diff options
Diffstat (limited to '')
| -rw-r--r-- | st.c | 8 |
1 files changed, 7 insertions, 1 deletions
| @@ -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 | } |
