[merge] use recalcXAvgCharWidth method on merged font

Fixes #2538, supersedes #2590
This commit is contained in:
Cosimo Lupo 2022-04-21 18:46:57 +01:00
parent 12942feb6b
commit ee2d83d4b3
3 changed files with 7 additions and 2 deletions

View File

@ -155,6 +155,11 @@ class Merger(object):
def _postMerge(self, font):
layoutPostMerge(font)
if "OS/2" in font:
# https://github.com/fonttools/fonttools/issues/2538
# TODO: Add an option to disable this?
font["OS/2"].recalcXAvgCharWidth(font)
__all__ = [
'Options',

View File

@ -132,7 +132,7 @@ ttLib.getTableClass('OS/2').mergeMap = {
'*': first,
'tableTag': equal,
'version': max,
'xAvgCharWidth': avg_int, # Apparently fontTools doesn't recalc this
'xAvgCharWidth': first, # Will be recalculated at the end on the merged font
'fsType': mergeOs2FsType, # Will be overwritten
'panose': first, # FIXME: should really be the first Latin font
'ulUnicodeRange1': bitwise_or,

View File

@ -834,7 +834,7 @@
<!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
will be recalculated by the compiler -->
<version value="4"/>
<xAvgCharWidth value="505"/>
<xAvgCharWidth value="501"/>
<usWeightClass value="400"/>
<usWidthClass value="5"/>
<fsType value="00000000 00000000"/>