servo / font-kit

A cross-platform font loading library written in Rust
Apache License 2.0
681 stars 100 forks source link

Support/Enable LCD filtering for subpixel antialiased text #95

Closed mrandri19 closed 5 years ago

mrandri19 commented 5 years ago

Currently, when rendering a glyph on Linux using the FreeType renderer and RasterizationOptions::SubpixelAa there is no LCD filtering.

It looks like this, with very noticeable color fringing: image

To enable filtering with FreeType FT_Library_SetLcdFilter should be set, but I don't know how that would work on other platforms.

The easiest solution would be to keep it transparent to the user and always use FT_LCD_FILTER_DEFAULT with FreeType. I could try to make a pull request for that if this solution works for you.

pcwalton commented 5 years ago

Let's use FT_LCD_FILTER_DEFAULT.

pcwalton commented 5 years ago

Also yikes, that's a big oversight! Thanks for catching it.

heftig commented 4 years ago

FTR, if the current FreeType is compiled without support for LCD filters (and thus FT_Library_SetLcdFilter always fails), it will produce output almost identical to FT_LCD_FILTER_LIGHT.

Maybe that's why this was overlooked.