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

[WIP] Fix #109: Implement basic subpixel rendering #377

Closed
wants to merge 11 commits into from

Conversation

bryphe
Copy link
Member

@bryphe bryphe commented Mar 2, 2019

This change adds subpixel rendering for low DPI displays to improve the quality of the rendered text (important for editors like Onivim 2). The basic strategy is to render the font glyph at 3x resolution, and then use a kernel to sample each color channel individually.

The chosen strategy only works with solid color backgrounds, which is an acceptable trade-off for now (if there is a non-solid color background, we'll fallback to a non-subpixel strategy).

The initial kernel is very simple - sample each channel subpixel against the high-resolution glyph. There's better choices of kernel potentially (that require more texture reads), we can experiment and see what works well.

This fixes #109

TODO:

  • Conditionally enable subpixel rendering only when low DPI and background color is solid
  • Investigate using FT_Render_Mode_LCD with FreeType, along with various filters
  • Remove hardcoding of scaling
  • Handle pixel alignment - make glyph quad always pixel-aligned, but adjust subpixel offset for text (test in example)
  • Try out different colors in example
  • Add option in example to enable / disable subpixel rendering
  • Should we be using GL_NEAREST instead of GL_LINEAR for sampling? Nope
  • Experiment with alternate kernels - the 5-tap filter here looks promising: https://www.grc.com/cttech.htm
  • Investigate filter options with Freetype (https://www.freetype.org/freetype2/docs/reference/ft2-lcd_filtering.html)

@bryphe
Copy link
Member Author

bryphe commented Apr 28, 2019

Will close this out to be superseded by the Skia effort

@bryphe bryphe closed this Apr 28, 2019
@Et7f3 Et7f3 deleted the bryphe/text/subpixel-rendering branch May 6, 2021 13:32
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

Successfully merging this pull request may close these issues.

Text Rendering / Clarity: Investigate subpixel rendering strategies
1 participant