All Projects → RazrFalcon → Ttf Parser

RazrFalcon / Ttf Parser

Licence: other
A high-level, safe, zero-allocation TrueType font parser.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Ttf Parser

font-v
Font version string reporting and modification library + executable tool
Stars: ✭ 15 (-93.21%)
Mutual labels:  opentype, ttf, otf
Typography
C# Font Reader (TrueType / OpenType / OpenFont / CFF / woff / woff2) , Glyphs Layout and Rendering
Stars: ✭ 246 (+11.31%)
Mutual labels:  opentype, ttf, otf
pixel font
All-in-one tool for creating TrueType outline fonts from bitmap glyph data, purely written in Elixir.
Stars: ✭ 16 (-92.76%)
Mutual labels:  opentype, ttf, otf
Awesome Typography
✏︎ Curated list about digital typography 🔥
Stars: ✭ 947 (+328.51%)
Mutual labels:  opentype, ttf, otf
Source Han Sans
Source Han Sans | 思源黑体 | 思源黑體 | 思源黑體 香港 | 源ノ角ゴシック | 본고딕
Stars: ✭ 10,181 (+4506.79%)
Mutual labels:  opentype, otf
Source Han Code Jp
Source Han Code JP | 源ノ角ゴシック Code
Stars: ✭ 1,362 (+516.29%)
Mutual labels:  opentype, otf
htmlcss
A lightweight HTML and CSS Parser in C
Stars: ✭ 36 (-83.71%)
Mutual labels:  ttf, otf
fontfacegen-webpack-plugin
A plugin for webpack that allows you to convert .ttf and .otf files into various other font formats such as .eot, .ttf, .svg, .woff and .woff2 using the existing NPM package fontfacegen.
Stars: ✭ 20 (-90.95%)
Mutual labels:  ttf, otf
beatrix
A tool to chop off useless fonts glyphs and convert TTF/OTF into WOFF & WOFF2
Stars: ✭ 22 (-90.05%)
Mutual labels:  ttf, otf
Birdfont
A font editor for creating fonts in TTF, EOT, SVG and BIRDFONT format.
Stars: ✭ 272 (+23.08%)
Mutual labels:  ttf, otf
Source Han Serif
Source Han Serif | 思源宋体 | 思源宋體 | 思源宋體 香港 | 源ノ明朝 | 본명조
Stars: ✭ 5,920 (+2578.73%)
Mutual labels:  opentype, otf
chiron-sans-hk
昭源黑體:現代筆形風格,平衡標準字形和印刷體慣用筆形的免費開源黑體字型
Stars: ✭ 131 (-40.72%)
Mutual labels:  opentype, otf
Acy-Font
自制手写字体。A hand-writing font set.
Stars: ✭ 20 (-90.95%)
Mutual labels:  ttf, otf
FontRegister
FontRegister is a small Windows utility to install fonts and/or repair the font registry via commandline.
Stars: ✭ 17 (-92.31%)
Mutual labels:  ttf, otf
Font Spider
Smart webfont compression and format conversion tool
Stars: ✭ 4,550 (+1958.82%)
Mutual labels:  opentype, ttf
Codeface
Typefaces for source code beautification
Stars: ✭ 5,612 (+2439.37%)
Mutual labels:  ttf, otf
Opentype.js
Read and write OpenType fonts using JavaScript.
Stars: ✭ 3,393 (+1435.29%)
Mutual labels:  opentype, otf
Adobe Variable Font Prototype
Variable font example in OpenType-CFF2 & TrueType formats
Stars: ✭ 116 (-47.51%)
Mutual labels:  opentype, otf
Haack
Hæck
Stars: ✭ 142 (-35.75%)
Mutual labels:  ttf, otf
Svgtofont
Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font.
Stars: ✭ 149 (-32.58%)
Mutual labels:  ttf

ttf-parser

Build Status Crates.io Documentation Rust 1.35+

A high-level, safe, zero-allocation TrueType font parser.

Can be used as Rust and as C library.

Features

  • A high-level API, for people who doesn't know how TrueType works internally. Basically, no direct access to font tables.
  • A C API.
  • Zero heap allocations.
  • Zero unsafe.
  • Zero dependencies.
  • no_std/WASM compatible.
  • Fast. See the Performance section.
  • Stateless. No mutable parsing methods.
  • Simple and maintainable code (no magic numbers).

Safety

  • The library must not panic. Any panic considered as a critical bug and should be reported.
  • The library forbids the unsafe code.
  • No heap allocations, so crash due to OOM is not possible.
  • All recursive methods have a depth limit.
  • Technically, should use less than 64KiB of stack in the worst case scenario.
  • Most of arithmetic operations are checked.
  • Most of numeric casts are checked.

