All Projects → mooman219 → Fontdue

mooman219 / Fontdue

Licence: mit
The fastest font renderer in the world, written in pure rust.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Fontdue

Typography
C# Font Reader (TrueType / OpenType / OpenFont / CFF / woff / woff2) , Glyphs Layout and Rendering
Stars: ✭ 246 (-50.7%)
Mutual labels:  font, opentype
xits
XITS - OpenType implementation of STIX fonts with math support
Stars: ✭ 299 (-40.08%)
Mutual labels:  font, opentype
punk-otf
Punk Nova - an OpenType implementation of Donald Knuth's Punk font
Stars: ✭ 37 (-92.59%)
Mutual labels:  font, opentype
Fonttools Opentype Feature Freezer
OTFeatureFreezer GUI app and pyftfeatfreeze commandline tool in Python to permanently "apply" OpenType features to fonts, by remapping their Unicode assignments
Stars: ✭ 130 (-73.95%)
Mutual labels:  font, opentype
bitsnpicas
Bits'N'Picas - Bitmap & Emoji Font Creation & Conversion Tools
Stars: ✭ 171 (-65.73%)
Mutual labels:  font, opentype
Fonts
✒️ Font loading and drawing library.
Stars: ✭ 135 (-72.95%)
Mutual labels:  font, opentype
fdiff
An OpenType table diff tool for fonts. Based on the fontTools TTX format.
Stars: ✭ 33 (-93.39%)
Mutual labels:  font, opentype
Free Font
大概是2020年最全的免费可商用字体,这里收录的商免字体都能找到明确的授权出处,可以放心使用,持续更新中...
Stars: ✭ 1,140 (+128.46%)
Mutual labels:  font, opentype
emojione-color
OpenType-SVG font of EmojiOne 2.3
Stars: ✭ 112 (-77.56%)
Mutual labels:  font, opentype
font-v
Font version string reporting and modification library + executable tool
Stars: ✭ 15 (-96.99%)
Mutual labels:  font, opentype
Adobe Variable Font Prototype
Variable font example in OpenType-CFF2 & TrueType formats
Stars: ✭ 116 (-76.75%)
Mutual labels:  font, opentype
Xits
XITS - OpenType implementation of STIX fonts with math support
Stars: ✭ 257 (-48.5%)
Mutual labels:  font, opentype
Source Han Code Jp
Source Han Code JP | 源ノ角ゴシック Code
Stars: ✭ 1,362 (+172.95%)
Mutual labels:  font, opentype
Source Han Super Otc
Source Han & Noto CJK Mega/Ultra OTCs
Stars: ✭ 153 (-69.34%)
Mutual labels:  font, opentype
Source Han Sans
Source Han Sans | 思源黑体 | 思源黑體 | 思源黑體 香港 | 源ノ角ゴシック | 본고딕
Stars: ✭ 10,181 (+1940.28%)
Mutual labels:  font, opentype
perplexed
OTF monospace typeface, a derivative of IBM Plex Mono with Powerline glyphs added
Stars: ✭ 23 (-95.39%)
Mutual labels:  font, opentype
Source Han Serif
Source Han Serif | 思源宋体 | 思源宋體 | 思源宋體 香港 | 源ノ明朝 | 본명조
Stars: ✭ 5,920 (+1086.37%)
Mutual labels:  font, opentype
Fonthx
Font File Generation in Haxe
Stars: ✭ 64 (-87.17%)
Mutual labels:  font, opentype
chiron-sans-hk
昭源黑體:現代筆形風格,平衡標準字形和印刷體慣用筆形的免費開源黑體字型
Stars: ✭ 131 (-73.75%)
Mutual labels:  font, opentype
rapid-arrows-font
OTF comic font
Stars: ✭ 30 (-93.99%)
Mutual labels:  font, opentype

Fontdue

Test Documentation Crates.io License

Fontdue is a simple, no_std (does not use the standard library for portability), pure Rust, TrueType (.ttf/.ttc) & OpenType (.otf) font rasterizer and layout tool. It strives to make interacting with fonts as fast as possible, and currently has the lowest end to end latency for a font rasterizer.

