[pango/coretext-font-describe: 1/2] coretext: Set size on font descriptions
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/coretext-font-describe: 1/2] coretext: Set size on font descriptions
- Date: Tue, 31 Aug 2021 04:55:12 +0000 (UTC)
commit a5e976d0f963bf4519b4ce3d64346d9f6e04ec64
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 | 8 ++++++++
pango/pangocoretext.c | 7 +++++--
2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 0980303b..c6ee1a73 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -407,6 +407,9 @@ _pango_core_text_font_description_from_ct_font_descriptor (CTFontDescriptorRef d
char *family_name;
char *style_name;
PangoFontDescription *font_desc;
+ int size;
+ CFNumberRef cf_number;
+ CGFloat pointsize;
font_desc = pango_font_description_new ();
@@ -419,6 +422,11 @@ _pango_core_text_font_description_from_ct_font_descriptor (CTFontDescriptorRef d
pango_font_description_set_family (font_desc, family_name);
g_free (family_name);
+ /* Size (if we have one) */
+ cf_number = CTFontDescriptorCopyAttribute (desc, kCTFontSizeAttribute);
+ if (cf_number != NULL && CFNumberGetValue (cf_number, kCFNumberCGFloatType, &pointsize))
+ pango_font_description_set_size (font_desc, (pointsize / (96./72.)) * 1024);
+
/* Weight */
pango_font_description_set_weight (font_desc,
ct_font_descriptor_get_weight (desc));
diff --git a/pango/pangocoretext.c b/pango/pangocoretext.c
index ccb3f674..f74d8c66 100644
--- a/pango/pangocoretext.c
+++ b/pango/pangocoretext.c
@@ -64,10 +64,13 @@ pango_core_text_font_describe (PangoFont *font)
PangoCoreTextFont *ctfont = (PangoCoreTextFont *)font;
PangoCoreTextFontPrivate *priv = ctfont->priv;
CTFontDescriptorRef ctfontdesc;
+ PangoFontDescription *desc;
- ctfontdesc = pango_core_text_font_key_get_ctfontdescriptor (priv->key);
+ ctfontdesc = CTFontCopyFontDescriptor (priv->font_ref);
+ desc = _pango_core_text_font_description_from_ct_font_descriptor (ctfontdesc);
+ CTRelease (ctfontdesc);
- return _pango_core_text_font_description_from_ct_font_descriptor (ctfontdesc);
+ return desc;
}
static PangoCoverage *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]