summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2022-06-27 15:52:51 +0800
committerMatthias Clasen <mclasen@redhat.com>2022-07-04 11:17:28 -0400
commit76400dc7d7c25c5484e4ed21a41b38c7ccbfba32 (patch)
tree60e90eeaa6a5a06f508cad06c57a7ffba4ceb556
parent7e91a51eb097c4e1266d3a689b2abe6e599ffd29 (diff)
downloadpango-76400dc7d7c25c5484e4ed21a41b38c7ccbfba32.tar.gz
pangodwrite-fontmap.cpp: Fix up Pango2Stretch mapping
It seems that we weren't getting the Pango2Stretch values from DirectWrite correctly. Seems like the Pango2Stretch enumerations were largely in line with the enumerations indicated by DWRITE_FONT_STRETCH.
-rw-r--r--pango2/pangodwrite-fontmap.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/pango2/pangodwrite-fontmap.cpp b/pango2/pangodwrite-fontmap.cpp
index ffbfbcb0..532c3a38 100644
--- a/pango2/pangodwrite-fontmap.cpp
+++ b/pango2/pangodwrite-fontmap.cpp
@@ -75,13 +75,44 @@ struct _Pango2DirectWriteFontMapClass
static Pango2Stretch
util_to_pango2_stretch (DWRITE_FONT_STRETCH stretch)
{
- int value = (int) stretch;
+ Pango2Stretch pango2_stretch = PANGO2_STRETCH_NORMAL;
- if G_UNLIKELY (stretch <= DWRITE_FONT_STRETCH_UNDEFINED ||
- stretch > DWRITE_FONT_STRETCH_ULTRA_EXPANDED)
- return PANGO2_STRETCH_NORMAL;
+ switch (stretch)
+ {
+ case DWRITE_FONT_STRETCH_ULTRA_CONDENSED:
+ pango2_stretch = PANGO2_STRETCH_ULTRA_CONDENSED;
+ break;
+ case DWRITE_FONT_STRETCH_EXTRA_CONDENSED:
+ pango2_stretch = PANGO2_STRETCH_EXTRA_CONDENSED;
+ break;
+ case DWRITE_FONT_STRETCH_CONDENSED:
+ pango2_stretch = PANGO2_STRETCH_CONDENSED;
+ break;
+ case DWRITE_FONT_STRETCH_SEMI_CONDENSED:
+ pango2_stretch = PANGO2_STRETCH_SEMI_CONDENSED;
+ break;
+ case DWRITE_FONT_STRETCH_NORMAL:
+ /* also DWRITE_FONT_STRETCH_MEDIUM */
+ pango2_stretch = PANGO2_STRETCH_NORMAL;
+ break;
+ case DWRITE_FONT_STRETCH_SEMI_EXPANDED:
+ pango2_stretch = PANGO2_STRETCH_SEMI_EXPANDED;
+ break;
+ case DWRITE_FONT_STRETCH_EXPANDED:
+ pango2_stretch = PANGO2_STRETCH_EXPANDED;
+ break;
+ case DWRITE_FONT_STRETCH_EXTRA_EXPANDED:
+ pango2_stretch = PANGO2_STRETCH_EXTRA_EXPANDED;
+ break;
+ case DWRITE_FONT_STRETCH_ULTRA_EXPANDED:
+ pango2_stretch = PANGO2_STRETCH_ULTRA_EXPANDED;
+ break;
+ case DWRITE_FONT_STRETCH_UNDEFINED:
+ default:
+ pango2_stretch = PANGO2_STRETCH_NORMAL;
+ }
- return (Pango2Stretch) --value;
+ return pango2_stretch;
}
static Pango2Style