のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

adobe variable font prototype をwindowsでbuildしてみる

buildFont.shは、コマンドプロンプトでは動かなかった。

gitで入れた、git bashで動かすと、スクリプト部分は動いた。

MINGW64のbashだと、思われる。

m_fujii@None53-Surface MINGW64 ~/Documents/GitHub/adobe-variable-font-prototype (master)

$ ./buildFont.sh
./buildFont.sh: line 8: buildmasterotfs: command not found
./buildFont.sh: line 9: buildcff2vf: command not found
Subroutinizing RomanMasters/AdobeVFPrototype.otf
sfntedit [FATAL]: file error <No such file or directory> [RomanMasters/AdobeVFPrototype.otf]
./buildFont.sh: line 20: fontmake: command not found
./buildFont.sh: line 24: ttx: command not found
sfntedit [FATAL]: file error <No such file or directory> [RomanMasters/AdobeVFPrototype.otf]
sfntedit [FATAL]: file error <No such file or directory> [RomanMasters/AdobeVFPrototype.ttf]
sfntedit [FATAL]: file error <No such file or directory> [RomanMasters/AdobeVFPrototype.ttf]
sfntedit [FATAL]: file error <No such file or directory> [RomanMasters/AdobeVFPrototype.otf]
rm: cannot remove '*/.tb_*': No such file or directory
Done

f:id:none53:20180703091323p:plain


コルタナの検索にPATHを入れると、システム環境変数の編集がでてくるので、
それでPATHが調べられる。
gitのbashは以下の位置を追加している。

C:\Program Files\Git\mingw64\bin
C:\Program Files\Git\usr\bin

bashだと、ttxをttx.cmdと打たないと、実行しないようだ。

$ ./buildFont.sh
Building local otf's for master font paths...
Built OTF font for RomanMasters\master_0/master.ufo
Built OTF font for RomanMasters\master_1/master.ufo
Built OTF font for RomanMasters\master_2/master.ufo
Built OTF font for RomanMasters\master_3/master.ufo
Built OTF font for RomanMasters\master_0/master.ufo
Built OTF font for RomanMasters\master_4/master.ufo
Traceback (most recent call last):
  File "C:\FDK\Tools\SharedData\FDKScripts\buildCFF2VF.py", line 756, in <module>
    run()
  File "C:\FDK\Tools\SharedData\FDKScripts\buildCFF2VF.py", line 744, in run
    print(__usage_)
NameError: global name '__usage_' is not defined
Subroutinizing RomanMasters/AdobeVFPrototype.otf
sfntedit [FATAL]: file error <No such file or directory> [RomanMasters/AdobeVFPrototype.otf]
./buildFont.sh: line 20: fontmake.cmd: command not found <=======================================エラー
Compiling "GSUB_patch.ttx" to "RomanMasters/AdobeVFPrototype.ttf"...
ERROR: Unhandled exception has occurred
Traceback (most recent call last):
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\ttx.py", line 384, in main
    process(jobs, options)
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\ttx.py", line 358, in process
    action(input, output, options)
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\misc\loggingTools.py", line 372, in wrapper
    return func(*args, **kwds)
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\ttx.py", line 271, in ttCompile
    allowVID=options.allowVID)
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\ttLib\__init__.py", line 166, in __init__
    file = open(file, "rb")
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\misc\py23.py", line 249, in open
    file, mode, buffering, encoding, errors, newline, closefd)
IOError: [Errno 2] No such file or directory: 'RomanMasters/AdobeVFPrototype.ttf'

fontmakeには、pythonが必要なので、anacondaのpythonをインストールする。

コマンドは、動くようになった。

#!/usr/bin/env sh

folder=RomanMasters
font=AdobeVFPrototype

# build the OTF version -- this requires the AFDKO toolkit
# which is available at https://github.com/adobe-type-tools/afdko
buildmasterotfs.cmd $folder/$font.designspace
buildcff2vf.cmd $folder/$font.designspace

