Example #1
0
    def execute_ufo_sfd(self, files, pipedata):
        _ = 'fontbakery-build-font2ttf.py %s %s'

        for filepath in files:
            ttfpath = os.path.basename(filepath)[:-4] + '.ttf'

            try:
                if self.bakery.config.get('compiler') == 'afdko':
                    import time
                    starttime = time.time()
                    command = 'makeotf -f {0} {1} -o {2}.otf'.format(
                        op.join(self.builddir, filepath),
                        self.bakery.config.get('afdko', ''),
                        op.join(self.builddir, filepath)[:-4])
                    self.bakery.logging_cmd(
                        op.join(self.builddir, op.dirname(filepath)))
                    run(command, op.join(self.builddir, op.dirname(filepath)))
                    elapsedtime = time.time() - starttime
                    self.bakery.logging_raw(
                        'Time elapsed: {}'.format(elapsedtime))
                    self.otf2ttf('{}.otf'.format(filepath[:-4]), pipedata)
                else:
                    self.bakery.logging_cmd(_ % (filepath, ttfpath))
                    convert(op.join(self.builddir, filepath),
                            op.join(self.builddir, ttfpath))
                    self.run_processes(op.basename(ttfpath), pipedata)
            except Exception as ex:
                self.bakery.logging_err(ex.message)
                raise
Example #2
0
    def execute_ufo_sfd(self, files, pipedata):
        _ = 'fontbakery-build-font2ttf.py %s %s'

        for filepath in files:
            ttfpath = os.path.basename(filepath)[:-4] + '.ttf'

            try:
                if self.bakery.config.get('compiler') == 'afdko':
                    import time
                    starttime = time.time()
                    command = 'makeotf -f {0} {1} -o {2}.otf'.format(op.join(self.builddir, filepath),
                                                                     self.bakery.config.get('afdko', ''),
                                                                     op.join(self.builddir, filepath)[:-4])
                    self.bakery.logging_cmd(op.join(self.builddir, op.dirname(filepath)))
                    run(command, op.join(self.builddir, op.dirname(filepath)))
                    elapsedtime = time.time() - starttime
                    self.bakery.logging_raw('Time elapsed: {}'.format(elapsedtime))
                    self.otf2ttf('{}.otf'.format(filepath[:-4]), pipedata)
                else:
                    self.bakery.logging_cmd(_ % (filepath, ttfpath))
                    convert(op.join(self.builddir, filepath),
                            op.join(self.builddir, ttfpath))
                    self.run_processes(op.basename(ttfpath), pipedata)
            except Exception as ex:
                self.bakery.logging_err(ex.message)
                raise
Example #3
0
    def convert_otf2ttf(self, builddir):
        _ = '$ font2ttf.py {0}.otf {0}.ttf\n'
        self.stdout_pipe.write(_.format(self.postscript_fontname))

        try:
            path = op.join(builddir, 'sources',
                           self.postscript_fontname + '.otf')
            ttfpath = op.join(builddir, self.postscript_fontname + '.ttf')
            convert(path, ttfpath, log=self.stdout_pipe)
        except Exception, ex:
            self.stdout_pipe.write('Error: %s\n' % ex.message)
Example #4
0
    def convert_otf2ttf(self, builddir):
        _ = '$ font2ttf.py {0}.otf {0}.ttf\n'
        self.stdout_pipe.write(_.format(self.postscript_fontname))

        try:
            path = op.join(builddir, 'sources',
                           self.postscript_fontname + '.otf')
            ttfpath = op.join(builddir, self.postscript_fontname + '.ttf')
            convert(path, ttfpath, log=self.stdout_pipe)
        except Exception, ex:
            self.stdout_pipe.write('Error: %s\n' % ex.message)
Example #5
0
    def execute_ufo_sfd(self, files):
        for f in files:
            filepath = op.join(self.builddir, f)
            _ = 'font2ttf.py %s %s'
            self.bakery.logging_cmd(_ % (filepath,
                                         filepath[:-4] + '.ttf'))
            ttfpath = filepath[:-4] + '.ttf'

            try:
                convert(op.join(self.builddir, filepath),
                        op.join(self.builddir, ttfpath), log=self.bakery.log)
            except Exception, ex:
                self.bakery.logging_err(ex.message)
                raise
