summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-12 20:17:38 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-11-12 20:17:38 +0000
commit017af62e2a524fe103c08224a8669c110cdbb514 (patch)
tree8076df4f5e59fae48f3bc85f7a0e66cec9561f79
parentae15885600be2e3ac3fe48aff821881a0feb018b (diff)
parent050e321e1e73b6cf12caf7a58a52b58079c9afb1 (diff)
downloadpango-017af62e2a524fe103c08224a8669c110cdbb514.tar.gz
Merge branch 'ctweight' into 'main'
coretext: correctly clamp the core text weights at min/max values See merge request GNOME/pango!502
-rw-r--r--pango/pangocoretext-fontmap.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 3d8544c6..6a68003e 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -116,6 +116,7 @@ typedef struct
/* This map is based on empirical data from analyzing a large collection of
* fonts and comparing the opentype value with the value that OSX returns.
* see: https://bugzilla.gnome.org/show_bug.cgi?id=766148
+ * FIXME: This need recalibrating, values outside these bounds do occur!
*/
static const PangoCTWeight ct_weight_map[] = {
@@ -315,6 +316,7 @@ ct_font_descriptor_get_weight (CTFontDescriptorRef desc)
CFNumberRef cf_number;
CGFloat value;
PangoWeight weight = PANGO_WEIGHT_NORMAL;
+ guint i;
dict = CTFontDescriptorCopyAttribute (desc, kCTFontTraitsAttribute);
cf_number = (CFNumberRef)CFDictionaryGetValue (dict,
@@ -322,14 +324,13 @@ ct_font_descriptor_get_weight (CTFontDescriptorRef desc)
if (cf_number != NULL && CFNumberGetValue (cf_number, kCFNumberCGFloatType, &value))
{
- if (value < ct_weight_min || value > ct_weight_max)
+ if (!(value >= ct_weight_min && value <= ct_weight_max))
{
- /* This is really an error */
- weight = PANGO_WEIGHT_NORMAL;
+ i = value > ct_weight_max ? G_N_ELEMENTS (ct_weight_map) - 1 : 0;
+ weight = ct_weight_map[i].ct_weight;
}
else
{
- guint i;
for (i = 1; value > ct_weight_map[i].ct_weight; ++i)
;