font-patcher: Fix broken diacritic glyphs in monospaced font

[why]
Some glyphs are just used as overlays for 'real' glyphs. These can be
for example U+0300 .. U+036F (the 'COMBINING ...' diactritics) like
  U+0300, gravecomb, COMBINING GRAVE ACCENT
  U+0301, acutecomb, COMBINING ACUTE ACCENT
  U+0308, uni0308, COMBINING DIAERESIS

They are never used on their own, at least they are overlayed over a
blanc (U+0020, space).

For the font rendering engine they need to have the correct negative
bearings, so they are shifted to take no space by themselves.

The font-patcher script does not allow negative bearings in monospaced
fonts. This makes sense if every glyph is in itself a 'letter' that
should not reach beyond it's allotted (monospaced) space.

[how]
In the font-patcher script we do not touch the bearings of such overlay
glyphs. They can be identified by their width of zero.

For Windows to detect this font as 'monospaced' we need to change the
width to the standard width, though.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2019-10-24 08:21:02 +02:00
parent a2f0958ae5
commit d307a73356

View file

@ -789,7 +789,14 @@ class font_patcher:
# Ligartures will have these.
continue
if (glyph.width != 0):
# If the width is zero this glyph is intened to be printed on top of another one.
# In this case we need to keep the negative bearings to shift it 'left'.
# Things like &Auml; have these: composed of U+0041 'A' and U+0308 'double dot above'
#
# If width is not zero, correct the bearings such that they are within the width:
self.remove_glyph_neg_bearings(glyph)
self.set_glyph_width_mono(glyph)