[Bug 744812] Re: FontConfig/Qt stack choke on Ubuntu Medium font meta-data (No medium in Inkscape and too bold in Qt apps)

Michał Sawicz michal.sawicz at canonical.com
Sat Sep 22 10:40:28 UTC 2012


I managed to track down the culprit:

http://qt.gitorious.org/qt/qt/blobs/4.8/src/gui/text/qfontdatabase_x11.cpp#line729

The problem is that Qt only supports 5 weights:
http://qt.gitorious.org/qt/qt/blobs/4.8/src/gui/text/qfont.h#line103
  Light		= 25,
  Normal	= 50,
  DemiBold	= 63,
  Bold		= 75,
  Black		= 87

FontConfig has 11 weights defined:
http://cgit.freedesktop.org/fontconfig/tree/fontconfig/fontconfig.h#n126
  #define FC_WEIGHT_THIN		    0
  #define FC_WEIGHT_EXTRALIGHT	    40
  #define FC_WEIGHT_ULTRALIGHT	    FC_WEIGHT_EXTRALIGHT
  #define FC_WEIGHT_LIGHT		    50
  #define FC_WEIGHT_BOOK		    75
  #define FC_WEIGHT_REGULAR		    80
  #define FC_WEIGHT_NORMAL		    FC_WEIGHT_REGULAR
  #define FC_WEIGHT_MEDIUM		    100
  #define FC_WEIGHT_DEMIBOLD	    180
  #define FC_WEIGHT_SEMIBOLD	    FC_WEIGHT_DEMIBOLD
  #define FC_WEIGHT_BOLD		    200
  #define FC_WEIGHT_EXTRABOLD	    205
  #define FC_WEIGHT_ULTRABOLD	    FC_WEIGHT_EXTRABOLD
  #define FC_WEIGHT_BLACK		    210
  #define FC_WEIGHT_HEAVY		    FC_WEIGHT_BLACK
  #define FC_WEIGHT_EXTRABLACK	    215
  #define FC_WEIGHT_ULTRABLACK	    FC_WEIGHT_EXTRABLACK

And getFCWeight maps them as follows:
   0 ÷  75 => Light
  76 ÷ 140 => Normal
 141 ÷ 190 => DemiBold
 191 ÷ 205 => Bold
 206 ÷  ∞  => Black

Because of that both Ubuntu Regular and Medium fall into the same Qt
weight - QFont::Normal. Since that operation loses the granularity,
there's probably no easy way to distinguish between Normal and Medium
later in the process.

Possible solutions:
a) introduce QFont::Medium
b) make FC_WEIGHT_MEDIUM mapped to QFont::DemiBold
c) drop seemingly duplicate fonts

I myself would lean towards solution a), but neither that or b) really
fixes anything - if there's duplicates, it becomes non-deterministic in
which font will be selected (the last one added? a random one?).
Solution c) seems to be the most complete, but then also quite
intrusive. We'd have to only leave the one whose fontconfig weight is
closest to the respective weight. So from each of the getFCWeight ranges
only one font would be selected, closest to what fontconfig says that
weight should be.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to fontconfig in Ubuntu.
https://bugs.launchpad.net/bugs/744812

Title:
  FontConfig/Qt stack choke on Ubuntu Medium font meta-data (No medium
  in Inkscape and too bold in Qt apps)

Status in Linux Libertine:
  Unknown
Status in Ubuntu Font Family:
  Invalid
Status in “fontconfig” package in Ubuntu:
  Confirmed
Status in “ubuntu-font-family-sources” package in Ubuntu:
  Confirmed
Status in “fontconfig” source package in Natty:
  Confirmed
Status in “ubuntu-font-family-sources” source package in Natty:
  Fix Released
Status in “fontconfig” source package in Oneiric:
  Confirmed
Status in “ubuntu-font-family-sources” source package in Oneiric:
  Fix Released
Status in “fontconfig” source package in Precise:
  Confirmed
Status in “ubuntu-font-family-sources” source package in Precise:
  Fix Released
Status in “fontconfig” source package in Quantal:
  Confirmed
Status in “ubuntu-font-family-sources” source package in Quantal:
  Confirmed

Bug description:
  [Kubuntu natty up-to-date]
  Hi,
  Without any change on my system, I noticed some days ago that my default font (ubuntu) changed. Some odd behaviour appeared : ubuntu medium 10 pt was ok but ubuntu medium 11pt was bold (-> in my taskbar clock or in kpackapgekit). In fact, after some play with kcm kubuntu font manager, the ubuntu medium 10pt was wrong, since kcm module shows the true appearance of ubuntu medium, which is quite bold. I swapped to ubunu light font
  SO ! I changed font hinting to light (default in kubuntu seems to be medium) and it seems to have solved bugs.
  Anyway, "ubuntu font" management by KDE seems to be strange, and firefox 4 font rendering is worse (imho) with light hinting (but maybe because of unselected "system default" parameter in fonts kcm).

To manage notifications about this bug go to:
https://bugs.launchpad.net/linuxlibertine/+bug/744812/+subscriptions




More information about the foundations-bugs mailing list