Crate fonterator [−] [src]
Fonterator is a pure Rust alternative to libraries like FreeType based on RustType.
Getting Started
Add the following to your Cargo.toml:
[dependencies]
fonterator = "0.1.0"
To hit the ground running with Fonterator, look at the image.rs
example
supplied with the crate. It demonstrates loading a font file, rasterising an
arbitrary string, and saving as an SVG. If you prefer to
just look at the documentation, the entry point for loading fonts is
FontCollection
, from which you can access individual fonts, then their
glyphs.
Unicode terminology
This crate uses terminology for computerised typography as specified by the Unicode standard. If you are not sure of the differences between a code point, a character, and a glyph, you may want to check the official Unicode glossary, or alternatively, here's my take on it from a practical perspective:
- A character is what you would conventionally call a single symbol,
independent of its appearance or representation in a particular font.
Examples include
a
,A
,ä
,å
,1
,*
,Ω
, etc. - A Unicode code point is the particular number that the Unicode standard
associates with a particular character. Note however that code points also
exist for things not conventionally thought of as characters by
themselves, but can be combined to form characters, such as diacritics
like accents. These "characters" are known in Unicode as "combining
characters". E.g., a diaeresis (
¨
) has the code point U+0308. If this code point follows the code point U+0055 (the letteru
), this sequence represents the characterü
. Note that there is also a single codepoint forü
, U+00FC. This means that what visually looks like the same string can have multiple different Unicode representations. Some fonts will have glyphs (see below) for one sequence of codepoints, but not another that has the same meaning. To deal with this problem it is recommended to use Unicode normalisation, as provided by, for example, the unicode-normalization crate, to convert to code point sequences that work with the font in question. Typically a font is more likely to support a single code point vs. a sequence with the same meaning, so the best normalisation to use is "canonical recomposition", known as NFC in the normalisation crate. - A glyph is a particular font's shape to draw the character for a particular Unicode code point. This will have its own identifying number unique to the font, its ID.
Structs
Font |
A single font. This may or may not own the font data. |
FontCollection |
A collection of fonts read straight from a font file's data. The data in the collection is not validated. This structure may or may not own the font data. |
Glyph |
A single glyph of a font. this is a thin wrapper referring to the font, glyph id and scaling information. |
GlyphIterator |
An iterator over glyphs in a string. |
Path |
An iterator over |
Enums
Error |
The type for errors returned by Fonterator. |
PathOp |
An operation that builds a path. |
SharedBytes |
|