[cairo] API to disable subpixel antialiasing per-surface
Robert O'Callahan
robert at ocallahan.org
Mon Jan 10 14:12:43 PST 2011
On Tue, Jan 11, 2011 at 2:08 AM, Behdad Esfahbod <behdad at behdad.org> wrote:
> I found both the API and the implementation less than elegant. In fact,
> both
> are dirty hacks!
>
> On the API level, it defeats the whole purpose of having an opaque
> cairo_font_options_t.
I'm not sure what you mean by that.
I'm open to making _cairo_surface_set_font_options()
> public if that helps.
>
It won't help. That would only affect fonts whose font options are set to
CAIRO_ANTIALIAS_DEFAULT. Sometimes we're setting font options to
CAIRO_ANTIALIAS_SUBPIXEL explicitly (e.g. downloaded fonts need Cleartype in
Windows XP even if the user hasn't enabled Cleartype) and but we still need
to disable subpixel AA when rendering those fonts to RGBA surfaces (in some
cases).
On the implementation level, it's just wrong. The scaled font glyph metrics
> may depend on the antialias mode. In which case with your patch, apps
> position glyphs with one mode, and render with another. It's broken.
>
If, at layout time, we know that the font needs to be grayscale-AA, we will
make it so when we construct the font and we don't need this additional
control. But sometimes we don't know until after layout is done whether we
can use subpixel AA or not, because that actually depends on layout! For
example, if text overlaps a GPU-accelerated video, we may need to place it
in an RGBA layer. In that case, rendering the glyphs of the grayscale-AA
font using glyph positions of the subpixel-AA font seems to give better
results than mangling the subpixel-AA alpha channels into a single alpha
value as cairo does today, especially when the text isn't black. We can't
handle a circular dependency where layout depends on the antialiasing of the
text and the antialiasing of the text depends on layout.
I understand your frustration, but this approach doesn't work IMO.
>
I'd welcome a better suggestion.
Rob
--
"Now the Bereans were of more noble character than the Thessalonians, for
they received the message with great eagerness and examined the Scriptures
every day to see if what Paul said was true." [Acts 17:11]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110111/59b792ee/attachment.html>
More information about the cairo
mailing list