Alternatives

It's very hard to compare different libraries, so we are using table-based comparison. There are roughly three types of TrueType tables:

  • A table with a list of properties (like head, OS/2, etc.).
    If a library tries to parse it at all then we mark it as supported.
  • A table that contains a single type of data (glyf, CFF (kinda), hmtx, etc.).
    Can only be supported or not.
  • A table that contains multiple subtables (cmap, kern, GPOS, etc.).
    Can be partially supported and we note which subtables are actually supported.
Feature/Library ttf-parser FreeType stb_truetype
Memory safe
Thread safe ~ (mostly reentrant)
Zero allocation
Variable fonts
Rendering -1 ~ (very primitive)
avar table
bdat table
bloc table
CBDT table
CBLC table
CFF table ~ (no seac support)
CFF2 table
cmap table ~ (no 8) ~ (no 2,8,10,14; Unicode-only)
EBDT table
EBLC table
fvar table
gasp table
GDEF table ~
glyf table ~2 ~2
GPOS table ~ (only 2)
GSUB table
gvar table
head table
hhea table
hmtx table
HVAR table
kern table ~ (no AAT 1) ~ (only 0) ~ (only 0)
maxp table
MVAR table
name table
OS/2 table
post table
sbix table ~ (PNG only) ~ (PNG only)
SVG table
vhea table
vmtx table
VORG table
VVAR table
Language Rust + C API C C
Tested version 0.12.0 2.10.4 1.24
License MIT / Apache-2.0 FTL / GPLv2 public domain

Legend:

  • ✓ - supported
  • ~ - partial
  • nothing - not supported

Notes:

  1. While ttf-parser doesn't support rendering by itself, there are mutliple rendering libraries on top of it: rusttype, ab-glyph and fontdue.
  2. Matching points are not supported.

Performance

TrueType fonts designed for fast querying, so most of the methods are very fast. The main exception is glyph outlining. Glyphs can be stored using two different methods: using Glyph Data format and Compact Font Format (pdf). The first one is fairly simple which makes it faster to process. The second one is basically a tiny language with a stack-based VM, which makes it way harder to process.

The benchmark tests how long it takes to outline all glyphs in the font.

Table/Library ttf-parser FreeType stb_truetype
glyf 0.915 ms 1.258 ms 0.718 ms
gvar 3.545 ms 4.288 ms -
CFF 1.365 ms 5.992 ms 2.836 ms
CFF2 1.982 ms 6.859 ms -

Note: FreeType is surprisingly slow, so I'm worried that I've messed something up.

And here are some methods benchmarks:

test outline_glyph_276_from_cff2 ... bench:         867 ns/iter (+/- 15)
test from_data_otf_cff           ... bench:         968 ns/iter (+/- 13)
test from_data_otf_cff2          ... bench:         887 ns/iter (+/- 25)
test outline_glyph_276_from_cff  ... bench:         678 ns/iter (+/- 41)
test outline_glyph_276_from_glyf ... bench:         649 ns/iter (+/- 11)
test outline_glyph_8_from_cff2   ... bench:         534 ns/iter (+/- 14)
test from_data_ttf               ... bench:         467 ns/iter (+/- 11)
test glyph_name_post_276         ... bench:         223 ns/iter (+/- 5)
test outline_glyph_8_from_cff    ... bench:         315 ns/iter (+/- 13)
test outline_glyph_8_from_glyf   ... bench:         291 ns/iter (+/- 5)
test family_name                 ... bench:         183 ns/iter (+/- 102)
test glyph_name_cff_276          ... bench:          62 ns/iter (+/- 1)
test glyph_index_u41             ... bench:          16 ns/iter (+/- 0)
test glyph_name_cff_8            ... bench:           5 ns/iter (+/- 0)
test glyph_name_post_8           ... bench:           2 ns/iter (+/- 0)
test subscript_metrics           ... bench:           2 ns/iter (+/- 0)
test glyph_hor_advance           ... bench:           2 ns/iter (+/- 0)
test glyph_hor_side_bearing      ... bench:           2 ns/iter (+/- 0)
test glyph_name_8                ... bench:           1 ns/iter (+/- 0)
test ascender                    ... bench:           1 ns/iter (+/- 0)
test underline_metrics           ... bench:           1 ns/iter (+/- 0)
test strikeout_metrics           ... bench:           1 ns/iter (+/- 0)
test x_height                    ... bench:           1 ns/iter (+/- 0)
test units_per_em                ... bench:         0.5 ns/iter (+/- 0)
test width                       ... bench:         0.2 ns/iter (+/- 0)

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].