aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--config.def.h4
-rw-r--r--st.c20
3 files changed, 17 insertions, 8 deletions
diff --git a/TODO b/TODO
index 4fc1346..794b71b 100644
--- a/TODO
+++ b/TODO
@@ -13,7 +13,6 @@ code & interface
13drawing 13drawing
14------- 14-------
15* add diacritics support to xdraws() 15* add diacritics support to xdraws()
16* add kerning configuration
17* make the font cache simpler 16* make the font cache simpler
18* add hard width handling 17* add hard width handling
19 * xft is reporting wrong width and height for characters 18 * xft is reporting wrong width and height for characters
diff --git a/config.def.h b/config.def.h
index 9a3d2c8..8cb8804 100644
--- a/config.def.h
+++ b/config.def.h
@@ -9,6 +9,10 @@ static char font[] = "Liberation Mono:pixelsize=12:antialias=false:autohint=fals
9static int borderpx = 2; 9static int borderpx = 2;
10static char shell[] = "/bin/sh"; 10static char shell[] = "/bin/sh";
11 11
12/* Kerning / character bounding-box mutlipliers */
13float cwscale = 1.0;
14float chscale = 1.0;
15
12/* 16/*
13 * word delimiter string 17 * word delimiter string
14 * 18 *
diff --git a/st.c b/st.c
index 362de23..6756f76 100644
--- a/st.c
+++ b/st.c
@@ -76,6 +76,7 @@ char *argv0;
76#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg) 76#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg)
77#define IS_SET(flag) ((term.mode & (flag)) != 0) 77#define IS_SET(flag) ((term.mode & (flag)) != 0)
78#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.tv_usec)/1000) 78#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.tv_usec)/1000)
79#define CEIL(x) (((x) != (int) (x)) ? (x) + 1 : (x))
79 80
80#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b)) 81#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
81#define IS_TRUECOL(x) (1 << 24 & (x)) 82#define IS_TRUECOL(x) (1 << 24 & (x))
@@ -2777,8 +2778,8 @@ xloadfonts(char *fontstr, int fontsize) {
2777 die("st: can't open font %s\n", fontstr); 2778 die("st: can't open font %s\n", fontstr);
2778 2779
2779 /* Setting character width and height. */ 2780 /* Setting character width and height. */
2780 xw.cw = dc.font.width; 2781 xw.cw = CEIL(dc.font.width * cwscale);
2781 xw.ch = dc.font.height; 2782 xw.ch = CEIL(dc.font.height * chscale);
2782 2783
2783 FcPatternDel(pattern, FC_SLANT); 2784 FcPatternDel(pattern, FC_SLANT);
2784 FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); 2785 FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
@@ -2960,6 +2961,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
2960 Colour *fg, *bg, *temp, revfg, revbg, truefg, truebg; 2961 Colour *fg, *bg, *temp, revfg, revbg, truefg, truebg;
2961 XRenderColor colfg, colbg; 2962 XRenderColor colfg, colbg;
2962 Rectangle r; 2963 Rectangle r;
2964 int oneatatime;
2963 2965
2964 frcflags = FRC_NORMAL; 2966 frcflags = FRC_NORMAL;
2965 2967
@@ -3087,6 +3089,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
3087 u8fs = s; 3089 u8fs = s;
3088 u8fblen = 0; 3090 u8fblen = 0;
3089 u8fl = 0; 3091 u8fl = 0;
3092 oneatatime = font->width != xw.cw;
3090 for(;;) { 3093 for(;;) {
3091 u8c = s; 3094 u8c = s;
3092 u8cblen = utf8decode(s, &u8char); 3095 u8cblen = utf8decode(s, &u8char);
@@ -3094,8 +3097,8 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
3094 bytelen -= u8cblen; 3097 bytelen -= u8cblen;
3095 3098
3096 doesexist = XftCharExists(xw.dpy, font->match, u8char); 3099 doesexist = XftCharExists(xw.dpy, font->match, u8char);
3097 if(!doesexist || bytelen <= 0) { 3100 if(oneatatime || !doesexist || bytelen <= 0) {
3098 if(bytelen <= 0) { 3101 if(oneatatime || bytelen <= 0) {
3099 if(doesexist) { 3102 if(doesexist) {
3100 u8fl++; 3103 u8fl++;
3101 u8fblen += u8cblen; 3104 u8fblen += u8cblen;
@@ -3108,7 +3111,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
3108 winy + font->ascent, 3111 winy + font->ascent,
3109 (FcChar8 *)u8fs, 3112 (FcChar8 *)u8fs,
3110 u8fblen); 3113 u8fblen);
3111 xp += font->width * u8fl; 3114 xp += CEIL(font->width * cwscale * u8fl);
3112 3115
3113 } 3116 }
3114 break; 3117 break;
@@ -3117,8 +3120,11 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
3117 u8fl++; 3120 u8fl++;
3118 u8fblen += u8cblen; 3121 u8fblen += u8cblen;
3119 } 3122 }
3120 if(doesexist) 3123 if(doesexist) {
3124 if (oneatatime);
3125 continue;
3121 break; 3126 break;
3127 }
3122 3128
3123 /* Search the font cache. */ 3129 /* Search the font cache. */
3124 for(i = 0; i < frclen; i++) { 3130 for(i = 0; i < frclen; i++) {
@@ -3178,7 +3184,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
3178 xp, winy + frc[i].font->ascent, 3184 xp, winy + frc[i].font->ascent,
3179 (FcChar8 *)u8c, u8cblen); 3185 (FcChar8 *)u8c, u8cblen);
3180 3186
3181 xp += font->width; 3187 xp += CEIL(font->width * cwscale);
3182 } 3188 }
3183 3189
3184 /* 3190 /*