Example #6
0
    def execute_ufo_sfd(self, files):
        for f in files:
            filepath = op.join(self.builddir, f)
            _ = 'font2ttf.py %s %s'
            self.bakery.logging_cmd(_ % (filepath, filepath[:-4] + '.ttf'))
            ttfpath = filepath[:-4] + '.ttf'

            try:
                convert(op.join(self.builddir, filepath),
                        op.join(self.builddir, ttfpath),
                        log=self.bakery.log)
            except Exception, ex:
                self.bakery.logging_err(ex.message)
                raise
Example #7
0
    def after_copy(self, builddir):
        from scripts.font2ttf import convert
        _ = '$ font2ttf.py %s %s %s'
        self.stdout_pipe.write(_ % (self.source_path,
                                    self.postscript_fontname + '.ttf',
                                    self.postscript_fontname + '.otf'))

        ufopath = op.join(builddir, 'sources', self.get_file_name())
        ttfpath = op.join(builddir, self.postscript_fontname + '.ttf')
        otfpath = op.join(builddir, self.postscript_fontname + '.otf')

        try:
            convert(ufopath, ttfpath, otfpath, log=self.stdout_pipe)
        except Exception, ex:
            self.stdout_pipe.write('FAILED\nError: %s\n' % ex.message)
Example #8
0
    def convert_ufo2ttf(self, builddir):

        _ = '$ font2ttf.py %s %s %s'
        self.stdout_pipe.write(_ % (self.source_path,
                                    self.postscript_fontname + '.ttf',
                                    self.postscript_fontname + '.otf'))

        ufopath = op.join(builddir, 'sources', self.get_file_name())
        ttfpath = op.join(builddir, self.postscript_fontname + '.ttf')
        otfpath = op.join(builddir, self.postscript_fontname + '.otf')

        try:
            convert(ufopath, ttfpath, otfpath, log=self.stdout_pipe)
        except Exception, ex:
            self.stdout_pipe.write('# Error: %s\n' % ex.message)
Example #9
0
    def after_copy(self, builddir):
        from scripts.font2ttf import convert
        _ = '$ font2ttf.py %s %s %s'
        self.stdout_pipe.write(
            _ % (self.source_path, self.postscript_fontname + '.ttf',
                 self.postscript_fontname + '.otf'))

        ufopath = op.join(builddir, 'sources', self.get_file_name())
        ttfpath = op.join(builddir, self.postscript_fontname + '.ttf')
        otfpath = op.join(builddir, self.postscript_fontname + '.otf')

        try:
            convert(ufopath, ttfpath, otfpath, log=self.stdout_pipe)
        except Exception, ex:
            self.stdout_pipe.write('FAILED\nError: %s\n' % ex.message)
Example #10
0
    def convert_ufo2ttf(self, builddir):

        _ = '$ font2ttf.py %s %s %s'
        self.stdout_pipe.write(
            _ % (self.source_path, self.postscript_fontname + '.ttf',
                 self.postscript_fontname + '.otf'))

        ufopath = op.join(builddir, 'sources', self.get_file_name())
        ttfpath = op.join(builddir, self.postscript_fontname + '.ttf')
        otfpath = op.join(builddir, self.postscript_fontname + '.otf')

        try:
            convert(ufopath, ttfpath, otfpath, log=self.stdout_pipe)
        except Exception, ex:
            self.stdout_pipe.write('# Error: %s\n' % ex.message)
Example #11
0
    def otf2ttf(self, filepath):
        fontname = filepath[:-4]

        _ = 'font2ttf.py {0}.otf {0}.ttf\n'
        self.bakery.logging_cmd(_.format(fontname))

        path = '{}.otf'.format(fontname)
        if op.exists(op.join(self.builddir, path)):
            try:
                ttfpath = '{}.ttf'.format(fontname)
                convert(op.join(self.builddir, path),
                        op.join(self.builddir, ttfpath), log=self.bakery.log)
                os.remove(op.join(self.builddir, path))
            except Exception, ex:
                self.bakery.logging_err(ex.message)
                raise
Example #12
0
    def otf2ttf(self, filepath):
        fontname = filepath[:-4]

        _ = 'font2ttf.py {0}.otf {0}.ttf\n'
        self.bakery.logging_cmd(_.format(fontname))

        path = '{}.otf'.format(fontname)
        if op.exists(op.join(self.builddir, path)):
            try:
                ttfpath = '{}.ttf'.format(fontname)
                convert(op.join(self.builddir, path),
                        op.join(self.builddir, ttfpath),
                        log=self.bakery.log)
                os.remove(op.join(self.builddir, path))
            except Exception, ex:
                self.bakery.logging_err(ex.message)
                raise