# extract and subroutinize the CFF2 table
echo 'Subroutinizing' $folder/$font.otf
tx.cmd -cff2 +S +b -std $folder/$font.otf $folder/.tb_cff2 2> /dev/null

# replace CFF2 table with subroutinized version
sfntedit -a CFF2=$folder/.tb_cff2 $folder/$font.otf 1> /dev/null

# build the TTF version -- this requires a customized version of fontmake
# which is available at https://github.com/adobe-type-tools/fontmake
fontmake -m $folder/$font.designspace -o variable --production-names

# patch GSUB table, to add <FeatureVariations>
# this enables the transitional glyphs dollar and cent
ttx.cmd -o $folder/$font.ttf -m $folder/$font.ttf GSUB_patch.ttx

# use DSIG, name, OS/2, hhea, post, and STAT tables from OTF
sfntedit -x DSIG=$folder/.tb_DSIG,name=$folder/.tb_name,OS/2=$folder/.tb_os2,hhea=$folder/.tb_hhea,post=$folder/.tb_post,STAT=$folder/.tb_STAT $folder/$font.otf 1> /dev/null
sfntedit -a DSIG=$folder/.tb_DSIG,name=$folder/.tb_name,OS/2=$folder/.tb_os2,hhea=$folder/.tb_hhea,post=$folder/.tb_post,STAT=$folder/.tb_STAT $folder/$font.ttf 1> /dev/null

# use cmap, GDEF, GPOS, and GSUB tables from TTF
sfntedit -x cmap=$folder/.tb_cmap,GDEF=$folder/.tb_GDEF,GPOS=$folder/.tb_GPOS,GSUB=$folder/.tb_GSUB $folder/$font.ttf 1> /dev/null
sfntedit -a cmap=$folder/.tb_cmap,GDEF=$folder/.tb_GDEF,GPOS=$folder/.tb_GPOS,GSUB=$folder/.tb_GSUB $folder/$font.otf 1> /dev/null

# delete temporary files
rm */.tb_*

echo "Done"

結局、うまくビルドできなかった。

m_fujii@None53-Surface MINGW64 ~/Documents/GitHub/adobe-variable-font-prototype (master)
$ ./buildFont.sh
Building local otf's for master font paths...
Built OTF font for RomanMasters\master_0/master.ufo
Built OTF font for RomanMasters\master_1/master.ufo
Built OTF font for RomanMasters\master_2/master.ufo
Built OTF font for RomanMasters\master_3/master.ufo
Built OTF font for RomanMasters\master_0/master.ufo
Built OTF font for RomanMasters\master_4/master.ufo
Traceback (most recent call last):
  File "C:\FDK\Tools\SharedData\FDKScripts\buildCFF2VF.py", line 756, in <module>
    run()
  File "C:\FDK\Tools\SharedData\FDKScripts\buildCFF2VF.py", line 744, in run
    print(__usage_)
