-
-
Couldn't load subscription status.
- Fork 1.4k
Text shaping, font fallback, and iced_wgpu overhaul
#1697
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
Conversation
|
Woo! 🎉 |
|
|
||
| /// The result of hit testing on text. | ||
| #[derive(Debug, Clone, Copy, PartialEq)] | ||
| pub enum Hit { |
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.
Could remove this and just have the CharOffset(usize) as a struct to avoid the match in the impl, unless you plan on adding more variants back!
native/src/overlay/menu.rs
Outdated
| let intrinsic = Size::new( | ||
| 0.0, | ||
| f32::from(text_size + self.padding.vertical()) | ||
| (f32::from(self.padding.vertical()) + text_size * 1.2) |
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 1.2 value is used in a few different calculations; might it be better suited as a font::DEFAULT_LINE_HEIGHT or something const?
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.
Yes, I have plans to make this configurable somehow. Still figuring it out.
And get rid of the staging belt! 🎉
|
I am still experiencing tofu font issues when using |
I didn't understand your previous message. After replacing |
This PR introduces support for text shaping and font fallback (#33), as well as it improves the architecture of
iced_wgputo get rid of bottlenecks that were present since the inception of the library (#41).cosmic-textandglyphonThe
wgpu_glyphdependency iniced_wgpuhas been replaced withglyphon, a fairly new text renderer forwgputhat has a better-suited architecture for layering and caching.Recently,
glyphonlanded integration withcosmic-text(grovesNL/glyphon#23), which provides advanced text shaping, layout, and rendering wrapped up into a simple abstraction.cosmic-texthas been a long-time-missing piece in the Rust GUI ecosystem and the folks at System76 are breaking ground to make the ecosystem thrive!What does this all mean? It means
icedis now capable of rendering more complex scripts, automatically finding missing glyphs in your system fonts (no more tofu!), and selecting fonts based on their family.For instance, we can now handle emoji 🥳:
iced_wgpuoverhaulSince the inception of the library,
iced_wgpuhas been limited by the (now gone)wgpu_glyphdependency. The main issue withwgpu_glyphis that it couples uploading new data to the GPU with recording draw calls. This architecture is forced byglyph-brush, an internal dependency originally designed with OpenGL in mind that deals with text and glyph caching.The architecture of
wgpu_glyphbecomes a problem when combined with layering. If we want to draw multiple layers of text with other kinds of primitives between them then we have to issue multiple text draw calls (a depth buffer would break alpha blending). But since uploads and draw calls are coupled, we are forced to issue a complete newRenderPassfor every layer of text!And it gets worse!
glyph-brushcouples cache trimming with drawing as well. So not only we have to issue a whole newRenderPassand upload data between draw calls, but every layer overwrites the cache of the previous one. Not good.glyphonhas a completely different architecture. For starters, it has a first-classTextAtlaswhich represents the glyph cache. Then, it has aTextRenderertype with two different methods:prepareandrender.preparedeals with preparing buffers and updating theTextAtlas, whilerenderjust issues a draw call.This separation is great because it lets us completely redesign the architecture of
iced_wgputo split rendering intoprepareanddrawstages and reuse aRenderPassas much as possible (no uploads in between!). Furthermore, aTextAtlascan be shared with manyTextRenderers (i.e. layers!) as needed.Memory usage should also be considerably lower, since we are no longer forced to use a
StagingBeltto upload between draw calls.Deprecation of
iced_glowandiced_glutinAs of now,
glyphononly works withwgpu. In order to bring these improvements over to theiced_glowrenderer, we would need to addglowsupport forglyphon(or fork it). This would take a considerable amount of effort.As time goes on, maintaining
iced_glowis becoming quite a headache. OpenGL is full of pitfalls and ensuring compatibility with older hardware while also taking advantage of more modern one is a pain.Because of this, I have decided to deprecate
iced_glowandiced_glutin. I am just removing the crates from the repository for now. But by all means, if someone is interested in maintaining them further I will gladly give you a repository in theiced-rsorganization.Instead of working on maintaining a renderer with a graphics API that is on its deathbed, I prefer to focus on implementing a proper software renderer. This should increase the compatibility of the library even further; allowing it to run not only in older hardware but also in environments with no GPUs (e.g. virtual machines).
Next steps
These changes are not ready for
masteryet! They will be merged into a newadvanced-textbranch for now.First, it's very likely there are a bunch of bugs! While we may be able to draw complex scripts now, we are certainly not capable of editing them. The
TextInputlogic has not been changed.Also, the vectorial text support (#1610) needs to be merged and integrated with these changes.
Finally, since removing
iced_glowdecreases the compatibility of the library considerably, I would like to have a software renderer before these new features can land inmaster.