bugBattle for Wesnoth - Bugs: bug #21648, Pango/Cairo (GUI2) font rendering...

Show feedback again

bug #21648: Pango/Cairo (GUI2) font rendering with ClearType on Windows

Submitted by:  Ignacio R. Morelle <shadowmaster>
Submitted on:  Fri Feb 14 05:05:48 2014  
Category: BugSeverity: 4 - Important
Priority: 5 - NormalItem Group: User Interface
Status: FixedPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Release: 1.10.x, 1.11.x, earlier too maybeOperating System: Windows XP - 8

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Mon Aug 8 12:40:02 2016, comment #10:

Big improvement. I think this can be marked as fixed/done. Thanks.

Wedge009 <wedge009>
Project Member
Sun Aug 7 18:29:05 2016, comment #9:

I committed https://github.com/wesnoth/wesnoth/commit/c91b200b7a10bf82fb13417a1267fcdf0fc4b2c1 which reduces the number of rendering passes on Windows to 1 and uses CAIRO_ANTIALIAS_DEFAULT. JyrkiVesterinen reported this now makes Wesnoth respect Window's font smoothing settings, so I consider this an improvement.

Charles Dang <vultraz>
Project Administrator
Wed Jun 22 10:03:18 2016, comment #8:

> To me, images 2, 3, and 4 look the same (in terms of fonts)

Hmm yes its eaiser to see when you see those images like a gif.

> while image 1 looks like it's using CAIRO_ANTIALIAS_DEFAULT

Liek i said, only image 4 uses CAIRO_ANTIALIAS_GRAY.

Daniel <gfgtdf>
Project Member
Wed Jun 22 10:00:12 2016, comment #7:

Well, shadown gave a link to his patch in comment 3, it changes sets anitalasing to CAIRO_ANTIALIAS_GRAY

Daniel <gfgtdf>
Project Member
Wed Jun 22 00:42:04 2016, comment #6:

Not sure what shadowm's patch involves. To me, images 2, 3, and 4 look the same (in terms of fonts) while image 1 looks like it's using CAIRO_ANTIALIAS_DEFAULT in Windows. I've uploaded updated screenshots with the Lato font, both are taken with current master aside from changing the anti-aliasing mode for Cairo (as previously). Default AA continues to look like the hinting is applied twice as much as the grey-scale AA.

Wedge009 <wedge009>
Project Member
Tue Jun 21 19:36:26 2016, comment #5:

I just dis some testing on latest master:
picture 4 is current master.
picture 1 is without shadowms patch.
picture 2 is without shadowms patch decode_pixel() on windows.
picture 3 is without shadowms patch doing a single draw (as opposed to current master which does 3 draws.)

Daniel <gfgtdf>
Project Member
Sat Aug 1 13:04:33 2015, comment #4:

After posting those screenshots I also managed to get Pango 1.37.2 compiled and working. Still no change in the text rendering with CAIRO_ANTIALIAS_DEFAULT. ):

Wedge009 <wedge009>
Project Member
Sun Feb 23 08:03:38 2014, comment #3:

I committed the workaround from file #20044 in commit cdab0f2e842a68acea9227c87783d11ce8f4d23a, which is in version 1.11.10.

The underlying bug (which may or may not be related to the specific Cairo version we use on Windows) remains unsolved, but I'm marking this as In Progress anyway.

Ignacio R. Morelle <shadowmaster>
Project Administrator
Fri Feb 14 05:11:12 2014, comment #2:

All that said, I found that forcing the antialiasing mode to be grayscale on Windows in the ttext constructor minimized the issue, although some (literal) rough edges remain; take a close look at the text in italics in the attached screenshot, for example.

I am attaching both the patch (done against current Git master) and a screenshot of its effects.

