GNOME Bugzilla – Bug 749635
Font weights are incorrectly mapped between Pango and FontConfig, particularly semilight
Last modified: 2015-05-25 01:34:58 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.
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.