Roadmap

Current goal (milestone 1): fontdue is designed to be a replacement for rusttype (link), ab_glyph (link), parts of glyph_brush (link), and glyph_brush_layout (link). This is a class of font libraries that don't tackle shaping.

Future goals: Shaping - the complex layout of text such as Arabic and Devanagari - will be added. There are two potential pure Rust libraries (allsorts or rustybuzz) that are candidates for providing a shaping backend to Fontdue, but are relatively immature right now.

A non-goal of this library is to be allocation free and have a fast, "zero cost" initial load. This library does make allocations and depends on the alloc crate. Fonts are fully parsed on creation and relevant information is stored in a more convenient to access format. Unlike other font libraries, the font structures have no lifetime dependencies since it allocates its own space.

Example

Rasterization

The rasterization API is done for milestone 1 and should not see major changes.

// Read the font data.
let font = include_bytes!("../resources/Roboto-Regular.ttf") as &[u8];
// Parse it into the font type.
let font = fontdue::Font::from_bytes(font, fontdue::FontSettings::default()).unwrap();
// Rasterize and get the layout metrics for the letter 'g' at 17px.
let (metrics, bitmap) = font.rasterize('g', 17.0);

Layout

The layout API is immature and may see many more major breaking changes before milestone 1.

// Read the font data.
let font = include_bytes!("../resources/fonts/Roboto-Regular.ttf") as &[u8];
// Parse it into the font type.
let roboto_regular = Font::from_bytes(font, fontdue::FontSettings::default()).unwrap();
// The list of fonts that will be used during layout.
let fonts = &[roboto_regular];
// Create a layout context. Laying out text needs some heap allocations; reusing this context
// reduces the need to reallocate space. We inform layout of which way the Y axis points here.
let mut layout = Layout::new(CoordinateSystem::PositiveYUp);
// By default, layout is initialized with the default layout settings. This call is redundant, but
// demonstrates setting the value with your custom settings.
layout.reset(&LayoutSettings {
    ..LayoutSettings::default()
});
// The text that will be laid out, its size, and the index of the font in the font list to use for
// that section of text.
layout.append(fonts, &TextStyle::new("Hello ", 35.0, 0));
layout.append(fonts, &TextStyle::new("world!", 40.0, 0));
// Prints the layout for "Hello world!"
println!("{:?}", layout.glyphs());

// If you wanted to attached metadata based on the TextStyle to the glyphs returned in the
// glyphs() function, you can use the TextStyle::with_metadata function. In this example, the
// Layout type is now parameterized with u8 (Layout<u8>). All styles need to share the same
// metadata type.
let mut layout = Layout::new(CoordinateSystem::PositiveYUp);
layout.append(fonts, &TextStyle::with_user_data("Hello ", 35.0, 0, 10u8));
layout.append(fonts, &TextStyle::with_user_data("world!", 40.0, 0, 20u8));
println!("{:?}", layout.glyphs());

Performance

Rasterization

These benchmarks measure the time it takes to generate the glyph metrics and bitmap for the text "Sphinx of black quartz, judge my vow." over a range of sizes. The lower the line in the graph the better.

Rasterize benchmarks

Rasterize benchmarks

Layout

This benchmark measures the time it takes to layout latin characters of sample text with wrapping on word boundaries.

Layout benchmarks

Notices

Maintenance

Please bear with me on new features or quirks that you find. I will definitely get to issues you open (also thank you for opening them), but I don't have as much time as I would like to work on fontdue so please be patient, this is a mostly solo project <3.

TrueType & OpenType Table Support

Fontdue depends on ttf-parser (link) for parsing fonts, which supports a wide range of TrueType and OpenType features.

Attribution

Fontdue started as a slightly more production ready wrapper around font-rs (link) because of how fast it made rasterization look, and how simple the wonderful rusttype (link) crate made font parsing look. Since then, I've rewritten fontdue from the ground up, but I feel like it still deservers some attribution.

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].