-
Notifications
You must be signed in to change notification settings - Fork 131
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
Set LCD geometry for subpixel rendering #296
Comments
Yes, I think this make sense to expose a wrapper to be able to use this function ! |
So according to https://freetype.org/freetype2/docs/reference/ft2-lcd_rendering.html Subpixel rendering mode, depends on FT compilation option. FT_CONFIG_OPTION_SUBPIXEL_RENDERING enables ClearType-style rendering. Otherwise, Harmony LCD rendering is enabled. ClearType-style rendering: (since FT 2.3.0) ClearType-style LCD rendering exploits the color-striped structure of LCD pixels, increasing the available resolution in the direction of the stripe (usually horizontal RGB) by a factor of 3 Use the functions: Harmony LCD rendering: (since FT 2.10.0) Harmony LCD rendering is suitable to panels with any regular subpixel structure, not just monitors with 3 color striped subpixels, as long as the color subpixels have fixed positions relative to the pixel center Use the functions: So we would need 3 stubs to FreeType functions to cover the two modes + one function to tell if we're doing ClearType-style or Harmony. or just export the "FT_Library" internal handle and let people deal with it ? |
TTF_GetSubpixelMode() TTF_SetLcdFilter() TTF_SetLcdFilterWeights() TTF_SetLcdGeometry() see libsdl-org#296
I think adding / exposing the freetype function is the way to go: @Qrox |
@1bsyl Thanks for the update. The patch looks good to me but unfortunately I do not have time to test it right now. I can provide some observation that might make sense to note in the documentation though.
|
TTF_GetSubpixelMode() TTF_SetLcdFilter() TTF_SetLcdFilterWeights() TTF_SetLcdGeometry() see libsdl-org#296
Thanks for the feedback ! update:
|
indeed: |
TTF_GetSubpixelMode() TTF_SetLcdFilter() TTF_SetLcdFilterWeights() TTF_SetLcdGeometry() see libsdl-org#296
updated with "extern declspec" |
should we maintain an internal list of open fonts or just document the behavior :/ |
There's also the scenario of multiple monitors with different subpixel layouts, and not clearing the glyph cache can enable the user to create different versions of a font to apply to different monitors. But it sounds a bit hacky and I suppose the proper way is to ask freetype to add a per-font layout setting. |
maybe, we should tweak those new TTF_SetLcd function to take a TTF_Font in parameter, |
I've update the PR so that the setting are per-font, re-apply the setting if they have changed, flush the cache. |
@Qrox |
Sure, I have some in progress changes to |
I have added tests in example/testapp.c to test filter and filterweight and harmony maybe this ok, for merging ? @slouken |
Currently, SDL_ttf uses the Harmony algorithm with default LCD geometry (uniform RGB subpixels in the horizontal direction) when doing subpixel rendering. According to freetype docs,
which apparently does not work for screens with a different subpixel layout, as evidenced by this post.
Freetype has a function
FT_Library_SetLcdGeometry
for setting the geometry but it requires passing in the library instance which is a static variable in SDL_ttf, so it is currently impossible to set the LCD geometry when using SDL_ttf.It would be nice if SDL_ttf can expose this function to achieve the best rendering quality on non-conventional screens.
The text was updated successfully, but these errors were encountered: