[pango/coretext-font-describe] coretext: Set size on font descriptions




commit ce555d8587bab7aec8b587c5bd6049fac3cadd0d
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Aug 30 16:28:43 2021 -0400

    coretext: Set size on font descriptions
    
    Set a size on the font description returned by
    pango_font_describe(). Otherwise, scaling it
    doesn't work.
    
    Fixes: #610

 pango/pangocoretext-fontmap.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 0980303b..4c17904e 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -346,6 +346,20 @@ ct_font_descriptor_get_weight (CTFontDescriptorRef desc)
   return weight;
 }
 
+static int
+ct_font_descriptor_get_size (CTFontDescriptorRef desc)
+{
+  CFNumberRef cf_number;
+  CGFloat value;
+
+  cf_number = CTFontDescriptorCopyAttribute (desc, kCTFontSizeAttribute);
+
+  if (cf_number != NULL && CFNumberGetValue (cf_number, kCFNumberCGFloatType, &value))
+    return (int) (value * 1024);
+  else
+    return 12;
+}
+
 static gboolean
 ct_font_descriptor_is_small_caps (CTFontDescriptorRef desc)
 {
@@ -419,6 +433,9 @@ _pango_core_text_font_description_from_ct_font_descriptor (CTFontDescriptorRef d
   pango_font_description_set_family (font_desc, family_name);
   g_free (family_name);
 
+  pango_font_description_set_size (font_desc,
+                                   ct_font_descriptor_get_size (desc));
+
   /* Weight */
   pango_font_description_set_weight (font_desc,
                                      ct_font_descriptor_get_weight (desc));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]