GithubHelp home page GithubHelp logo

subfont's Introduction

subfont

generate subsetted woff/woff2 font.

requirements

  • python 3.6 or newer with pip

preparation

  1. git clone https://github.com/minacle/subfont.git
  2. cd subfont
  3. pip3.6 install -r requirements.txt
  4. python3.6 subfont.py --help

usage

usage: subfont.py [-F FILE...] [-T TAG...] [-I ID...] [-C CLASS...]
                  [-A ATTRIBUTE...] [-e EXTENSION...] [-i TEXT]
                  [-o DESTINATION] [-w] [-W] [-v] [-h]
                  -f FONT... -- FILE...

required arguments:
   -f FONT...        --fonts FONT...
      set font(s) to make subsetted
   FILE...
      file(s) to get used characters

ignoring arguments:
   -F FILE...        --ignore-files FILE...
      set file(s) to be ignored
   -T TAG...         --ignore-tags TAG...
      set tag(s) to be ignored
   -I ID...          --ignore-ids ID...
      set id(s) to be ignored
   -C CLASS...       --ignore-classes CLASS...
      set class(es) to be ignored
   -A ATTRIBUTE...   --ignore-attributes ATTRIBUTE...
      set attribute(s) to be ignored

optional arguments:
   -e EXTENSION...   --extensions EXTENSION...
      set extension(s) of file(s) to get used characters
   -i TEXT           --include-characters TEXT
      include characters in text
   -o DESTINATION    --output-directory DESTINATION
      set output directory
   -w                --woff
      output as woff (optionally required 'zopfli' module)
   -W                --woff2
      output as woff2 (required 'brotli' module)
   -v                --verbose
      print a lot of logs to reassure you
   -h                --help
      print help message and exit

example

python3.6 subfont.py -f font.otf -- index.html

subfont's People

Contributors

minacle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

subfont's Issues

subfont.py: error: the following arguments are required: FILE

Is it possible to make this argument optional?
It would be nice to use all characters if FILE is not provided.

Another improvement could be to support also chars instead of argument:
python subfont.py -f MyFont.ttf -- "abcdefghijklmnopqrstuvwxyz0123456789"

Crashed with fontTools.ttLib.TTLibError: specify a font number between 0 and 27 (inclusive)

Trying to use the script against a SVG(intentionally), it crashes with this error:

python3.6 subfont.py -f ~/.local/share/fonts/Adobe\ -\ Source\ Han\ Serif\ 思源宋體\ -\ 開放來源碼的泛\ CJK\ 字體/SourceHanSerif.ttc --output-directory . -- ~/工作空間/社群/台灣在地化社群/臺灣在地化社群的標誌/來源碼/l10n-tw-logo.svg                                                                                  
found 0 characters.                                                                                                                                          
Traceback (most recent call last):                                                                                                                           
  File "/usr/local/bin/pyftsubset", line 11, in <module>                                                                                                     
    sys.exit(main())                                                                                                                                         
  File "/usr/local/lib/python3.6/dist-packages/fontTools/misc/loggingTools.py", line 372, in wrapper                                                         
    return func(*args, **kwds)                                                                                                                               
  File "/usr/local/lib/python3.6/dist-packages/fontTools/subset/__init__.py", line 2954, in main                                                             
    font = load_font(fontfile, options, dontLoadGlyphNames=dontLoadGlyphNames)                                                                               
  File "/usr/local/lib/python3.6/dist-packages/fontTools/misc/loggingTools.py", line 372, in wrapper                                                         
    return func(*args, **kwds)                                                                                                                               
  File "/usr/local/lib/python3.6/dist-packages/fontTools/subset/__init__.py", line 2801, in load_font                                                        
    lazy=lazy)                                                                                                                                               
  File "/usr/local/lib/python3.6/dist-packages/fontTools/ttLib/__init__.py", line 180, in __init__
    self.reader = sfnt.SFNTReader(file, checkChecksums, fontNumber=fontNumber)
  File "/usr/local/lib/python3.6/dist-packages/fontTools/ttLib/sfnt.py", line 62, in __init__
    raise ttLib.TTLibError("specify a font number between 0 and %d (inclusive)" % (self.numFonts - 1))
fontTools.ttLib.TTLibError: specify a font number between 0 and 27 (inclusive)
generation failed ~/.local/share/fonts/Adobe - Source Han Serif 思源宋體 - 開放來源碼的泛 CJK 字體/SourceHanSerif.ttc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.