Commit 86516a45 authored by Matthias Clasen's avatar Matthias Clasen

Merge branch 'font-pattern-getter' into 'master'

Font pattern getter

See merge request !245
parents 218aad0f ecbe132a
Pipeline #215478 passed with stages
in 2 minutes and 28 seconds
......@@ -1015,6 +1015,7 @@ pango_fc_font_get_glyph
pango_fc_font_get_unknown_glyph
pango_fc_font_kern_glyphs
pango_fc_font_get_languages
pango_fc_font_get_pattern
<SUBSECTION Standard>
PANGO_FC_FONT
PANGO_IS_FC_FONT
......
......@@ -1067,3 +1067,19 @@ pango_fc_font_get_languages (PangoFcFont *font)
return languages;
}
/**
* pango_fc_font_get_pattern:
* @font: a #PangoFcFont
*
* Returns the FcPattern that @font is based on.
*
* Returns: the fontconfig pattern for this font
*
* Since: 1.48
*/
FcPattern *
pango_fc_font_get_pattern (PangoFcFont *font)
{
return font->font_pattern;
}
......@@ -98,6 +98,9 @@ PANGO_AVAILABLE_IN_1_48
PangoLanguage **
pango_fc_font_get_languages (PangoFcFont *font);
PANGO_AVAILABLE_IN_1_48
FcPattern *pango_fc_font_get_pattern (PangoFcFont *font);
PANGO_DEPRECATED_FOR(PANGO_GET_UNKNOWN_GLYPH)
PangoGlyph pango_fc_font_get_unknown_glyph (PangoFcFont *font,
gunichar wc);
......@@ -110,5 +113,6 @@ FT_Face pango_fc_font_lock_face (PangoFcFont *font);
PANGO_DEPRECATED_IN_1_44_FOR(pango_font_get_hb_font)
void pango_fc_font_unlock_face (PangoFcFont *font);
G_END_DECLS
#endif /* __PANGO_FC_FONT_H__ */
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment