check-ttf.py: check_regression_ttfauto_xheight_increase added.
Regression check to test whether the local fonts have the
same ttfautohint values for the parameter --increase-x-height'
@@ -760,6 +760,28 @@ def glyphs_surface_area(font):
return glyphs
+def ttfauto_fpgm_xheight_rounding(fpgm_tbl):
+ '''Find the value from the fpgm table which controls ttfautohint's
+ increase xheight parameter, '--increase-x-height'.
+ This implementation is based on ttfautohint v1.6.
+
+ This function has been tested on every font in the fonts/google repo
+ which has an fpgm table. Results have been stored in a spreadsheet:
+ http://tinyurl.com/jmlfmh3
+
+ For more information regarding the fpgm table read:
+ http://tinyurl.com/jzekfyx
+ '''
+ fpgm_tbl = '\n'.join(fpgm_tbl)
+ xheight_pattern = r'(MPPEM\[ \].*\nPUSHW\[ \].*\n)([0-9]{1,5})'
+ try:
+ xheight_val = int(re.search(xheight_pattern, fpgm_tbl).group(2))
+ except AttributeError:
+ # No instruction for xheight rounding exists
+ xheight_val = None
+ return xheight_val
+
+
# =======================================================================
# The following functions implement each of the individual checks per-se.
# =======================================================================
@@ -3937,6 +3959,25 @@ def check_regression_glyphs_structure(fb, new_font, old_font, f):
))
+def check_regression_ttfauto_xheight_increase(fb, new_font, old_font, f):
+ fb.new_check("TTFAutohint x-height increase value is same as "
+ "previouse release?")
+ new_fpgm_tbl = new_font['fpgm'].program.getAssembly()
+ old_fpgm_tbl = old_font['fpgm'].program.getAssembly()
+ new_inc_xheight = ttfauto_fpgm_xheight_rounding(new_fpgm_tbl)
+ old_inc_xheight = ttfauto_fpgm_xheight_rounding(old_fpgm_tbl)
+
+ if new_inc_xheight != old_inc_xheight:
+ fb.error("TTFAutohint --increase-x-height is %s. "
+ "It should match the previous version's value %s" % (
+ new_inc_xheight, old_inc_xheight
+ )
+ )
+ else:
+ fb.ok("TTFAutohint --increase-x-height is the same as the previous "
+ "release, %s" % (new_inc_xheight))
+
+
class target_font(object):
def __init__(self, ttfont=None, desc={}):
self.ttfont = ttfont
@@ -4328,6 +4369,12 @@ def fontbakery_check_ttf(config):
remote_styles[style],
f
)
+ check_regression_ttfauto_xheight_increase(
+ fb,
+ local_styles[style],
+ remote_styles[style],
+ f
+ )
fb.output_report(target)
fb.reset_report()
