summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/run_general_tests.py2
-rw-r--r--scripts/temporary_touchups.py12
-rwxr-xr-xscripts/touchup_for_android.py28
-rwxr-xr-xscripts/touchup_for_web.py19
4 files changed, 16 insertions, 45 deletions
diff --git a/scripts/run_general_tests.py b/scripts/run_general_tests.py
index ed327bb..bd62736 100755
--- a/scripts/run_general_tests.py
+++ b/scripts/run_general_tests.py
@@ -123,5 +123,7 @@ class TestLigatures(unittest.TestCase):
self.assertEqual(len(advances), 2)
+# TODO: Add test for version numbers being identical and being 2.version
+
if __name__ == '__main__':
unittest.main()
diff --git a/scripts/temporary_touchups.py b/scripts/temporary_touchups.py
index 1891bc2..20e407f 100644
--- a/scripts/temporary_touchups.py
+++ b/scripts/temporary_touchups.py
@@ -1,6 +1,10 @@
#!/usr/bin/python
"""Temporary post-build changes for Roboto."""
+from datetime import date
+import os
+from os import path
+
from nototools import font_data
import roboto_data
@@ -12,3 +16,11 @@ def apply_temporary_fixes(font):
weight = roboto_data.extract_weight_name(font_name)
weight_number = roboto_data.WEIGHTS[weight]
font['OS/2'].usWeightClass = weight_number
+
+ # Update version number from buildnumber.txt
+ build_number_txt = path.join(
+ path.dirname(__file__), os.pardir, 'res', 'buildnumber.txt')
+ build_number = open(build_number_txt).read().strip()
+ version_record = 'Version 2.%s; %d' % (build_number, date.today().year)
+ font_data.set_name_record(font, 5, version_record)
+
diff --git a/scripts/touchup_for_android.py b/scripts/touchup_for_android.py
index c8b844a..76a39ae 100755
--- a/scripts/touchup_for_android.py
+++ b/scripts/touchup_for_android.py
@@ -1,14 +1,10 @@
#!/usr/bin/python
"""Post-build changes for Roboto for Android."""
-import collections
-import os
-from os import path
import sys
from fontTools import ttLib
from nototools import font_data
-from nototools import unicode_data
import temporary_touchups
@@ -25,30 +21,6 @@ def drop_lookup(table, lookup_number):
feature.Feature.LookupCount -= 1
-def apply_temporary_fixes(font):
- """Apply some temporary fixes.
- """
- # Fix version number from buildnumber.txt
- # https://code.google.com/a/google.com/p/roboto/issues/detail?id=50
- from datetime import date
-
- build_number_txt = path.join(
- path.dirname(__file__), os.pardir, 'res', 'buildnumber.txt')
- build_number = open(build_number_txt).read().strip()
-
- version_record = 'Version 2.0%s; %d' % (build_number, date.today().year)
-
- for record in font['name'].names:
- if record.nameID == 5:
- if record.platformID == 1 and record.platEncID == 0: # MacRoman
- record.string = version_record
- elif record.platformID == 3 and record.platEncID == 1:
- # Windows UCS-2
- record.string = version_record.encode('UTF-16BE')
- else:
- assert False
-
-
def apply_android_specific_fixes(font):
"""Apply fixes needed for Android."""
# Set ascent, descent, and lineGap values to Android K values
diff --git a/scripts/touchup_for_web.py b/scripts/touchup_for_web.py
index 39e7c19..a5a282c 100755
--- a/scripts/touchup_for_web.py
+++ b/scripts/touchup_for_web.py
@@ -1,27 +1,12 @@
#!/usr/bin/python
"""Post-build web fonts changes for Roboto."""
-import os
-from os import path
import sys
from fontTools import ttLib
from nototools import font_data
-
-def apply_temporary_fixes(font):
- """Apply some temporary fixes.
- """
- # Fix version number from buildnumber.txt
- # https://code.google.com/a/google.com/p/roboto/issues/detail?id=50
- from datetime import date
-
- build_number_txt = path.join(
- path.dirname(__file__), os.pardir, 'res', 'buildnumber.txt')
- build_number = open(build_number_txt).read().strip()
-
- version_record = 'Version 2.%s; %d' % (build_number, date.today().year)
- font_data.set_name_record(font, 5, version_record)
+import temporary_touchups
def apply_web_specific_fixes(font, family_name):
@@ -71,7 +56,7 @@ def apply_web_specific_fixes(font, family_name):
def correct_font(source_font_name, target_font_name, family_name):
"""Corrects metrics and other meta information."""
font = ttLib.TTFont(source_font_name)
- apply_temporary_fixes(font)
+ temporary_touchups.apply_temporary_fixes(font)
apply_web_specific_fixes(font, family_name)
font.save(target_font_name)