diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build-v2.py | 4 | ||||
-rw-r--r-- | scripts/lib/fontbuild/Build.py | 9 | ||||
-rw-r--r-- | scripts/lib/fontbuild/instanceNames.py | 2 | ||||
-rwxr-xr-x | scripts/lib/fontbuild/markFeature.py | 5 | ||||
-rwxr-xr-x | scripts/run_android_tests.py | 20 | ||||
-rwxr-xr-x | scripts/run_general_tests.py | 37 | ||||
-rwxr-xr-x | scripts/run_web_tests.py | 4 | ||||
-rwxr-xr-x | scripts/touchup_for_android.py | 14 | ||||
-rwxr-xr-x | scripts/touchup_for_web.py | 6 |
9 files changed, 81 insertions, 20 deletions
diff --git a/scripts/build-v2.py b/scripts/build-v2.py index 0ef86e9..6026939 100644 --- a/scripts/build-v2.py +++ b/scripts/build-v2.py @@ -101,7 +101,7 @@ proj.generateFont(Mix([rg, bd], 0.35), "%s/Medium/Regular/Lt"%FAMILYNAME) proj.generateFont(Mix([rg, bd], RPoint(0.73, 0.73)), "%s/Bold/Bold/Rg"%FAMILYNAME) proj.generateFont(Mix([rg, bd], RPoint(1.125, 1.0)), - "%s/Black/Bold/Bk"%FAMILYNAME) + "%s/Black/Regular/Bk"%FAMILYNAME) proj.generateFont(th.font, "%s/Thin Italic/Italic/Th"%FAMILYNAME, italic=True, stemWidth=80) @@ -115,7 +115,7 @@ proj.generateFont(Mix([rg, bd], RPoint(0.73, 0.73)), "%s/Bold Italic/Bold Italic/Rg"%FAMILYNAME, italic=True, stemWidth=290) proj.generateFont(Mix([rg, bd], RPoint(1.125, 1.0)), - "%s/Black Italic/Bold Italic/Bk"%FAMILYNAME, + "%s/Black Italic/Italic/Bk"%FAMILYNAME, italic=True, stemWidth=290) # unfortunately some condensed forms (*.cn) of glyphs are not compatible with diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py index be0b79c..a4e5bac 100644 --- a/scripts/lib/fontbuild/Build.py +++ b/scripts/lib/fontbuild/Build.py @@ -28,7 +28,7 @@ from fontbuild.features import readFeatureFile, writeFeatureFile from fontbuild.generateGlyph import generateGlyph from fontbuild.instanceNames import setNamesRF from fontbuild.italics import italicizeGlyph -from fontbuild.markFeature import RobotoFeatureCompiler +from fontbuild.markFeature import RobotoFeatureCompiler, RobotoKernWriter from fontbuild.mitreGlyph import mitreGlyph from fontbuild.mix import Mix,Master,narrowFLGlyph @@ -184,10 +184,10 @@ class FontProject: # fewer control points and look noticeably different max_err = 0.002 if self.compatible: - fonts_to_quadratic(*fonts, max_err_em=max_err, dump_report=True) + fonts_to_quadratic(fonts, max_err_em=max_err, dump_stats=True) else: for font in fonts: - fonts_to_quadratic(font, max_err_em=max_err, dump_report=True) + fonts_to_quadratic([font], max_err_em=max_err, dump_stats=True) log(">> Generating TTF files") for font in fonts: @@ -288,5 +288,6 @@ def saveOTF(font, destFile, truetype=False): compiler = compileTTF else: compiler = compileOTF - otf = compiler(font, featureCompilerClass=RobotoFeatureCompiler) + otf = compiler(font, featureCompilerClass=RobotoFeatureCompiler, + kernWriter=RobotoKernWriter) otf.save(destFile) diff --git a/scripts/lib/fontbuild/instanceNames.py b/scripts/lib/fontbuild/instanceNames.py index 281eb03..890b5a6 100644 --- a/scripts/lib/fontbuild/instanceNames.py +++ b/scripts/lib/fontbuild/instanceNames.py @@ -57,7 +57,7 @@ class InstanceNames: f.info.versionMajor = version f.info.versionMinor = versionMinor f.info.year = self.year - f.info.copyright = "Font data copyright %s %s" %(self.foundry, self.year) + #f.info.copyright = "Font data copyright %s %s" %(self.foundry, self.year) f.info.trademark = "%s is a trademark of %s." %(self.longfamily, self.foundry) f.info.openTypeNameDesigner = "Christian Robertson" diff --git a/scripts/lib/fontbuild/markFeature.py b/scripts/lib/fontbuild/markFeature.py index 945cef0..395e537 100755 --- a/scripts/lib/fontbuild/markFeature.py +++ b/scripts/lib/fontbuild/markFeature.py @@ -43,3 +43,8 @@ class RobotoFeatureCompiler(FeatureOTFCompiler): ["a", "uni0430"], ["e", "uni0435"], ["p", "uni0440"],
["c", "uni0441"], ["x", "uni0445"], ["s", "uni0455"],
["i", "uni0456"], ["psi", "uni0471"]]
+
+
+class RobotoKernWriter(KernFeatureWriter):
+ leftFeaClassRe = r"@_(.+)_L$"
+ rightFeaClassRe = r"@_(.+)_R$"
diff --git a/scripts/run_android_tests.py b/scripts/run_android_tests.py index 3751670..f6a1f46 100755 --- a/scripts/run_android_tests.py +++ b/scripts/run_android_tests.py @@ -19,12 +19,32 @@ import unittest from nototools.unittests import font_tests +import run_general_tests + FONTS = font_tests.load_fonts( ['out/android/*.ttf'], expected_count=18) +class TestMetaInfo(run_general_tests.TestMetaInfo): + """Bugs: + https://github.com/google/roboto/issues/142 + """ + + loaded_fonts = FONTS + mark_heavier_as_bold = True + + +class TestNames(run_general_tests.TestNames): + """Bugs: + https://github.com/google/roboto/issues/37 + """ + + loaded_fonts = FONTS + mark_heavier_as_bold = True + + class TestVerticalMetrics(font_tests.TestVerticalMetrics): loaded_fonts = FONTS test_glyphs_ymin_ymax = None diff --git a/scripts/run_general_tests.py b/scripts/run_general_tests.py index ddfae17..494651d 100755 --- a/scripts/run_general_tests.py +++ b/scripts/run_general_tests.py @@ -24,7 +24,7 @@ from nototools.unittests import font_tests import roboto_data FONTS = font_tests.load_fonts( - ['hinted/*.ttf'], + ['out/RobotoTTF/*.ttf', 'out/RobotoCondensedTTF/*.ttf'], expected_count=18) UFOS = font_tests.load_fonts( @@ -44,12 +44,13 @@ class TestItalicAngle(font_tests.TestItalicAngle): class TestMetaInfo(font_tests.TestMetaInfo): """Bugs: + https://github.com/google/roboto/issues/142 https://code.google.com/a/google.com/p/roboto/issues/detail?id=8 https://code.google.com/a/google.com/p/roboto/issues/detail?id=29 """ loaded_fonts = FONTS - mark_heavier_as_bold = True + mark_heavier_as_bold = False test_us_weight = None #expected_version = '2.' + roboto_data.get_build_number() @@ -60,6 +61,20 @@ class TestMetaInfo(font_tests.TestMetaInfo): expected_os2_achVendID = 'GOOG' +class TestNames(font_tests.TestNames): + """Bugs: + https://github.com/google/roboto/issues/37 + """ + + loaded_fonts = FONTS + family_name = 'Roboto' + mark_heavier_as_bold = False + expected_copyright = 'Copyright 2011 Google Inc. All Rights Reserved.' + + def expected_unique_id(self, family, style): + return 'Google:%s:2015' % family + + class TestDigitWidths(font_tests.TestDigitWidths): loaded_fonts = FONTS @@ -96,8 +111,22 @@ class TestVerticalMetrics(font_tests.TestVerticalMetrics): class TestGlyphAreas(font_tests.TestGlyphAreas): - loaded_fonts = UFOS - masters = UFO_MASTERS + master_weights_to_test = ['Thin', 'Bold'] + instance_weights_to_test = ['Thin', 'Regular', 'Bold'] + exclude = ['Condensed', 'Italic'] + + master_glyph_sets = [ + f.replace('_', '-') for f in UFO_MASTERS[0]], UFO_MASTERS[1] + instance_glyph_sets = FONTS[0], [f.getGlyphSet() for f in FONTS[1]] + + master_glyphs_to_test = UFO_MASTERS[1][0].keys() + instance_glyphs_to_test = FONTS[1][0].getGlyphOrder() + + #TODO maybe fix masters so that whitelisting isn't necessary + whitelist = [ + 'uni0488', # offset 20 units b/w masters, interpolated points are off + 'uni2050' # has flipped component, so contour is backwards in master + ] if __name__ == '__main__': diff --git a/scripts/run_web_tests.py b/scripts/run_web_tests.py index 4f051bf..5d3fd34 100755 --- a/scripts/run_web_tests.py +++ b/scripts/run_web_tests.py @@ -53,8 +53,8 @@ class TestNames(font_tests.TestNames): mark_heavier_as_bold = True expected_copyright = 'Copyright 2011 Google Inc. All Rights Reserved.' - def expected_unique_id(self, full_name): - return full_name + def expected_unique_id(self, family, style): + return family + ' ' + style class TestDigitWidths(font_tests.TestDigitWidths): diff --git a/scripts/touchup_for_android.py b/scripts/touchup_for_android.py index 187a432..e13adea 100755 --- a/scripts/touchup_for_android.py +++ b/scripts/touchup_for_android.py @@ -56,7 +56,7 @@ def apply_android_specific_fixes(font): hhea.lineGap = 0 # Remove combining keycap and the arrows from the cmap table: - # https://code.google.com/a/google.com/p/roboto/issues/detail?id=52 + # https://github.com/google/roboto/issues/99 font_data.delete_from_cmap(font, [ 0x20E3, # COMBINING ENCLOSING KEYCAP 0x2191, # UPWARDS ARROW @@ -68,6 +68,18 @@ def apply_android_specific_fixes(font): if table in font: del font[table] + # Set bold bits for Black (macStyle bit 0, fsSelection bit 5, subfamily) + name_records = font_data.get_name_records(font) + family_name = name_records[1] + subfam_name = name_records[2] + if family_name.endswith('Black'): + font['head'].macStyle |= (1 << 0) + font['OS/2'].fsSelection |= (1 << 5) + font['OS/2'].fsSelection &= ~(1 << 6) + new_subfam_name = ( + ('Bold ' + subfam_name) if subfam_name != 'Regular' else 'Bold') + font_data.set_name_record(font, 2, new_subfam_name) + def correct_font(source_font_name, target_font_name): """Corrects metrics and other meta information.""" diff --git a/scripts/touchup_for_web.py b/scripts/touchup_for_web.py index 3e29e58..7879d9e 100755 --- a/scripts/touchup_for_web.py +++ b/scripts/touchup_for_web.py @@ -47,12 +47,6 @@ def apply_web_specific_fixes(font, family_name): family_name += ' Condensed' full_name = family_name + ' ' + subfamily_name - # macStyle - bold = subfamily_name.startswith(('Bold', 'Black')) - italic = subfamily_name.endswith('Italic') - macStyle = (italic << 1) | bold - font['head'].macStyle = macStyle - # Family, subfamily names font_data.set_name_record(font, 16, family_name) style_map = ['Regular', 'Bold', 'Italic', 'Bold Italic'] |