After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 749635 - Font weights are incorrectly mapped between Pango and FontConfig, particularly semilight
Font weights are incorrectly mapped between Pango and FontConfig, particularl...
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.36.x
Other All
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2015-05-20 13:54 UTC by simon
Modified: 2015-05-25 01:34 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description simon 2015-05-20 13:54:09 UTC
The mapping between Pango and FontConfig weights is incorrect.

In pangofc-fontmap.c, there are functions pango_fc_convert_weight_to_pango and pango_fc_convert_weight_to_fc. These should provide a 1:1 mapping when applied sequentially to standard font size values, but in several cases they don't.

The biggest problem is the implementation of the semilight weight. In the ..._to_pango function, PANGO_WEIGHT_SEMILIGHT (350) is returned if the input is between 45 and 52 and PANGO_WEIGHT_LIGHT (300) is returned if the input is between 52 and 65. So a FontConfig weight of 50 returns a Pango weight of 350, and a FontConfig weight of 55 returns a Pango weight of 300 - these are the wrong way around, in that a heavier input weight returns a lighter output weight, which cannot be correct.

There are other errors elsewhere in the tables. 

A Pango weight of 1000 converts to an FC weight of 215, which then converts back to 900. Conversely, an FC weight of 215 converts to a Pango weight of 900, which then converts back to 210.

An FC weight of 180 converts to a Pango weight of 600, which then converts back to 150.

To fix the semilight issue, I would suggest that ...convert_weight_to_pango needs to return PANGO_WEIGHT_LIGHT (300) if the input is between 45 and 52, and PANGO_WEIGHT_SEMILIGHT (350) if it is between 52 and 65 - the statements that return these two values should be switched.
Comment 1 Matthias Clasen 2015-05-20 17:06:45 UTC
this might be an excellent place for a unit test, if the api exposes this conversion in a way that can be accessed from a test.