Import a sequence of .svg files into FontForge as glyphs and output a font file

前端 未结 1 1514
清酒与你
清酒与你 2020-12-09 12:33

I want to create a font with a large volume of glyphs. Think Japanese kanji, in the thousands. So there will definitely be some scripting / batch processing required. Luckil

相关标签:
1条回答
  • 2020-12-09 13:26

    Try to rebuild your Fonforge. Because the code should work. I tested it and it runs fine.

    I successfully installed Fontforge with Python extension with Homebrew. This is the info:

    allcaps$ brew info fontforge
    fontforge: stable 20120731, HEAD
    http://fontforge.org/
    /usr/local/Cellar/fontforge/20120731 (377 files, 16M) *
      Built from source with: --with-x
    From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/fontforge.rb
    ==> Dependencies
    Required: gettext ✘, fontconfig ✔
    Recommended: jpeg ✔, libtiff ✔
    Optional: cairo ✔, pango ✘, libspiro ✘, czmq ✘
    ==> Options
    --with-cairo
      Build with cairo support
    --with-czmq
      Build with czmq support
    --with-gif
      Build with GIF support
    --with-libspiro
      Build with libspiro support
    --with-pango
      Build with pango support
    --with-x
      Build with X11 support, including FontForge.app
    --without-jpeg
      Build without jpeg support
    --without-libpng
      Build without libpng support
    --without-libtiff
      Build without libtiff support
    --without-python
      Build without python support
    --HEAD
      install HEAD version
    ==> Caveats
    Set PYTHONPATH if you need Python to find the installed site-packages:
      export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
    
    .app bundles were installed.
    Run `brew linkapps` to symlink these to /Applications.
    

    Set PYTHONPATH
    Run brew install fontforge of course with all flags you need.
    Run brew linkapps

    UPDATE

    Start with a empty font so the font isn't the problem:

    import fontforge
    font = fontforge.font() # create a new font
    

    To include a glyphlist (shouldn't be necessary) Download: http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt and then:

    import fontforge
    fontforge.loadNamelist('glyphlist.txt') # load a name list
    ...
    

    Create the glyph by code point. createChar(uni[,name]) 'A' is 65 so

    char = font.createChar(65)
    

    Glyphs and their code points:

    >>> for c in u'ABC 賢治':  print ord(c). 
    >>> 65, 66, 67, 32, 36066, 27835. 
    

    The Unicode Consortium defines the Unicode standard. The 'CJK Unified Ideographs' live in 'Basic Multilingual Plane (BMP)'.

    Glyphs without a unicode point can be referenced within a font by name. And are useful for open type features or building blocks to compose new glyphs. You can create them like this:

    font.createChar(-1, 'some_name')
    

    UPDATE 2

    You should name all glyphs that occur in the Adobe Glyph List by their AGL glyph name. The rest of the glyphs should be named uniXXXX where XXXX is the Unicode index. During development you can use any human readable name. So use your own naming and replace it when you generate the font for shipping. See Typophile.

    0 讨论(0)
提交回复
热议问题