Closed
Conversation
taj-p
commented
Mar 31, 2025
Owner
Author
|
Closed in favour of linebender#883 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Adds an API to
vello_cpuandvello_hybridfor drawing text:Background
This API does not perform text shaping and layout. Those functions should be performed by other libraries like Parley or Cosmic Text. The API proposed here merely takes glyph positions and rendering attributes and renders them to screen.
Comparison with Vello
The API should feel familiar to Vello's implementation with one change:
Scene. In other words, the scene's transform applying to every primitive except text seems unexpected and confusing. If text deserves special attention, I'm keen to understand that choice and this PR is certainly flexible to change. (This is my current understanding).Design
To support both CPU and Hybrid variants of the renderer, we expose a
GlyphRunBuilderfromvello_commonthat accepts aGlyphRenderertrait. The builder encapsulates the logic to "prepare" some glyph for rendering by theGlyphRenderer. I've implementedGlyphRendererfor both our CPU and Hybrid variants as shown below.vello/sparse_strips/vello_cpu/src/render.rs
Lines 185 to 209 in 6a6d158
vello/sparse_strips/vello_hybrid/src/scene.rs
Lines 270 to 294 in 6a6d158
Next Steps
This PR only supports outlined glyphs. We need to support Emoji through bitmap and colr variants. I'd prefer to do that in separate PRs and keep this PR focused on the API and overall strategy.
Notes
I haven't implemented caching of glyphs nor hinting instances. As per discussions, we wanted to keep the text API free from caching for now.