How to get text to screen: text rendering
background
What’s involved in getting some text to the glass? See the following links for some good info:
- SIGGRAPH 2018 - Digital typography
- Modern text rendering with Linux: Overview | Home
- Text layout is a loose hierarchy of segmentation | Raph Levien’s blog
- Minikin retrospective | Raph Levien’s blog
- Font fallback deep dive | Raph Levien’s blog
- Rust GUI Infrastructure
- Text Editing Hates You Too – Lord.io
- State of Text Rendering 2024
- Text Rendering Hates You (2019) | Hacker News
comparison
| library | language | reading | shaping | rendering | itemization | bidi | line breaking | cursors1 |
|---|---|---|---|---|---|---|---|---|
freetype |
C | yes | no | cpu | no | no | no | no |
harfbuzz |
C/C++ | no | yes | no | no | no | no | no |
glyphy |
C++ | no | no | gpu | no | no | no | no |
fribidi |
C | no | no | no | no | yes | no | no |
pango |
C | freetype | harfbuzz | cairo/xft/glyphy | fontconfig | fribidi | yes | yes |
libraqm |
C | freetype | harfbuzz | no | no | fribidi/sheenbidi | no | no |
ttf-parser |
rust | yes | no | no | no | no | no | no |
rusttype2 |
rust | ttf-parser | no | gpu | no | no | no | no |
ab_glyph |
rust | ttf-parser | ||||||
ab_glyph_rasterizer |
rust | |||||||
glyph_brush |
rust | |||||||
gfx_glyph |
rust | |||||||
glyph_brush_layout |
rust | |||||||
glyph_brush_draw_cache |
rust | |||||||
fontdue |
rust | ttf-parser | no | cpu | no | no | yes | yes |
rustybuzz |
rust | ttf-parser | yes | no | no | no | no | no |
swash |
rust | yes | yes | cpu via zeno | no | no | no | no |
allsorts |
rust | yes | yes | no | no | no | no | no |
fount |
rust | no | no | no | yes | no | no | no |
parley |
rust | swash | swash | no | fount | yes | limited | yes |
kas-text |
rust | ttf-parser | rustybuzz | abglyph/fontdue | fontdb | unicode-bidi | limited | no |
cosmic-text |
rust | ttf-parser | rustybuzz | swash | fontdb | unicode-bidi | unicode-linebreak | yes |
fontdb |
rust | ttf-parser | no | no | yes3 | no | no | no |
unicode-linebreak |
rust | no | no | no | no | no | yes | no |
unicode-bidi |
rust | no | no | no | no | yes | no | no |
font-kit |
rust/platform | platform | no | platform | yes | no | no | no |
skribo |
rust | font-kit | harfbuzz | font-kit | font-kit | no | no | no |
piet |
rust/platform | platform | platform | platform | platform | platform | platform | yes4 |
pathfinder |
rust | font-kit | no | gpu | font-kit | no | no | no |
femtovg |
rust | ttf-parser | rustybuzz | gpu | no | unicode-bidi | no5 | no |
glyphon |
some notes:
- Currently xilem is using piet-gpu and parley via the piet-text trait that it implemets
- However, while parley implements the piet-text trait, it has actually been removed from piet-gpu
- This issue and this issue give some ideas for where the xilem/druid ecosystem might be headed with respect to text
- cosmic-text and parley are the two “contenders” for something equivalent to pango that tries to handle everything about text
- Currently cosmic-text has better documented API with examples, including an edit trait that makes implementing custom text handling widgets easy.
- Both use swash, but differ in font fallback and line breaking/bidi/cursor handling
- https://github.com/dfrg/swash_demo for an example of how to do rendering from gpu cache
- also https://github.com/neovide/neovide uses swash on gpu
- https://github.com/linebender/skribo/issues/34
- https://github.com/RazrFalcon/tiny-skia/issues/1
- https://www.reddit.com/r/rust/comments/n42r54/swash_font_crate_now_with_docs_and_a_demo/
- https://www.reddit.com/r/rust/comments/zce386/vector_graphics_done_entirely_in_compute_shaders
bidi stuff
- [unic-bidi] API concerns · Issue #273 · open-i18n/rust-unic · GitHub
- language - Designing bidi text editing - User Experience Stack Exchange
- Line wrapping - KAS blog
- Is unic-bidi a suitable dependency for BiDi? · Issue #20 · kas-gui/kas-text · GitHub
- Text shaping and font fallback · Issue #33 · iced-rs/iced · GitHub