-
Notifications
You must be signed in to change notification settings - Fork 52
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
Feat/emoji_support #160
base: main
Are you sure you want to change the base?
Feat/emoji_support #160
Conversation
I haven't had a super deep look at this yet. But my initial impressions: I'm not sure the draw-cache should be generalised to handle rgba in this way. Drawing images using I would probably approach it as a separate concept. I'm also not sure moving to Perhaps there is a more lightweight, modular & less breaking approach? It would be great if users were not affected by emoji functionality if they don't plan on actually using emojis. Perhaps the initial/minimum support would be allowing the layout code to leave appropriate space for emojis somehow so an external render logic could handle them (they could also still have vertices appended to the regular glyph vertices for a single draw in theory). That could lead to an To be clear I haven't thought deeply about such tradeoffs myself, so I don't have good answers. But I am interested in having a clearer picture of the different ways this can be supported and the tradeoffs they involve. |
I think if one texture caches one emoji, it is not able to draw all the emoji in one draw call.
Maybe the "emojibursh" shouldn't be in another crate, because we need to layout and shape the text and emoji at the same time, but draw them separately. So maintain two cache at the same time maybe a better way. If the users don't plan on actually using emoji, they just don't configure the emoji fonts, and emojis will not render. |
I was talking about one image per emoji inside the cache (which has multiple emojis). Whereas with outlined glyphs every different sub-pixel position may require a separate draw to ensure high quality. So the draw cache may have multiple versions of the same glyph at the same scale. The current draw-cache is all about handling that. Emojis using Pre-baked images also don't have the same concerns about drawing being an expensive operation, whereas rasterization of outlines is. There's probably no need for dedicated multithreading code for a pre-baked image atlas. So having an optimal pre-baked rgba image cache seems like a different enough problem that I'd try having it as a separate structure from the outline draw cache.
Yep we do need to support it in the layout code. However, the only changes to layout you have made are the I also think it would be possible to render both emojis and outlines in a single draw, by having both textures in the shader pipeline and including the necessary info in the instanced vertex. 2-draw would work too, but if glyph_brush bundled it up to support single draw it would be up to the render-code to decide rather than dictated here. That would be an advantage of integrating the rgba texture cache in the crate maybe. Maybe before integrating it would make sense to figure out with whats blocking implementing emojis alongside outlines as a user of glyph_brush today. Or if it is already possible, what are the pain points. Current stateI think layout already works with something like Section::default()
.add_text(Text::new("Hello "))
.add_text(Text::new("😃").with_font_id(FontId(1))) // where font-1 is an emoji font
.add_text(Text::new(" world")) iiuc the emoji won't result in a I haven't tried it myself, but in this way it seems possible to render emojis correctly without any changes to glyph_brush. Assuming that works, it's just not ideal having to iterate over the glyphs again to figure out the emoji stuff. So perhaps it would be better if the In the back of my mind I'm also thinking this has parallels with supporting bitmap fonts, since they're also generally pre-baked rgba (#17). |
…don't need to calculate sub-pixel positions.
This crate uses a different scale value Currently if you want to size in pt you need to convert that into the equivalent I'm tempted to move to pt scale by default but this is a breaking change for the crate. |
pt scales are also measured in pixels, I believe that is what chrome uses. |
It just doesn't mean the same thing. |
Thanks for your reply!
Emoji has many codepoints, such as variation selector-16, skin tone modifier, zero-width joiner... and the grapheme cluster which is a sequence of codepoints that is considered a single human-perceived glyph. We could indeed only return the vertices of the emojis and renderer them through an external cargo, but perhaps the codepoints should be detected in glyph_brush first, otherwise the location of the vertex is wrong. |
Support the Rendering of emoji.
emoji_cache
inGlyphBrush
, and upload the textures separately. The data's type inoutline_cache
is u8, and inemoji_cache
is u32.font_id
inText
is changed to a vector type, thus supporting both normal fonts and emoji fonts.Todo: