-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom glyph indices in GlyphKey #35
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is the point of having an arbitrary GlyphId as part of the crossfont crate when all crossfont ever uses it for is the char
?
crossfont needs to get the glyph index from the character specified by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed to shape the text before rasterizing through crossfont, as harfbuzz returns glyph indices instead of just characters.
Sounds like an issue with using harfbuzz to me, not crossfont. Why does this need to be patched in crossfont?
Crossfont has no ability to verify which integer should be associated to which character for rasterization, so it really doesn't make any sense to pass platform-specific "IDs" around. All crossfont does is rasterize a single character on all platforms, so the only thing that makes sense is passing a single character to crossfont.
Currently, crossfont works like this:
This PR proposes an option to rasterize a glyph specified by its index:
And to answer your question: no, this is not platform-specific. All the libraries used for different platforms support TrueType fonts. And all TrueType fonts have glyph indices as part of their format: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html
The notion of glyph indices and characters enables support for various features such as characters that can look different when placed around different characters (for example, Chinese characters look different when in a Korean context to when in a Japanese context, also ligatures), and these features are supported via shaping. Shaping retrieves a line of characters, and tells you the glyphs that you will need to render. Users of And they are two characters ( |
See also https://harfbuzz.github.io/why-do-i-need-a-shaping-engine.html:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be honest I'm not particularly interested in discussing API design for a feature I don't care about at the moment. I might come back to this in the future, but especially with no ligature implementation in sight for Alacritty, I see little purpose in spending time on this.
Will reopen once I get ligature support working for alacritty. |
It stands to reason that if this is the case and crossfont has to work with glyph indices anyway, providing a character instead should be the special case, not the other way around. Perhaps instead we should deal exclusively with glyph indices but support fast extraction of those indices from characters via helpers to make the sole main interface work with indices but still support characters. |
This is a breaking change.
Changes:
GlyphId
, which is a four bytes storage with the most significant bit as a flag for whether this is achar
or the glyph index.font_path
to theRasterize
trait. Provides a way to get the path of a font byFontKey
.Tested locally with targets: