diff options
| author | Kenichi Handa | 2007-06-20 12:10:07 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2007-06-20 12:10:07 +0000 |
| commit | 91c5bb27e6c8388ef331d88a186f6874d13dba27 (patch) | |
| tree | ddf3cdf3ff63a828ad08c13d41d7c78272277eeb /src | |
| parent | a850be2ef8dc9e38dd7768765c2000d1e6e85f86 (diff) | |
| download | emacs-91c5bb27e6c8388ef331d88a186f6874d13dba27.tar.gz emacs-91c5bb27e6c8388ef331d88a186f6874d13dba27.zip | |
(xftfont_open): If one of font's ASCII glyph has
bigger ascent and descent than those of the font, use them as
font's ascent and descent.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xftfont.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/xftfont.c b/src/xftfont.c index ce648cc018d..af03cc43ecb 100644 --- a/src/xftfont.c +++ b/src/xftfont.c | |||
| @@ -223,6 +223,7 @@ xftfont_open (f, entity, pixel_size) | |||
| 223 | int spacing; | 223 | int spacing; |
| 224 | char *name; | 224 | char *name; |
| 225 | int len; | 225 | int len; |
| 226 | XGlyphInfo extents; | ||
| 226 | 227 | ||
| 227 | val = AREF (entity, FONT_EXTRA_INDEX); | 228 | val = AREF (entity, FONT_EXTRA_INDEX); |
| 228 | if (XTYPE (val) != Lisp_Misc | 229 | if (XTYPE (val) != Lisp_Misc |
| @@ -285,26 +286,24 @@ xftfont_open (f, entity, pixel_size) | |||
| 285 | font->file_name = (char *) file; | 286 | font->file_name = (char *) file; |
| 286 | font->font.size = xftfont->max_advance_width; | 287 | font->font.size = xftfont->max_advance_width; |
| 287 | font->font.charset = font->encoding_charset = font->repertory_charset = -1; | 288 | font->font.charset = font->encoding_charset = font->repertory_charset = -1; |
| 288 | font->ascent = xftfont->ascent; | ||
| 289 | font->descent = xftfont->descent; | ||
| 290 | font->font.height = xftfont->ascent + xftfont->descent; | ||
| 291 | 289 | ||
| 292 | if (FcPatternGetInteger (xftfont->pattern, FC_SPACING, 0, &spacing) | 290 | if (FcPatternGetInteger (xftfont->pattern, FC_SPACING, 0, &spacing) |
| 293 | != FcResultMatch) | 291 | != FcResultMatch) |
| 294 | spacing = FC_PROPORTIONAL; | 292 | spacing = FC_PROPORTIONAL; |
| 293 | if (! ascii_printable[0]) | ||
| 294 | { | ||
| 295 | int i; | ||
| 296 | for (i = 0; i < 95; i++) | ||
| 297 | ascii_printable[i] = ' ' + i; | ||
| 298 | } | ||
| 295 | if (spacing != FC_PROPORTIONAL) | 299 | if (spacing != FC_PROPORTIONAL) |
| 296 | font->font.average_width = font->font.space_width | 300 | { |
| 297 | = xftfont->max_advance_width; | 301 | font->font.average_width = font->font.space_width |
| 302 | = xftfont->max_advance_width; | ||
| 303 | XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); | ||
| 304 | } | ||
| 298 | else | 305 | else |
| 299 | { | 306 | { |
| 300 | XGlyphInfo extents; | ||
| 301 | |||
| 302 | if (! ascii_printable[0]) | ||
| 303 | { | ||
| 304 | int i; | ||
| 305 | for (i = 0; i < 95; i++) | ||
| 306 | ascii_printable[i] = ' ' + i; | ||
| 307 | } | ||
| 308 | XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents); | 307 | XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents); |
| 309 | font->font.space_width = extents.xOff; | 308 | font->font.space_width = extents.xOff; |
| 310 | if (font->font.space_width <= 0) | 309 | if (font->font.space_width <= 0) |
| @@ -315,6 +314,14 @@ xftfont_open (f, entity, pixel_size) | |||
| 315 | } | 314 | } |
| 316 | UNBLOCK_INPUT; | 315 | UNBLOCK_INPUT; |
| 317 | 316 | ||
| 317 | font->ascent = xftfont->ascent; | ||
| 318 | if (font->ascent < extents.y) | ||
| 319 | font->ascent = extents.y; | ||
| 320 | font->descent = xftfont->descent; | ||
| 321 | if (font->descent < extents.height - extents.y) | ||
| 322 | font->descent = extents.height - extents.y; | ||
| 323 | font->font.height = font->ascent + font->descent; | ||
| 324 | |||
| 318 | /* Unfortunately Xft doesn't provide a way to get minimum char | 325 | /* Unfortunately Xft doesn't provide a way to get minimum char |
| 319 | width. So, we use space_width instead. */ | 326 | width. So, we use space_width instead. */ |
| 320 | font->min_width = font->font.space_width; | 327 | font->min_width = font->font.space_width; |
| @@ -326,9 +333,9 @@ xftfont_open (f, entity, pixel_size) | |||
| 326 | 333 | ||
| 327 | /* Setup pseudo XFontStruct */ | 334 | /* Setup pseudo XFontStruct */ |
| 328 | xfont->fid = xftfont_default_fid (f); | 335 | xfont->fid = xftfont_default_fid (f); |
| 329 | xfont->ascent = xftfont->ascent; | 336 | xfont->ascent = font->ascent; |
| 330 | xfont->descent = xftfont->descent; | 337 | xfont->descent = font->descent; |
| 331 | xfont->max_bounds.descent = xftfont->descent; | 338 | xfont->max_bounds.descent = font->descent; |
| 332 | xfont->max_bounds.width = xftfont->max_advance_width; | 339 | xfont->max_bounds.width = xftfont->max_advance_width; |
| 333 | xfont->min_bounds.width = font->font.space_width; | 340 | xfont->min_bounds.width = font->font.space_width; |
| 334 | font->font.font = xfont; | 341 | font->font.font = xfont; |