예제 #1
0
 def test_font_unencoded_glyphs(self):
     """ Font does not have unencoded glyphs """
     ttx = ttLib.TTFont(self.operator.path, 0)
     unencoded_glyphs = get_unencoded_glyphs(ttx)
     self.assertIs(unencoded_glyphs, [],
                   msg='There should not be unencoded glyphs')
예제 #2
0
 def test_font_unencoded_glyphs(self):
     """ Font does not have unencoded glyphs """
     ttx = ttLib.TTFont(self.operator.path, 0)
     unencoded_glyphs = get_unencoded_glyphs(ttx)
     self.assertIs(unencoded_glyphs, [],
                   msg='There should not be unencoded glyphs')
#
# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.
from __future__ import print_function
import argparse
import os

import fontTools.ttLib
from bakery_cli.fixers import AddSPUAByGlyphIDToCmap, get_unencoded_glyphs


description = 'Fixes TTF unencoded glyphs to have Private Use Area encodings'

parser = argparse.ArgumentParser(description=description)
parser.add_argument('ttf_font', nargs='+',
                    help='Font in OpenType (TTF/OTF) format')
parser.add_argument('--autofix', action="store_true",
                    help='Apply autofix. '
                         'Otherwise just check if there are unencoded glyphs')

args = parser.parse_args()

for path in args.ttf_font:
    if not os.path.exists(path):
        continue

    if args.autofix:
        AddSPUAByGlyphIDToCmap(None, path).apply()
    else:
        ttx = fontTools.ttLib.TTFont(path, 0)
        print('{0}: {1}'.format(path, get_unencoded_glyphs(ttx)))