Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Mirror ofhttps://gitlab.redox-os.org/redox-os/rusttype

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

redox-os/rusttype

Repository files navigation

crates.iodocs.rs

RustType is a pure Rust alternative to libraries like FreeType.

The current capabilities of RustType:

  • Reading OpenType formatted fonts and font collections. This includes*.ttfas well as*.otf font files.
  • Retrieving glyph shapes and commonly used properties for a font and its glyphs.
  • Laying out glyphs horizontally using horizontal and vertical metrics, andglyph-pair-specific kerning.
  • Rasterising glyphs with sub-pixel positioning using an accurate analyticalalgorithm (not based on sampling).
  • Managing a font cache on the GPU with thegpu_cache module. This keepsrecently used glyph renderings in a dynamic cache in GPU memory to minimisetexture uploads per-frame. It also allows you keep the draw call count fortext very low, as all glyphs are kept in one GPU texture.

Notable things that RustType does not supportyet:

  • Font hinting.
  • Ligatures of any kind.
  • Some less common TrueType sub-formats.
  • Right-to-left and vertical text layout.

Testing & examples

Heavier examples, tests & benchmarks are in the./dev directory. This avoids dev-dependency feature bleed.

Run all tests withcargo test --all --all-features.

Run examples withcargo run --example <NAME> -p dev

Getting Started

To hit the ground running with RustType, look atdev/examples/ascii.rssupplied with the crate. It demonstrates loading a font file, rasterising anarbitrary string, and displaying the result as ASCII art. If you prefer to justlook at the documentation, the entry point for loading fonts isFont,from which you can access individual fonts, then their glyphs.

Future Plans

The initial motivation for the project was to provide easy-to-use font rendering for games.There are numerous avenues for improving RustType. Ideas:

  • Support for some common forms of ligatures.
  • And, eventually, support for embedded right-to-left Unicode text.

If you think you could help with achieving any of these goals, feel free to opena tracking issue for discussing them.

Minimum supported rust compiler

This crate is maintained withlatest stable rust.

License

Licensed under either of

at your option.

Contribution

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

See Also

  • glyph_brush - can cache vertex generation & provides more complex layouts.

[8]ページ先頭

©2009-2025 Movatter.jp