def run(self, name, pipedata): # create menu subset with glyph for text of family name if pipedata.get('pyftsubset') is False: return self.bakery.logging_raw('### Subset TTFs (pyftsubset) {}\n'.format(name)) ttfont = ttLib.TTFont(op.join(self.builddir, name)) L = map(lambda X: (X.nameID, X.string), ttfont['name'].names) D = dict(L) string = bin2unistring(D.get(16) or D.get(1)) menu_glyphs = '\n'.join(['U+%04x' % ord(c) for c in string]) for subset in pipedata.get('subset', []): glyphs = SubsetExtension.get_glyphs(subset) # The every subsets must include the "latin" subset if subset != 'latin': glyphs += '\n{}'.format(SubsetExtension.get_glyphs('latin')) self.execute_pyftsubset(pipedata, subset, name, glyphs=glyphs) # If any subset other than latin or latin-ext has been # generated when the subsetting is done, this string should # additionally include some characters corresponding to each # of those subsets. G = SubsetExtension.get_glyphs(subset + '-menu') if G: menu_glyphs += '\n{}'.format(G) self.execute_pyftsubset(pipedata, 'menu', name, glyphs=menu_glyphs)
def run(self, pipedata): # create menu subset with glyph for text of family name if pipedata.get('pyftsubset') is False: return from bakery_cli.utils import ProcessedFile name = ProcessedFile() self.bakery.logging_raw( '### Subset TTFs (pyftsubset) {}\n'.format(name)) ttfont = ttLib.TTFont(op.join(self.builddir, name)) L = map(lambda X: (X.nameID, X.string), ttfont['name'].names) D = dict(L) string = bin2unistring(D.get(16) or D.get(1)) menu_glyphs = '\n'.join(['U+%04x' % ord(c) for c in string]) for subset in pipedata.get('subset', []): glyphs = SubsetExtension.get_glyphs(subset) # The every subsets must include the "latin" subset if subset != 'latin': glyphs += '\n{}'.format(SubsetExtension.get_glyphs('latin')) self.execute_pyftsubset(pipedata, subset, name, glyphs=glyphs) # If any subset other than latin or latin-ext has been # generated when the subsetting is done, this string should # additionally include some characters corresponding to each # of those subsets. G = SubsetExtension.get_glyphs(subset + '-menu') if G: menu_glyphs += '\n{}'.format(G) self.execute_pyftsubset(pipedata, 'menu', name, glyphs=menu_glyphs)
def execute(self, pipedata, prefix=""): self.stdout_pipe.write('Subset TTFs (pyftsubset)\n', prefix='### %s ' % prefix) os.chdir(op.join(self.builddir, 'sources')) for name in pipedata['bin_files']: # create menu subset with glyph for text of family name ttfont = ttLib.TTFont(op.join(self.builddir, name)) L = map(lambda X: (X.nameID, X.string), ttfont['name'].names) D = dict(L) string = bin2unistring(D.get(16) or D.get(1)) menu_glyphs = ['U+%04x' % ord(c) for c in string] for subset in pipedata.get('subset', []): glyphs = SubsetExtension.get_glyphs(subset) # The Devanagari subset must include the latin unicode set too if subset == 'devanagari': G = SubsetExtension.get_glyphs('latin') glyphs += ' ' + ' '.join(G.split()) self.execute_pyftsubset(pipedata, subset, name, glyphs=glyphs) # If any subset other than latin or latin-ext has been # generated when the subsetting is done, this string should # additionally include some characters corresponding to each # of those subsets. G = SubsetExtension.get_glyphs(subset + '-menu') if G: menu_glyphs += G.split() self.execute_pyftsubset(pipedata, 'menu', name, glyphs='\n'.join(menu_glyphs))
def execute(self, pipedata): task = self.bakery.logging_task('Subset TTFs (pyftsubset)') if self.bakery.forcerun: return try: for name in pipedata['bin_files']: # create menu subset with glyph for text of family name ttfont = ttLib.TTFont(op.join(self.builddir, name)) L = map(lambda X: (X.nameID, X.string), ttfont['name'].names) D = dict(L) string = bin2unistring(D.get(16) or D.get(1)) menu_glyphs = ['U+%04x' % ord(c) for c in string] for subset in pipedata.get('subset', []): glyphs = SubsetExtension.get_glyphs(subset) # The every subsets must include the "latin" subset if subset != 'latin': G = SubsetExtension.get_glyphs('latin') glyphs += ' ' + ' '.join(G.split()) self.execute_pyftsubset(pipedata, subset, name, glyphs=glyphs) # If any subset other than latin or latin-ext has been # generated when the subsetting is done, this string should # additionally include some characters corresponding to each # of those subsets. G = SubsetExtension.get_glyphs(subset + '-menu') if G: menu_glyphs += G.split() self.execute_pyftsubset(pipedata, 'menu', name, glyphs='\n'.join(menu_glyphs)) self.bakery.logging_task_done(task) except: self.bakery.logging_task_done(task, failed=True) raise
def execute(self, pipedata): task = self.bakery.logging_task('Subset TTFs (pyftsubset)') if self.bakery.forcerun: return try: for name in pipedata['bin_files']: # create menu subset with glyph for text of family name ttfont = ttLib.TTFont(op.join(self.builddir, name)) L = map(lambda X: (X.nameID, X.string), ttfont['name'].names) D = dict(L) string = bin2unistring(D.get(16) or D.get(1)) menu_glyphs = ['U+%04x' % ord(c) for c in string] for subset in pipedata.get('subset', []): glyphs = SubsetExtension.get_glyphs(subset) # The every subsets must include the "latin" subset if subset != 'latin': G = SubsetExtension.get_glyphs('latin') glyphs += ' ' + ' '.join(G.split()) self.execute_pyftsubset(pipedata, subset, name, glyphs=glyphs) # If any subset other than latin or latin-ext has been # generated when the subsetting is done, this string should # additionally include some characters corresponding to each # of those subsets. G = SubsetExtension.get_glyphs(subset + '-menu') if G: menu_glyphs += G.split() self.execute_pyftsubset(pipedata, 'menu', name, glyphs='\n'.join(menu_glyphs)) self.bakery.logging_task_done(task) except: self.bakery.logging_task_done(task, failed=True) raise