(file #20043, file #20044)

Ignacio R. Morelle <shadowmaster>
Project Administrator
Fri Feb 14 05:07:15 2014, comment #1:

GUI1 screenshot for comparison.

(file #20042)

Ignacio R. Morelle <shadowmaster>
Project Administrator
Fri Feb 14 05:05:48 2014, original submission:

As evidenced by the attached screenshots, the Pango/Cairo font rendering code path used by GUI2 yields considerably different results to the SDL_ttf (freetype) path used by GUI1 when running on Windows XP and later with ClearType enabled (there is no way to disable it from the Windows configuration UI on Vista and later).

In fact, the Cairo rendering with ClearType looks generally inferior due to the way antialiasing bits are overpainted. For instance, consider the rendering of the words "encircling" and "skirmishers" in the titlescreen screenshot: the thinner 'l's and 'i's make the text look poorly-rendered, and the thin 'i' following a thick 'm' in "skirmishers" makes the kerning seem inconsistent.

The overpainting is done on purpose as a Windows-specific hack in ttext::rerender() (src/text.cpp around line 678) because there appears to be a bug with the decode_pixel() function normally used on Linux and other systems; in fact, forcing that rendering method on Windows results in a washed-out text effect.

Because Pango/Cairo and SDL_ttf/freetype-based text rendering still coexist in Wesnoth largely due to the continued usage of GUI1, having these inconsistencies in font rendering within the same application gives the game a significantly less polished overall appearance. Since Windows users comprise a large part of our audience, I consider this to be a rather important issue that might be worth solving before or during Wesnoth 1.12.x.


  • The Cairo version in use appears to be 1.10.2 -- I obtained it from the Windows build-time dependencies dir from the Wesnoth SF.net project for building on Windows.) However, I think this is also the version that is used for our official Windows build. What I don't know for sure if this is actually a bug in Cairo (or possibly Pango?) that is already solved in newer versions; unfortunately, the Gtk+ project site does not have newer Windows builds than 1.10.2.
  • Although the screenshots were made with a 1.11.6+dev build, the issue remains in latest Git master, and as far as I know has been present for a long time, even before 1.10.x.
Ignacio R. Morelle <shadowmaster>
Project Administrator


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #27614:  wesnoth-1.13.4+dev-win32-cleartype-cairo-1.14.4-defaults.png added by wedge009 (463kB - image/png - Adding screenshots with Lato font - current master as at 2016-06-22.)
file #27615:  wesnoth-1.13.4+dev-win32-cleartype-cairo-1.14.4-greyscale-aa.png added by wedge009 (470kB - image/png - Adding screenshots with Lato font - current master as at 2016-06-22.)
file #24715:  wesnoth-win32-cleartype-cairo-1.14.2-defaults.png added by wedge009 (105kB - image/png - Demonstrating the issue still stands with Cairo 1.14.2 in Windows.)
file #24716:  wesnoth-win32-cleartype-cairo-1.14.2-grayscale-aa.png added by wedge009 (107kB - image/png - Demonstrating the issue still stands with Cairo 1.14.2 in Windows.)
file #20044:  font-render.patch added by shadowmaster (510B - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by vultraz (Posted a comment)
  • -unavailable- added by gfgtdf (Posted a comment)
  • -unavailable- added by wedge009 (Updated the item)
  • -unavailable- added by shadowmaster (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Nov 7 08:07:55 2016vultrazOpen/ClosedOpen=>Closed
    Mon Aug 8 12:52:35 2016vultrazStatusIn Progress=>Fixed
    Wed Jun 22 00:35:18 2016wedge009Attached File-=>Added wesnoth-1.13.4+dev-win32-cleartype-cairo-1.14.4-defaults.png, #27614
      Attached File-=>Added wesnoth-1.13.4+dev-win32-cleartype-cairo-1.14.4-greyscale-aa.png, #27615
    Sat Aug 1 12:02:44 2015wedge009Attached File-=>Added wesnoth-win32-cleartype-cairo-1.14.2-defaults.png, #24715
      Attached File-=>Added wesnoth-win32-cleartype-cairo-1.14.2-grayscale-aa.png, #24716
    Sun Feb 23 08:03:38 2014shadowmasterStatusNone=>In Progress
    Fri Feb 14 05:11:12 2014shadowmasterAttached File-=>Added wesnoth-win32-cleartype-cairo-grayscale-aa.png, #20043
      Attached File-=>Added font-render.patch, #20044
    Fri Feb 14 05:07:15 2014shadowmasterAttached File-=>Added wesnoth-win32-cleartype-freetype.png, #20042
    Fri Feb 14 05:05:48 2014shadowmasterAttached File-=>Added wesnoth-win32-cleartype-cairo-defaults.png, #20041
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup