tUse character size scaling factors - st - [fork] customized build of st, the s… | |
git clone git://src.adamsgaard.dk/st | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 7e3cff33ffbd69a112fa4071a9f0ed2dc93bfc57 | |
parent aaee0e8b28a353c215b6d1c8fc06d20038d7b426 | |
Author: Eric Pruitt <[email protected]> | |
Date: Mon, 5 Aug 2013 11:33:37 +0200 | |
Use character size scaling factors | |
The bounding boxes for characters can be scaled using "cwscale" and "chscale" | |
tto scale the width and height respectively. | |
Diffstat: | |
M TODO | 1 - | |
M config.def.h | 4 ++++ | |
M st.c | 20 +++++++++++++------- | |
3 files changed, 17 insertions(+), 8 deletions(-) | |
--- | |
diff --git a/TODO b/TODO | |
t@@ -13,7 +13,6 @@ code & interface | |
drawing | |
------- | |
* add diacritics support to xdraws() | |
-* add kerning configuration | |
* make the font cache simpler | |
* add hard width handling | |
* xft is reporting wrong width and height for characters | |
diff --git a/config.def.h b/config.def.h | |
t@@ -9,6 +9,10 @@ static char font[] = "Liberation Mono:pixelsize=12:antialias=… | |
static int borderpx = 2; | |
static char shell[] = "/bin/sh"; | |
+/* Kerning / character bounding-box mutlipliers */ | |
+float cwscale = 1.0; | |
+float chscale = 1.0; | |
+ | |
/* | |
* word delimiter string | |
* | |
diff --git a/st.c b/st.c | |
t@@ -76,6 +76,7 @@ char *argv0; | |
#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (… | |
#define IS_SET(flag) ((term.mode & (flag)) != 0) | |
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.tv_usec)… | |
+#define CEIL(x) (((x) != (int) (x)) ? (x) + 1 : (x)) | |
#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b)) | |
#define IS_TRUECOL(x) (1 << 24 & (x)) | |
t@@ -2777,8 +2778,8 @@ xloadfonts(char *fontstr, int fontsize) { | |
die("st: can't open font %s\n", fontstr); | |
/* Setting character width and height. */ | |
- xw.cw = dc.font.width; | |
- xw.ch = dc.font.height; | |
+ xw.cw = CEIL(dc.font.width * cwscale); | |
+ xw.ch = CEIL(dc.font.height * chscale); | |
FcPatternDel(pattern, FC_SLANT); | |
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); | |
t@@ -2960,6 +2961,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, i… | |
Colour *fg, *bg, *temp, revfg, revbg, truefg, truebg; | |
XRenderColor colfg, colbg; | |
Rectangle r; | |
+ int oneatatime; | |
frcflags = FRC_NORMAL; | |
t@@ -3087,6 +3089,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, i… | |
u8fs = s; | |
u8fblen = 0; | |
u8fl = 0; | |
+ oneatatime = font->width != xw.cw; | |
for(;;) { | |
u8c = s; | |
u8cblen = utf8decode(s, &u8char); | |
t@@ -3094,8 +3097,8 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, i… | |
bytelen -= u8cblen; | |
doesexist = XftCharExists(xw.dpy, font->match, u8char); | |
- if(!doesexist || bytelen <= 0) { | |
- if(bytelen <= 0) { | |
+ if(oneatatime || !doesexist || bytelen <= 0) { | |
+ if(oneatatime || bytelen <= 0) { | |
if(doesexist) { | |
u8fl++; | |
u8fblen += u8cblen; | |
t@@ -3108,7 +3111,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, i… | |
winy + font->ascent, | |
(FcChar8 *)u8fs, | |
u8fblen); | |
- xp += font->width * u8fl; | |
+ xp += CEIL(font->width * cwscale * u8f… | |
} | |
break; | |
t@@ -3117,8 +3120,11 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, … | |
u8fl++; | |
u8fblen += u8cblen; | |
} | |
- if(doesexist) | |
+ if(doesexist) { | |
+ if (oneatatime); | |
+ continue; | |
break; | |
+ } | |
/* Search the font cache. */ | |
for(i = 0; i < frclen; i++) { | |
t@@ -3178,7 +3184,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, i… | |
xp, winy + frc[i].font->ascent, | |
(FcChar8 *)u8c, u8cblen); | |
- xp += font->width; | |
+ xp += CEIL(font->width * cwscale); | |
} | |
/* |