Some time ago I was asked to document how to prepare MWE for reporting FontForge problems with Emmentaler. Here it is.
How to report `FontForge` problems while creating LilyPond fonts ================================================================ The output produced by the `mf2pt1` script to convert METAFONT input files to Type1 PostScript fonts often contains overlapping glyphs. This should be avoided in general.[1] For this reason, `mf2pt1` by default calls `FontForge` in batch mode to remove overlaps. The code in `FontForge` that handles such overlaps is quite a complicated piece of software. Due to its complexity it is not well maintained since the original author of the program left the project many years ago. To help fix warnings and errors it is thus quite important to produce minimal working examples (MWEs). Based on such input the debugging and fixing of such problems is much easier and might eventually lead to a patch by the FontForge development team. Note that the FontForge errors don't result in unusable fonts, fortunately. They simply lack some overlap removals, which are invisible. However, this might be sheer coincidence only, so it's better that FontForge gets improved :-) Preliminaries ------------- In the following, the input font `feta11` gets used for examples. Using a FontForge executable based on the git repository from Feb. 22nd, 2020, the following warnings are produced while calling mf2pt1 --rounding=0.0001 feta11.mf (as recommended in the `mf/README` file). Internal Error (overlap) in scripts.reverseturn: \ Fixup error 2 in MergeIntersections. Internal Error (overlap) in scripts.reverseturn: \ Could not find finalm [missing newline] Internal Error (overlap) in scripts.turn: \ Fixup error 2 in MergeIntersections. Internal Error (overlap) in scripts.turn: \ Could not find finalm [missing newline] The errors for both glyphs are similar; we are thus going to prepare an MWE with a single glyph only (`scripts.turn`). Call `mf2pt1` without `t1asm` ----------------------------- Another program used by `mf2pt1` is `t1asm`; it converts the plain text data produced by the `mpost` program (which directly handles the METAFONT input files) into a Type1 font in the binary `PFB` format. To suppress its execution, set the `T1ASM` environment variable to a non-existent program. T1ASM=foo ./mf2pt1 --rounding=0.0001 feta11.mf As a result we get a file `feta11.pt1`, which has a size of approx. 266kByte. Massage `feta11.pt1` -------------------- We are now going to reduce the size of `feta11.pt1`. * Remove all entries in the encoding vector except the one for `/scripts.turn`. * Remove all entries in the `/CharStrings` dictionary except for `/scripts.turn` and `/.notdef' (the latter glyph should be present in any Type1 font). As a result we get a disassembled font with exactly two glyphs. We call it `scripts.turn.pt1`; it has a size of less than 3kByte. Prepare input data for `fontforge` ---------------------------------- We now manually call `t1asm` to produce the PFB file. t1asm scripts.turn.pt1 > scripts.turn.pfb Since `fontforge` is doing in-place editing,[2] we also prepare a copy. cp scripts.turn.pfb scripts.turn.orig.pfb If no FontForge batchfile is explicitly given, `mf2pt1` uses the following (as can be seen if you look into the script). Open($1); SelectAll(); RemoveOverlap(); AddExtrema(); Simplify(0, 2); CorrectDirection(); Simplify(0, 2); RoundToInt(); AutoHint(); Generate($1); Quit(0); All known FontForge problems happen at the `RemoveOverlap` stage; this means that we can use a simplified script containing only Open($1); SelectAll(); RemoveOverlap(); Generate($1); Quit(0); to trigger the issue. We save this as `scripts.turn.txt`. Call `fontforge` ---------------- We are now ready to finally call FontForge. fontforge -script scripts.turn.txt scripts.turn.pfb And indeed, we get the same error messages as with the original, big input file. Visual comparison of `scripts.turn.orig.pfb` and `scripts.turn.pfb` shows that FontForge does the right thing (i.e., correctly removing the glyph overlap) inspite of complaining. * * * The problem described above has been filed as https://github.com/fontforge/fontforge/issues/4184 [1] Since the advent of Variation Fonts (VF) this is no longer a problem with platforms or applications that can handle them. However, not all software stacks support them. [2] This could be easily avoided by adjusting the script. However, it would complicate the MWE, which should be rather avoided.