Skip to content
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

Zoomed layers result in blurry text #4813

Open
pepperoni505 opened this issue Jul 11, 2024 · 2 comments
Open

Zoomed layers result in blurry text #4813

pepperoni505 opened this issue Jul 11, 2024 · 2 comments
Labels
bug Something is broken

Comments

@pepperoni505
Copy link

Describe the bug
When zooming using the Pan Zoom demo on the website, it appears the font doesn't get properly updated to the zoom level, and still renders at the quality of the initial depth.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://www.egui.rs/
  2. Open the Pan Zoom demo
  3. Zoom in
  4. Observe text

Expected behavior
The text would not be blurry

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Safari
  • Version: Whatever the demo is running (presumably latest?)

Additional context

@pepperoni505 pepperoni505 added the bug Something is broken label Jul 11, 2024
@emilk emilk changed the title Pan/Zoom demo has blurry text Zoomed layers result in blurry text Jul 11, 2024
@jb55
Copy link

jb55 commented Dec 21, 2024

it would be great if we had something like https://sluglibrary.com/ for rendering text

EDIT: nm apparently open source projects can't implement this because the technique is patented (very lame). so another approach would be mesh based fonts.

Thinking about this some more, a quick fix might be to have a way to set the resolution of the glyph texture so that zooming up to a certain level remains crisp?

@jb55
Copy link

jb55 commented Dec 22, 2024

I went down a rabbit hole today looking into this. I was curious how browsers deal with glyph sizes when it comes to pinch zooming and found a few interesting comments by @pcwalton:

Honestly, there are so few different glyphs on a typical page, and CPUs are so fast, that it usually isn't that hard to just rerender every glyph on CPU and aggressively reuse glyph images in order to hit 60 FPS during pinch zoom, at least for Latin text. CJK may be a different story, but I kind of doubt it.

https://news.ycombinator.com/item?id=32113767

I imagine the fastest thing you could do is use an algorithm similar to slug to generate these glyph atlases on the gpu while you're zooming. The downside of this is that a gpu algo is not going to cover all of the features that something like swash will be providing?

Perhaps the best approach is some kind of glyph caching system that supports various sizes.

With the plan to switch to cosmic-text:

I noticed there is a SwashCache:

so maybe we can use that to cache glyphs at various sizes when we need them for a particular zoom level?

there is still the issue of what the texture atlas would look like in this setup, perhaps you would need something like

for building these dynamically? I'm just thinking out loud here since I have yet to dive into the internals of egui's glyph atlas and caching. would be curious to hear @emilk 's thoughts on how we might do this.

....

After doing some more digging it looks like glyphon does exactly this:

and I noticed there is egui-glyphon also:

...

I've updated egui-glyphon for 0.30.0 to see if I can get a proof of concept working:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants