Beispiel #1
0
    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)
Beispiel #2
0
    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))
Beispiel #3
0
    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)
Beispiel #4
0
def subset_process(project, build, log):
    from .app import app
    config = project.config

    param = {'login': project.login, 'id': project.id,
             'revision': build.revision, 'build': build.id}

    _out = os.path.join(app.config['DATA_ROOT'], '%(login)s/%(id)s.out/%(build)s.%(revision)s/' % param)
    _out_src = os.path.join(app.config['DATA_ROOT'], '%(login)s/%(id)s.out/%(build)s.%(revision)s/sources/' % param)

    log.write('Subset TTFs (pyftsubset)\n', prefix='### ')

    for subset in config['state']['subset']:
        os.chdir(_out_src)
        for name in glob.glob("*.ufo"):
            name = name[:-4]  # cut .ufo
            glyphs = open(SubsetExtension.get_subset_path(subset)).read()
            cmd = ("pyftsubset %(out)s.ttf %(glyphs)s"
                   " --layout-features='*' --glyph-names --symbol-cmap"
                   " --notdef-glyph --notdef-outline --recommended-glyphs"
                   " --name-IDs='*' --name-legacy --name-languages='*'"
                   " --hinting")
            cmd = cmd % {'glyphs': glyphs.replace('\n', ' '),
                         'out': os.path.join(_out, name)}
            run(cmd, cwd=_out, log=log)
            run('mv %(out)s.ttf.subset %(out)s.%(subset)s' % {'subset': subset,
                'out': os.path.join(_out, name)}, cwd=_out, log=log)
    # remove +latin from the subset name
    os.chdir(_out)
    files = glob.glob('*+latin*')
    for filename in files:
        newfilename = filename.replace('+latin', '')
        run("mv \"%s\" \"%s\"" % (filename, newfilename), cwd=_out, log=log)
Beispiel #5
0
    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
Beispiel #6
0
    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
Beispiel #7
0
def subset_process(project, build, log):
    from .app import app
    config = project.config

    param = {
        'login': project.login,
        'id': project.id,
        'revision': build.revision,
        'build': build.id
    }

    _out = os.path.join(app.config['DATA_ROOT'],
                        '%(login)s/%(id)s.out/%(build)s.%(revision)s/' % param)
    _out_src = os.path.join(
        app.config['DATA_ROOT'],
        '%(login)s/%(id)s.out/%(build)s.%(revision)s/sources/' % param)

    log.write('Subset TTFs (pyftsubset)\n', prefix='### ')

    for subset in config['state']['subset']:
        os.chdir(_out_src)
        for name in glob.glob("*.ufo"):
            name = name[:-4]  # cut .ufo
            glyphs = open(SubsetExtension.get_subset_path(subset)).read()
            cmd = ("pyftsubset %(out)s.ttf %(glyphs)s"
                   " --layout-features='*' --glyph-names --symbol-cmap"
                   " --notdef-glyph --notdef-outline --recommended-glyphs"
                   " --name-IDs='*' --name-legacy --name-languages='*'"
                   " --hinting")
            cmd = cmd % {
                'glyphs': glyphs.replace('\n', ' '),
                'out': os.path.join(_out, name)
            }
            run(cmd, cwd=_out, log=log)
            run('mv %(out)s.ttf.subset %(out)s.%(subset)s' % {
                'subset': subset,
                'out': os.path.join(_out, name)
            },
                cwd=_out,
                log=log)
    # remove +latin from the subset name
    os.chdir(_out)
    files = glob.glob('*+latin*')
    for filename in files:
        newfilename = filename.replace('+latin', '')
        run("mv \"%s\" \"%s\"" % (filename, newfilename), cwd=_out, log=log)