- How to install
- Usage of an example CLI
otfedcli
- Development status
- How to develop this library
- Remarks
Under the condition that opam
(a package manager for OCaml, Coq, etc.) is installed, invoke the following commands:
$ cd <your-workspace>
$ git clone https://github.com/gfngfn/otfed
$ cd otfed
$ opam pin add otfed .
Probably the last command above will ask you whether to install otfed
. Then answer y
.
If not, invoking the following command will do:
$ opam install otfed
$ dune exec otfedcli <path/to/font-file> <command> ... <command>
<command> ::=
| tables # Prints all the tags of tables contained in the font.
| cmap # Prints all the Unicode-aware `cmap` subtables.
| cmap_word "<arbitrary-utf8-text>" # Consults `cmap` subtables for each character in the given text.
| head # Prints the contents of `head` table.
| hhea # Prints the contents of `hhea` table.
| vhea # Prints the contents of `vhea` table.
| maxp # Prints the contents of `maxp` table.
| hmtx <glyph-id> # Consults the `hmtx` table by the glyph of ID <glyph-id>.
| vmtx <glyph-id> # Consults the `vmtx` table by the glyph of ID <glyph-id>.
| glyf <glyph-id> <output-svg-file> # Outputs the glyph of ID <glyph-id> that has TrueType outlines.
| cff <glyph-id> <output-svg-file> # Outputs the glyph of ID <glyph-id> that has CFF outlines.
| cff_lex <glyph-id> # Prints the tokenized CharString of the glyph of ID <glyph-id>.
| cff_top # Prints the Top DICT in the `CFF␣` table.
| charset <glyph-id> # Prints the name of the glyph by consulting the charset in `CFF␣`.
| gsub <script> <langsys> <feature> # Prints the contents of `GSUB` subtables.
| gpos <script> <langsys> <feature> # Prints the contents of `GPOS` subtables.
| subset <glyph-ids> <output-ttf> # Makes a subset font by using given glyph IDs.
<glyph-ids> ::= (comma-separated glyph IDs where no space is allowed around commas)
Consults cmap
subtables by Unicode code points:
$ dune exec otfedcli input/ipaexm.ttf cmap_word "田中太郎"
* subtable (platform: 0, encoding: 3)
- U+7530 --> 2900
- U+4E2D --> 2746
- U+592A --> 2614
- U+90CE --> 3830
* subtable (platform: 3, encoding: 1)
- U+7530 --> 2900
- U+4E2D --> 2746
- U+592A --> 2614
- U+90CE --> 3830
* subtable (platform: 3, encoding: 10)
- U+7530 --> 2900
- U+4E2D --> 2746
- U+592A --> 2614
- U+90CE --> 3830
Prints all of the Unicode-aware cmap
subtables in IPAex Mincho (please be careful of large outputs on stdout):
$ dune exec otfedcli input/ipaexm.ttf cmap
(omitted)
Outputs the glyph of ID 1000 in IPAex Mincho as an SVG file:
$ dune exec otfedcli input/ipaexm.ttf glyf 1000 output/ipaexm1000.svg
(omitted)
Outputs the glyph of ID 50 in Computer Modern Typewriter Italic as an SVG file:
$ dune exec otfedcli input/cmunit.otf cff 50 output/cmunit1000.svg
(omitted)
Outputs the subset of Junicode which contains .notdef
, “Q”, and “f” only:
$ dune exec otfedcli input/Junicode.ttf subset 0,113,302 output/Junicode-subset.ttf
- Support:
- V = supported
- - = not supported yet
- Test:
- V = having automated tests
- - = not supported
- o = no automated test has been given, but seems to be working fine for many inputs
- x = not well-tested
Tables | Encoding operations | Decoding operations | ||||
---|---|---|---|---|---|---|
Supported | Tested | Supported | Tested | |||
Required | cmap | Format 0 | - | - | - | - |
Format 2 | - | - | - | - | ||
Format 4 | - | - | V | V | ||
Format 6 | - | - | - | - | ||
Format 8 | - | - | - | - | ||
Format 10 | - | - | - | - | ||
Format 12 | V | V | V | V | ||
Format 13 | - | - | V | V | ||
Format 14 | V | V | V | V | ||
head | V | V | V | V | ||
hhea | V | V | V | V | ||
hmtx | V | V | V | V | ||
maxp | V | V | V | V | ||
name | V | V | V | V | ||
OS/2 | ver. 0 | V | o | V | o | |
ver. 1 | V | o | V | o | ||
ver. 2 | V | V | V | V | ||
ver. 3, 4, & 5 | V | o | V | o | ||
post | V | V | V | V | ||
TTF | cvt␣ | - | - | - | - | |
fpgm | - | - | - | - | ||
glyf | V | V | V | V | ||
loca | short | V | V | V | o | |
long | V | o | V | V | ||
prep | - | - | - | - | ||
gasp | - | - | - | - | ||
CFF | CFF␣ | V | o | V | V | |
CFF2 | - | - | - | - | ||
VORG | - | - | - | - | ||
SVG | SVG␣ | - | - | - | - | |
Optional | DSIG | - | - | - | - | |
kern | Format 0 | - | - | V | V | |
other | - | - | - | - | ||
vhea | ver. 1.0 | V | V | V | V | |
ver. 1.1 | V | x | V | x | ||
vmtx | V | V | V | V | ||
Advanced | BASE | - | - | - | - | |
GDEF | - | - | - | - | ||
GPOS | LookupType 1 | - | - | V | o | |
LookupType 2 | - | - | V | o | ||
LookupType 3 | - | - | V | x | ||
LookupType 4 | - | - | V | o | ||
LookupType 5 | - | - | V | o | ||
LookupType 6 | - | - | V | o | ||
LookupType 7 | - | - | - | - | ||
LookupType 8 | - | - | - | - | ||
LookupType 9 | - | - | V | o | ||
GSUB | LookupType 1 | - | - | V | o | |
LookupType 2 | - | - | V | o | ||
LookupType 3 | - | - | - | - | ||
LookupType 4 | - | - | V | o | ||
LookupType 5 | - | - | - | - | ||
LookupType 6 | - | - | - | - | ||
LookupType 7 | - | - | - | - | ||
LookupType 8 | - | - | - | - | ||
JSTF | - | - | - | - | ||
MATH | - | - | V | V |
Assumes that Dune (≥2.7) is installed.
$ dune build
$ dune test
This library has been developed with the intension of reformulating otfm
.
See also:
Some unit tests use data extracted from the following fonts:
- IPAex明朝 (IPAex Mincho):
ipaexm.ttf
- See the license here
- Latin Modern:
lmroman10-regular.otf
andlmmono10-regular.otf
- See the license here
- Latin Modern Math
- See the license here
- Junicode
- See the license here
- DejaVu Sans:
DejaVuSans-ExtraLight.ttf
- See the license here