fontfeature patch

This commit is contained in:
ant 2025-01-04 21:59:53 +01:00
parent 37bc089f1d
commit ec1b8b0ac0
4 changed files with 34 additions and 9 deletions

20
x.c
View file

@ -1770,6 +1770,26 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
xp = winx, yp = winy + font->ascent;
#endif // VERTCENTER_PATCH
cluster_xp = xp; cluster_yp = yp;
#if FONTFEATURES_PATCH
{ // Get font features
shaped.features = (hb_feature_t *) malloc(sizeof(hb_feature_t) * 128);
FcChar8 *s;
int feature_idx = 0;
while (FcPatternGetString(font->pattern, FC_FONT_FEATURES, feature_idx, &s) == FcResultMatch) {
if (strlen(s) != 4)
die("Invalid font feature tag");
if (feature_idx >= 128)
die("Too many font features");
shaped.features[feature_idx].tag = HB_TAG(s[0], s[1], s[2], s[3]);
shaped.features[feature_idx].value = 1;
shaped.features[feature_idx].start = HB_FEATURE_GLOBAL_START;
shaped.features[feature_idx].end = HB_FEATURE_GLOBAL_END;
feature_idx++;
}
shaped.features_count = feature_idx;
}
#endif // FONTFEATURES_PATCH
/* Shape the segment. */
hbtransform(&shaped, font->match, glyphs, 0, len);
#endif // LIGATURES_PATCH