You are not logged in.

#1 2019-03-25 09:46:14

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

[solved] How st is loading glyphs that missing in font

I have installed st and set

static char *font = "Bitstream Vera Sans Mono:pixelsize=11:antialias=true:autohint=true";

I assume that glyphs like powerline arrows missing in Bitstream Vera Sans Mono, because when I used urxvt with this font I needed to add additional font for glyphs (Roboto Mono for Powerline). May be I wrong, because st show glyphs correctly, but unfortunately ugly. So I want to add user defined font for glyphs. I look code in x.c, but find only how st is loading font which assigned to font variable defined in config.h. I'm not good at C yet, so possibly overlook something.

Last edited by Kirill Bugaev (2019-03-25 17:58:28)

Offline

#2 2019-03-25 13:05:44

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,530
Website

Re: [solved] How st is loading glyphs that missing in font

st uses font-config.  If a glyph is missing in a font, font-config can fallback on an alternative font.  I believe the list it would use is the same as what you'd get from `fc-match -s "Bitstream Vera Sans Mono"`.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2019-03-25 17:57:30

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: [solved] How st is loading glyphs that missing in font

Seems like I solve problem by magic way. I have added to config.h

static char *font2 = "Roboto Mono for Powerline:pixelsize=11:antialias=true:autohint=true";

And then to x.c

xinit(int cols, int rows)
{
...
	FcPattern *fontpattern, *match;
	FcResult result;
...
	if (font2[0] == '-')
		fontpattern = XftXlfdParse(font2, False, False);
	else
		fontpattern = FcNameParse((FcChar8 *)font2);
	if (!fontpattern)
		die("can't open font %s\n", font2);
	match = FcFontMatch(NULL, fontpattern, &result);
	frc = xrealloc(frc, sizeof(Fontcache));
	frc[frclen].font = XftFontOpenPattern(xw.dpy, match);
	if (!frc[frclen].font)
		die("XftFontOpenPattern failed seeking font2: %s\n", strerror(errno));
	frc[frclen].flags = FRC_NORMAL;
	frclen++;
	frccap++;
...
}

So I just add font2 to font cache as first entry.

Offline

Board footer

Powered by FluxBB