NameError: global name '__usage_' is not defined
Subroutinizing RomanMasters/AdobeVFPrototype.otf
sfntedit [FATAL]: file error <No such file or directory> [RomanMasters/AdobeVFPrototype.otf]
INFO:fontmake.font_project:Building interpolation-compatible TTFs
INFO:ufo2ft:Pre-processing glyphs
INFO:cu2qu.ufo:New spline lengths: 1: 18, 2: 930, 3: 527, 4: 100, 5: 1
INFO:ufo2ft.filters:Running DecomposeComponentsFilter on AdobeVFPrototype-Master0
INFO:ufo2ft.filters:Running DecomposeComponentsFilter on AdobeVFPrototype-Default
INFO:ufo2ft.filters:Running DecomposeComponentsFilter on AdobeVFPrototype-Master2
INFO:ufo2ft.filters:Running DecomposeComponentsFilter on AdobeVFPrototype-Master3
INFO:ufo2ft.filters:Running DecomposeComponentsFilter on AdobeVFPrototype-Master0
INFO:ufo2ft.filters:Running DecomposeComponentsFilter on AdobeVFPrototype-Master4
INFO:ufo2ft:Building OpenType tables for AdobeVFPrototype-Master0
WARNING:ufo2ft.featureCompiler:Please change the file name in the include(...); statement to be relative to the UFO itself, instead of relative to t                             he 'features.fea' file contained in it.
Traceback (most recent call last):
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontTools\feaLib\lexer.py", line 230, in __next__
    self.lexers_.append(self.make_lexer_(path))
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontTools\feaLib\lexer.py", line 247, in make_lexer_
    fileobj = open(filename, "r", encoding="utf-8")
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontTools\misc\py23.py", line 250, in open
    file, mode, buffering, encoding, errors, newline, closefd)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\m_fujii\\Documents\\GitHub\\adobe-variable-font-prototype\\RomanMasters\\master_                             0\\../../../features.fea'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\m_fujii\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\m_fujii\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\m_fujii\Anaconda3\Scripts\fontmake.exe\__main__.py", line 9, in <module>
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontmake\__main__.py", line 256, in main
    project.run_from_designspace(designspace_path, **args)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontmake\font_project.py", line 623, in run_from_designspace
    **kwargs)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontmake\font_project.py", line 680, in run_from_ufos
    ufos, output_dir=master_bin_dir, **kwargs)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontmake\font_project.py", line 240, in build_interpolatable_ttfs
    self.save_otfs(ufos, ttf=True, interpolatable=True, **kwargs)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontTools\misc\loggingTools.py", line 372, in wrapper
    return func(*args, **kwds)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontmake\font_project.py", line 395, in save_otfs
    for font, ufo in zip(fonts, ufos):
  File "c:\users\m_fujii\anaconda3\lib\site-packages\ufo2ft\__init__.py", line 194, in compileInterpolatableTTFs
    featureCompilerClass=featureCompilerClass,
  File "c:\users\m_fujii\anaconda3\lib\site-packages\ufo2ft\__init__.py", line 230, in compileFeatures
    return featureCompiler.compile()
  File "c:\users\m_fujii\anaconda3\lib\site-packages\ufo2ft\featureCompiler.py", line 125, in compile
    self.setupFeatures()
  File "c:\users\m_fujii\anaconda3\lib\site-packages\ufo2ft\featureCompiler.py", line 222, in setupFeatures
    featureFile = parseLayoutFeatures(self.ufo)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\ufo2ft\featureCompiler.py", line 47, in parseLayoutFeatures
    parser = Parser(buf, glyphNames)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontTools\feaLib\parser.py", line 50, in __init__
    self.advance_lexer_(comments=True)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontTools\feaLib\parser.py", line 1608, in advance_lexer_
    self.next_token_location_) = next(self.lexer_)
  File "c:\users\m_fujii\anaconda3\lib\site-packages\fontTools\feaLib\lexer.py", line 235, in __next__
    raise IncludedFeaNotFound(fname_token, fname_location)
fontTools.feaLib.error.IncludedFeaNotFound: C:\Users\m_fujii\Documents\GitHub\adobe-variable-font-prototype\RomanMasters\master_0\master.ufo:1:9: ..                             /../../features.fea
Compiling "GSUB_patch.ttx" to "RomanMasters/AdobeVFPrototype.ttf"...
ERROR: Unhandled exception has occurred
Traceback (most recent call last):
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\ttx.py", line 384, in main
    process(jobs, options)
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\ttx.py", line 358, in process
    action(input, output, options)
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\misc\loggingTools.py", line 372, in wrapper
    return func(*args, **kwds)
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\ttx.py", line 271, in ttCompile
    allowVID=options.allowVID)
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\ttLib\__init__.py", line 166, in __init__
    file = open(file, "rb")
  File "C:\FDK\Tools\win\Python\AFDKOPython27\lib\site-packages\fonttools-3.9.1-py2.7.egg\fontTools\misc\py23.py", line 249, in open
    file, mode, buffering, encoding, errors, newline, closefd)
IOError: [Errno 2] No such file or directory: 'RomanMasters/AdobeVFPrototype.ttf'