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

draw cache: Rework subpixel position & scale matching #104

Open
alexheretic opened this issue May 13, 2020 · 0 comments
Open

draw cache: Rework subpixel position & scale matching #104

alexheretic opened this issue May 13, 2020 · 0 comments

Comments

@alexheretic
Copy link
Owner

The current draw cache design, inherited from rusttype's gpu_cache, isn't great at handling larger glyphs.

To get high quality small glyphs you needed a very precise subpixel-position tolerance & precise scale tolerance.

As glyphs get larger though, these become more meaningless. At a certain scale I no longer care about subpixel position at all, and we have quite wasteful usage of texture space. We can also happily match with much larger glyphs without issue, so the scale tolerance makes less sense too.

Even with small glyphs the large amount of copies with different sub-pixel positions should be less necessary as the draw cache has sub-pixel correction, whereas rust type always placed textures as drawn.

So I'd like to

  • Set a max accuracy at low scales using a square number instead of a tolerance. So for example I could config a max of 25 copies at scale 10.0. That is 5x5 sub-pixel "zones" for matching the correct sub-pixel render.
  • Set some sort of way that at larger sizes we match less of these "zones" eventually only rendering once per glyph (1x1 zone) as sub-pixel position differences will no longer be visible at the larger scale.
  • Once we up to not caring about sub-pixel position, we should also be able to re-use larger scale matching glyphs. So a 150px w texture can be used for a 120px w, but not for a 12px w.

I think in doing this properly we could have much more efficient texture usage in almost all cases without any real loss of quality. One issue is we can currently perform constant-time lookups using the immutable scale & subpixel position tolerances, with a new cleverer system lookup speed will still be important.

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

No branches or pull requests

1 participant