Bug 25118 - hinting for CAIRO_HINT_STYLE_MEDIUM is wrong
Summary: hinting for CAIRO_HINT_STYLE_MEDIUM is wrong
Status: RESOLVED WONTFIX
Alias: None
Product: cairo
Classification: Unclassified
Component: freetype font backend (show other bugs)
Version: 1.9.5
Hardware: Other All
: medium normal
Assignee: David Turner
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-16 05:19 UTC by Pierre Ossman
Modified: 2012-05-27 11:35 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Pierre Ossman 2009-11-16 05:19:12 UTC
The way cairo maps CAIRO_HINT_STYLE_MEDIUM to Freetype settings is different from other libraries, which makes things look strange when you have some apps using Cairo for rendering and some using something else (like Xft).

The offending code is in cairo-ft-font.c:_cairo_ft_options_merge():

...
	switch (options->base.hint_style) {
	case CAIRO_HINT_STYLE_NONE:
	    load_flags |= FT_LOAD_NO_HINTING;
	    break;
	case CAIRO_HINT_STYLE_SLIGHT:
	    load_target = FT_LOAD_TARGET_LIGHT;
	    break;
	case CAIRO_HINT_STYLE_MEDIUM:
	    break;
	case CAIRO_HINT_STYLE_FULL:
	case CAIRO_HINT_STYLE_DEFAULT:
...

All other implementations I've found map FT_LOAD_TARGET_LIGHT to both "slight" and "medium". E.g. Xft:

	if (FC_HINT_NONE < hint_style && hint_style < FC_HINT_FULL)
	{
	    fi->load_flags |= FT_LOAD_TARGET_LIGHT;
	}

Pango:

      switch (hintstyle) {
      case FC_HINT_SLIGHT:
      case FC_HINT_MEDIUM:
	ft2font->load_flags |= FT_LOAD_TARGET_LIGHT;
	break;

One entertaining effect of this is gnome-appearance-properties which uses Xft to render the font examples, but then GTK+ uses Cairo for the actual font rendering, resulting in the examples showing something other than what you will get.
Comment 1 Carl Worth 2010-02-19 13:08:18 UTC
Behdad,

Can you comment on this? Is this an obvious bug in cairo that we should just fix?

-Carl
Comment 2 Pierre Ossman 2012-02-02 02:22:18 UTC
Had enough time to mull this over? :)
Comment 3 Behdad Esfahbod 2012-05-27 11:35:48 UTC
The problem is, even if you're right, changing this at this point will break stuff.  Since Xft is hardly in use these days, I don't see any reason to change this.

As it is, cairo's HINT_LIGHT, HINT_MEDIUM, and HINT_FULL each achieve a different rendering.  Merging two of those into one sounds like a regression to me.


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.