Author :
Werner Lemberg
Date :
2025-04-14 15:48:33
Hash :d1ac9524 Message :[autofit] Fix creation of the adjustment database's reverse map.
Due to the way the reverse map array gets constructed with HarfBuzz, there
might be multiple, identical glyph index entries with different character
values in the array. As an example, an OpenType feature like 'unic' might
map lowercase glyph 'ae' to uppercase glyph 'AE', in addition to the already
present cmap entry for 'AE'.
In most cases, this incorrect mapping is harmless (but still wrong).
However, there exist some lowercase/uppercase character pairs where the
diacritic for the uppercase character is on the other vertical side of the
base character as for the lowercase character. An example is U+0122 (LATIN
CAPITAL LETTER G WITH CEDILLA) and U+0123 (LATIN SMALL LETTER G WITH
CEDILLA): the former has the cedilla below, the latter above. A wrong
mapping would thus shift the base glyph 'G' up by a pixel instead of
shifting the cedilla down.
We fix this by always giving precedence to cmap entries.
* src/autofit/afadjust.c (af_reverse_character_map_entry_compare): Do a
secondary sort on the character code.
(af_reverse_character_map_lookup): Adjust binary search to return the
first occurrence of an entry (i.e., the one with the lowest array index).
(af_reverse_character_map_new)[FT_CONFIG_OPTION_USE_HARFBUZZ]: Implement
cmap priority.