1# RustType
2[![crates.io](https://img.shields.io/crates/v/rusttype.svg)](https://crates.io/crates/rusttype)
3[![docs.rs](https://docs.rs/rusttype/badge.svg)](https://docs.rs/rusttype)
4
5RustType is a pure Rust alternative to libraries like FreeType.
6
7The current capabilities of RustType:
8
9* Reading TrueType formatted fonts and font collections. This includes `*.ttf`
10  as well as a subset of `*.otf` font files.
11* Retrieving glyph shapes and commonly used properties for a font and its glyphs.
12* Laying out glyphs horizontally using horizontal and vertical metrics, and
13  glyph-pair-specific kerning.
14* Rasterising glyphs with sub-pixel positioning using an accurate analytical
15  algorithm (not based on sampling).
16* Managing a font cache on the GPU with the `gpu_cache` module. This keeps
17  recently used glyph renderings
18  in a dynamic cache in GPU memory to minimise texture uploads per-frame. It
19  also allows you keep the draw call count for text very low, as all glyphs are
20  kept in one GPU texture.
21
22Notable things that RustType does not support *yet*:
23
24* OpenType formatted fonts that are not just TrueType fonts (OpenType is a
25  superset of TrueType). Notably there is no support yet for cubic Bezier curves
26  used in glyphs.
27* Font hinting.
28* Ligatures of any kind
29* Some less common TrueType sub-formats.
30* Right-to-left and vertical text layout.
31
32## Getting Started
33
34To hit the ground running with RustType, look at the `simple.rs` example
35supplied with the crate. It demonstrates loading a font file, rasterising an
36arbitrary string, and displaying the result as ASCII art. If you prefer to just
37look at the documentation, the entry point for loading fonts is
38`FontCollection`, from which you can access individual fonts, then their glyphs.
39
40## Future Plans
41
42The initial motivation for the project was to provide easy-to-use font rendering for games.
43There are numerous avenues for improving RustType. Ideas:
44
45* Some form of hinting for improved legibility at small font sizes.
46* Replacing the dependency on
47  [stb_truetype-rs](https://gitlab.redox-os.org/redox-os/stb_truetype-rs)
48  (a translation of [stb_truetype.h](https://github.com/nothings/stb/blob/master/stb_truetype.h)),
49  with OpenType font loading written in idiomatic Rust.
50* Add support for cubic curves in OpenType fonts.
51* Extract the rasterisation code into a separate vector graphics rendering crate.
52* Support for some common forms of ligatures.
53* And, eventually, support for embedded right-to-left Unicode text.
54
55If you think you could help with achieving any of these goals, feel free to open
56a tracking issue for discussing them.
57
58## License
59
60Licensed under either of
61
62 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
63   http://www.apache.org/licenses/LICENSE-2.0)
64 * MIT license ([LICENSE-MIT](LICENSE-MIT) or
65   http://opensource.org/licenses/MIT)
66
67at your option.
68
69### Contribution
70
71Unless you explicitly state otherwise, any contribution intentionally submitted
72for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
73dual licensed as above, without any additional terms or conditions.
74
75### See Also
76
77- [glyph_brush](https://github.com/alexheretic/glyph-brush) - can cache vertex generation & provides more complex layouts.
78