fontfeature patch
This commit is contained in:
parent
b77fb11b76
commit
4397a1814f
4 changed files with 34 additions and 9 deletions
13
hb.c
13
hb.c
|
|
@ -35,13 +35,6 @@ typedef struct {
|
||||||
static RuneBuffer hbrunebuffer = { 0, NULL };
|
static RuneBuffer hbrunebuffer = { 0, NULL };
|
||||||
static hb_buffer_t *hbbuffer;
|
static hb_buffer_t *hbbuffer;
|
||||||
|
|
||||||
/*
|
|
||||||
* Poplulate the array with a list of font features, wrapped in FEATURE macro,
|
|
||||||
* e. g.
|
|
||||||
* FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
|
|
||||||
*/
|
|
||||||
hb_feature_t features[] = { };
|
|
||||||
|
|
||||||
void
|
void
|
||||||
hbcreatebuffer(void)
|
hbcreatebuffer(void)
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +118,11 @@ hbtransform(HbTransformData *data, XftFont *xfont, const Glyph *glyphs, int star
|
||||||
hb_buffer_add_codepoints(buffer, hbrunebuffer.runes, length, 0, length);
|
hb_buffer_add_codepoints(buffer, hbrunebuffer.runes, length, 0, length);
|
||||||
|
|
||||||
/* Shape the segment. */
|
/* Shape the segment. */
|
||||||
hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
|
#if FONTFEATURES_PATCH
|
||||||
|
hb_shape(font, buffer, data->features, data->features_count);
|
||||||
|
#else
|
||||||
|
hb_shape(font, buffer, NULL, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get new glyph info. */
|
/* Get new glyph info. */
|
||||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, &glyph_count);
|
hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, &glyph_count);
|
||||||
|
|
|
||||||
4
hb.h
4
hb.h
|
|
@ -7,6 +7,10 @@ typedef struct {
|
||||||
hb_glyph_info_t *glyphs;
|
hb_glyph_info_t *glyphs;
|
||||||
hb_glyph_position_t *positions;
|
hb_glyph_position_t *positions;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
#if FONTFEATURES_PATCH
|
||||||
|
hb_feature_t *features;
|
||||||
|
int features_count;
|
||||||
|
#endif // FONTFEATURES_PATCH
|
||||||
} HbTransformData;
|
} HbTransformData;
|
||||||
|
|
||||||
void hbcreatebuffer(void);
|
void hbcreatebuffer(void);
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,11 @@
|
||||||
* https://github.com/cog1to/st-ligatures
|
* https://github.com/cog1to/st-ligatures
|
||||||
* https://st.suckless.org/patches/ligatures/
|
* https://st.suckless.org/patches/ligatures/
|
||||||
*/
|
*/
|
||||||
#define LIGATURES_PATCH 0
|
#define LIGATURES_PATCH 1
|
||||||
|
|
||||||
|
/* This patch add support for custom font features. It depends on the LIGATURES_PATCH patch
|
||||||
|
*/
|
||||||
|
#define FONTFEATURES_PATCH 1
|
||||||
|
|
||||||
/* This patch makes st ignore terminal color attributes by forcing display of the default
|
/* This patch makes st ignore terminal color attributes by forcing display of the default
|
||||||
* foreground and background colors only - making for a monochrome look. Idea ref.
|
* foreground and background colors only - making for a monochrome look. Idea ref.
|
||||||
|
|
|
||||||
20
x.c
20
x.c
|
|
@ -1724,6 +1724,26 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
|
||||||
xp = winx, yp = winy + font->ascent;
|
xp = winx, yp = winy + font->ascent;
|
||||||
#endif // VERTCENTER_PATCH
|
#endif // VERTCENTER_PATCH
|
||||||
cluster_xp = xp; cluster_yp = yp;
|
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. */
|
/* Shape the segment. */
|
||||||
hbtransform(&shaped, font->match, glyphs, 0, len);
|
hbtransform(&shaped, font->match, glyphs, 0, len);
|
||||||
#endif // LIGATURES_PATCH
|
#endif // LIGATURES_PATCH
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue