diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-09-21 19:08:08 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-09-21 19:08:08 +0000 |
commit | 86516a454fb71b1a6564b4e76174503711eed05b (patch) | |
tree | 40eb6b8c10b47a56d686f5ac64ee5fb9f678a2fe /pango/pangofc-fontmap.c | |
parent | 218aad0fc1d9823b2b8ea4c91da534982f6ddb0c (diff) | |
parent | ecbe132ad8127a659ec86aade121a1f4356bf5cd (diff) | |
download | pango-86516a454fb71b1a6564b4e76174503711eed05b.tar.gz |
Merge branch 'font-pattern-getter' into 'master'
Font pattern getter
See merge request GNOME/pango!245
Diffstat (limited to 'pango/pangofc-fontmap.c')
-rw-r--r-- | pango/pangofc-fontmap.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index e120d305..0f211c46 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -2805,6 +2805,32 @@ create_face (PangoFcFamily *fcfamily, return face; } +static int +compare_face (const void *p1, const void *p2) +{ + const PangoFcFace *f1 = *(const void **)p1; + const PangoFcFace *f2 = *(const void **)p2; + int w1, w2; + int s1, s2; + + if (FcPatternGetInteger (f1->pattern, FC_WEIGHT, 0, &w1) != FcResultMatch) + w1 = FC_WEIGHT_MEDIUM; + + if (FcPatternGetInteger (f1->pattern, FC_SLANT, 0, &s1) != FcResultMatch) + s1 = FC_SLANT_ROMAN; + + if (FcPatternGetInteger (f2->pattern, FC_WEIGHT, 0, &w2) != FcResultMatch) + w2 = FC_WEIGHT_MEDIUM; + + if (FcPatternGetInteger (f2->pattern, FC_SLANT, 0, &s2) != FcResultMatch) + s2 = FC_SLANT_ROMAN; + + if (s1 != s2) + return s1 - s2; /* roman < italic < oblique */ + + return w1 - w2; /* from light to heavy */ +} + static void ensure_faces (PangoFcFamily *fcfamily) { @@ -2914,6 +2940,8 @@ ensure_faces (PangoFcFamily *fcfamily) faces = g_renew (PangoFcFace *, faces, num); + qsort (faces, num, sizeof (PangoFcFace *), compare_face); + fcfamily->n_faces = num; fcfamily->faces = faces; } |