Bug 40456 - BGR subpixel font rendering is broken, produces RGB subpixel order rendering
Summary: BGR subpixel font rendering is broken, produces RGB subpixel order rendering
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.10.2
Hardware: Other All
: medium major
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
Depends on:
Reported: 2011-08-29 05:09 UTC by Ingo Ruhnke
Modified: 2011-10-13 05:09 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

Add the missing break; (483 bytes, patch)
2011-08-29 18:16 UTC, Simon Elmir
Details | Splinter Review

Description Ingo Ruhnke 2011-08-29 05:09:19 UTC
BGR subpixel rendering is broken in 1.10.2, it always results in an image identical to RGB subpixel rendering. The problem can be produced with code like this:

    cairo_font_options_t* fopts = cairo_font_options_create();
    cairo_font_options_set_subpixel_order(fopts, CAIRO_SUBPIXEL_ORDER_BGR);
    cairo_font_options_set_antialias(fopts, CAIRO_ANTIALIAS_SUBPIXEL);
    cairo_set_font_options(cr, fopts);

Which will produce the same output as with CAIRO_SUBPIXEL_ORDER_RGB.

The problem is caused by a missing 'break' statement in a 'switch' in src/cairo-ft-font.c. Patch for the issue is attached.
Comment 1 Simon Elmir 2011-08-29 18:16:59 UTC
Created attachment 50673 [details] [review]
Add the missing break;

Ingo Ruhnke's patch.
Comment 2 Clarke Wixon 2011-10-12 23:01:05 UTC
I'll confirm the proposed fix -- I'm the original reporter on Ubuntu Bug 703191 (link available under "See Also"), and I have manually patched and built Cairo 1.10.2 on my system using Ingo Ruhnke's patch.

BGR-ordered subpixel font rendering now looks fine systemwide, and switching back and forth between RGB and BGR has the expected effect.

Can we get some developer eyes on this?  It's a year-old regression and it would be nice to kill it off once and for all.
Comment 3 Uli Schlachter 2011-10-13 04:45:57 UTC
The new test text-antialias-subpixel-bgr from commit 9208df1630a53 shows this exact problem. The proposed fix from comment 1 works there, too.

Could someone who dares touching font stuff take a closer look?
Comment 4 Chris Wilson 2011-10-13 05:09:28 UTC
commit 7df2c113b16666d4b1f3e4c6f4cb045c40929c4f
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Oct 13 13:02:51 2011 +0100

    ft: Add missing break to enable BGR subpixel rendering
    Reported-by: Ingo Ruhnke <grumbel@gmx.de>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=40456
    Original-patch-by: Simon Elmir <nerd65536+freedesktop@gmail.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

commit 9208df1630a535d473f656575c61a0ccf0c2a89c
Author: Uli Schlachter <psychon@znc.in>
Date:   Thu Oct 13 12:46:03 2011 +0200

    test: Add text-antialias-subpixel-{,v}{bgr,rgb}
    There were no tests for any subpixel order but rgb, so let's write something
    all four possibilities.
    This is mostly copy&paste from test/text-antialias.c (and
    text-antialias-subpixel-rgb does the same thing as text-antialias-subpixel)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.