Example #13
0
    def otf2ttf(self, filepath, pipedata):
        fontname = filepath[:-4]

        ttfpath = '{}.ttf'.format(op.basename(fontname))

        path = '{}.otf'.format(op.basename(fontname))

        if op.exists(op.join(self.builddir, path)):
            _ = 'fontbakery-build-font2ttf.py {0}.otf {1}\n'
            self.bakery.logging_cmd(_.format(fontname, ttfpath))
            try:
                convert(op.join(self.builddir, path),
                        op.join(self.builddir, ttfpath),
                        log=self.bakery.logger)
                os.remove(op.join(self.builddir, path))
            except Exception as ex:
                self.bakery.logging_err(ex.message)
                raise

        self.start_processes(ttfpath, pipedata)
Example #14
0
    def otf2ttf(self, filepath, pipedata):
        fontname = filepath[:-4]

        ttfpath = '{}.ttf'.format(op.basename(fontname))

        path = '{}.otf'.format(op.basename(fontname))

        if op.exists(op.join(self.builddir, 'sources', path)):
            _ = 'fontbakery-build-font2ttf.py {0}.otf {1}\n'
            self.bakery.logging_cmd(_.format(fontname, ttfpath))
            try:
                convert(op.join(self.builddir, 'sources', path),
                        op.join(self.builddir, 'sources', ttfpath))
                os.remove(op.join(self.builddir, 'sources', path))
            except Exception as ex:
                self.bakery.logging_err(ex.message)
                raise

        shellutil.move(op.join(self.builddir, 'sources', ttfpath),
                       op.join(self.builddir, ttfpath))
        self.run_processes(ttfpath, pipedata)
Example #15
0
# $ fontbakery-build-font2ttf.py font.ufo font.ttf font.otf
# $ fontbakery-build-font2ttf.py font.otf font.ttf
from __future__ import print_function

import argparse
import os
import sys

from bakery_cli.scripts import font2ttf

parser = argparse.ArgumentParser()
parser.add_argument('--with-otf',
                    action="store_true",
                    help='Generate otf file')
parser.add_argument('source', nargs='+', type=str)

args = parser.parse_args()

for src in args.source:
    if not os.path.exists(src):
        print('\nError: {} does not exists\n'.format(src), file=sys.stderr)
        continue

    basename, _ = os.path.splitext(src)

    otffile = None
    if args.with_otf:
        otffile = '{}.otf'.format(basename)

    font2ttf.convert(src, '{}.ttf'.format(basename), otffile)
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.
#
# Convert a source font into OpenType-TTF and optionally also OpenType-CFF
#
# $ fontbakery-build-font2ttf.py font.sfd font.ttf font.otf
# $ fontbakery-build-font2ttf.py font.sfdir font.ttf font.otf
# $ fontbakery-build-font2ttf.py font.ufo font.ttf font.otf
# $ fontbakery-build-font2ttf.py font.otf font.ttf
import sys
from bakery_cli.scripts import font2ttf


if __name__ == '__main__':
    if len(sys.argv) < 3:
        print "Usage: %s <source font> <ttf> [<otf>]" % sys.argv[0]
        sys.exit(0)
    print("Input: %s, Output: %s" % (sys.argv[1], ', '.join(sys.argv[1:])))
    font2ttf.convert(*sys.argv[1:])
# $ fontbakery-build-font2ttf.py font.ufo font.ttf font.otf
# $ fontbakery-build-font2ttf.py font.otf font.ttf
from __future__ import print_function

import argparse
import os
import sys

from bakery_cli.scripts import font2ttf


parser = argparse.ArgumentParser()
parser.add_argument('--with-otf', action="store_true",
                    help='Generate otf file')
parser.add_argument('source', nargs='+', type=str)

args = parser.parse_args()

for src in args.source:
    if not os.path.exists(src):
        print('\nError: {} does not exists\n'.format(src), file=sys.stderr)
        continue

    basename, _ = os.path.splitext(src)

    otffile = None
    if args.with_otf:
        otffile = '{}.otf'.format(basename)

    font2ttf.convert(src, '{}.ttf'.format(basename), otffile)