Skip to content

mf2pt1.pl: Fix bounding boxes

Werner Lemberg requested to merge dev/wl/bounding-boxes into master

After mf2pt1 converts a METAFONT font to a raw Type1 PostScript font, it calls FontForge to do some clean-ups while producing (intermediate) Type1 fonts:

  • removal of outline overlaps
  • simplification of glyph outlines (especially important for Parmesan glyphs, which still consist mostly of high-number-polygonal pens because nobody has found time yet to make them better suitable to outline conversion)
  • correct outline directions
  • adding outline extremum points
  • rounding coordinates
  • hinting the glyphs

Up to now, the default, built-in FontForge script of mf2pt1 added extremum points before simplifying outlines. A closer inspection triggered by Merge Request !2370 revealed that glyph simplification does not preserve extremum points, which can be considered a bug or an undocumented feature of FontForge (tested version was a build using sources from March 2024; see https://github.com/fontforge/fontforge/issues/5266). The consequence was that a number of Emmentaler glyphs like 'one' or 'accidentals.hufnagelM1' had wider or taller bounding boxes for both Pango and LilyPond than expected.

[For speed, the bounding box used by Pango and LilyPond is actually not the real outline's bounding box but the one derived from the outline's control points. It is thus important that extremum points are part of the outlines so that the horizontal and vertical dimensions of the control point bounding box is equal to the outline bounding box.]

This commit ensures that extremum points are added after the first round of glyph simplifications, thus ensuring tight bounding boxes.

Edited by Werner Lemberg

Merge request reports