I am working on a scalable bitmap-like (a.k.a. pixelated) outline TTF font that sources its glyphs from a HEX plain-text file (like what Unifoundry’s Unifont project uses) that was originally sourced from a machine-generated BDF font. Because neither HEX nor BDF provides for mapping one single glyph (like “-”) to two or more character codepoints expecting to share one same glyph (like U+002D HYPHEN-MINUS, U+00AD SOFT HYPHEN, U+2010 HYPHEN, & U+2011 NON-BREAKING HYPHEN) due to their one-to-one glyph-to-char nature, my SFD project always ends up with an unnecessary amount of exact-duplicate glyphs.
I want to trim down the number of stored glyphs within my font project to an acceptable minimum of unique glyphs (allowing multiple encoding slots for certain glyphs like “-” from the example above) and thus reduce the final font size without decreasing Unicode coverage, but I don’t know if there is some automated, Perl-scriptable way for FontForge to detect all exact glyph duplicates within a font and merge/unify them all into single unique glyphs encoded to multiple characters. (I do not have the patience to manually check one-by-one all cases of glyph duplication in my font.)
Any help here would be greatly appreciated. Thankees!
Comments
It can be easily done with Python, but with Perl... Idk
Well, the only Python I know is what I learned when dealing with VapourSynth (a video frame-editing-&-serving framework often used with VirtualDub2), but maybe if you show me an example Python code of what you could do to deal with your glyph-compositing case, maybe I could see if there is something there that could perhaps apply to my case – and if I see a way to rewrite it in Perl, then better. (It’s not the first time I do translate a Python code to Perl – I once did that when trying to rewrite code for mapping a non-Unicode BDF font to Unicode before applying the Unifont scripts to convert it to HEX and then to outlined TTF.)
Thankee! (hopefully)
1. use the CPAN module Font::TTF
It supports only the TTF file format. It can read, manipulate and write the tables of a font. The time needed to get into the guts is high.
2. use the command line utility ttx coming with FontForge resp. font-tools. Then manipulate the ttx file with your favorite XML module and convert it back to TTF.
I have a similar problem in repairing amateurish historical fonts. Duplicate glyphs, glyphs with a wrong code point, code points in the PUA.