diff options
| -rw-r--r-- | config.def.h | 8 | ||||
| -rw-r--r-- | st.c | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h index fd09d72..a1e7d5a 100644 --- a/config.def.h +++ b/config.def.h | |||
| @@ -417,3 +417,11 @@ static uint selmasks[] = { | |||
| 417 | [SEL_RECTANGULAR] = Mod1Mask, | 417 | [SEL_RECTANGULAR] = Mod1Mask, |
| 418 | }; | 418 | }; |
| 419 | 419 | ||
| 420 | /* | ||
| 421 | * Printable characters in ASCII, used to estimate the advance width | ||
| 422 | * of single wide characters. | ||
| 423 | */ | ||
| 424 | static char ascii_printable[] = | ||
| 425 | " !\"#$%&'()*+,-./0123456789:;<=>?" | ||
| 426 | "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" | ||
| 427 | "`abcdefghijklmnopqrstuvwxyz{|}~"; | ||
| @@ -68,6 +68,7 @@ char *argv0; | |||
| 68 | #define LEN(a) (sizeof(a) / sizeof(a)[0]) | 68 | #define LEN(a) (sizeof(a) / sizeof(a)[0]) |
| 69 | #define DEFAULT(a, b) (a) = (a) ? (a) : (b) | 69 | #define DEFAULT(a, b) (a) = (a) ? (a) : (b) |
| 70 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) | 70 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) |
| 71 | #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) | ||
| 71 | #define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177') | 72 | #define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177') |
| 72 | #define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) | 73 | #define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) |
| 73 | #define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c)) | 74 | #define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c)) |
| @@ -3277,6 +3278,7 @@ xloadfont(Font *f, FcPattern *pattern) | |||
| 3277 | { | 3278 | { |
| 3278 | FcPattern *match; | 3279 | FcPattern *match; |
| 3279 | FcResult result; | 3280 | FcResult result; |
| 3281 | XGlyphInfo extents; | ||
| 3280 | 3282 | ||
| 3281 | match = FcFontMatch(NULL, pattern, &result); | 3283 | match = FcFontMatch(NULL, pattern, &result); |
| 3282 | if (!match) | 3284 | if (!match) |
| @@ -3287,6 +3289,10 @@ xloadfont(Font *f, FcPattern *pattern) | |||
| 3287 | return 1; | 3289 | return 1; |
| 3288 | } | 3290 | } |
| 3289 | 3291 | ||
| 3292 | XftTextExtentsUtf8(xw.dpy, f->match, | ||
| 3293 | (const FcChar8 *) ascii_printable, | ||
| 3294 | LEN(ascii_printable), &extents); | ||
| 3295 | |||
| 3290 | f->set = NULL; | 3296 | f->set = NULL; |
| 3291 | f->pattern = FcPatternDuplicate(pattern); | 3297 | f->pattern = FcPatternDuplicate(pattern); |
| 3292 | 3298 | ||
| @@ -3296,7 +3302,7 @@ xloadfont(Font *f, FcPattern *pattern) | |||
| 3296 | f->rbearing = f->match->max_advance_width; | 3302 | f->rbearing = f->match->max_advance_width; |
| 3297 | 3303 | ||
| 3298 | f->height = f->ascent + f->descent; | 3304 | f->height = f->ascent + f->descent; |
| 3299 | f->width = f->lbearing + f->rbearing; | 3305 | f->width = DIVCEIL(extents.xOff, LEN(ascii_printable)); |
| 3300 | 3306 | ||
| 3301 | return 0; | 3307 | return 0; |
| 3302 | } | 3308 | } |
