diff options
| author | Chong Yidong | 2012-08-16 14:35:13 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-08-16 14:35:13 +0800 |
| commit | 032a42c88d421ee434e783e29bf2cde3d6a81e7b (patch) | |
| tree | 24fa7910668c8e4c92da4cd50d753a9a0358c64d | |
| parent | 1c308380b6f29e389dc10d418b9203a74d64dce2 (diff) | |
| download | emacs-032a42c88d421ee434e783e29bf2cde3d6a81e7b.tar.gz emacs-032a42c88d421ee434e783e29bf2cde3d6a81e7b.zip | |
For Xft and X font backends, set omitted max_width font fields.
* src/xfont.c (xfont_open):
* src/xftfont.c (xftfont_open): Set the font's max_width field.
* src/font.h (struct font): Update comments.
| -rw-r--r-- | src/ChangeLog | 15 | ||||
| -rw-r--r-- | src/font.h | 12 | ||||
| -rw-r--r-- | src/xfont.c | 1 | ||||
| -rw-r--r-- | src/xftfont.c | 17 |
4 files changed, 31 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 27527dbb934..54215f59f8e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,6 +1,19 @@ | |||
| 1 | 2012-08-16 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * xfont.c (xfont_open): | ||
| 4 | * xftfont.c (xftfont_open): Set the font's max_width field. | ||
| 5 | |||
| 6 | * nsfont.m (nsfont_open): Similar to the Xft backend, set | ||
| 7 | min_width to space_width and average_width to the average over | ||
| 8 | printable ASCII characters. | ||
| 9 | (ns_char_width): Code cleanup. | ||
| 10 | (ns_ascii_average_width): New utility function. | ||
| 11 | |||
| 12 | * font.h (struct font): Update comments. | ||
| 13 | |||
| 1 | 2012-08-16 Dmitry Antipov <dmantipov@yandex.ru> | 14 | 2012-08-16 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 15 | ||
| 3 | Simple interface to set Lisp_Object fields of chararcter tables. | 16 | Simple interface to set Lisp_Object fields of character tables. |
| 4 | * lisp.h (CSET): New macro. | 17 | * lisp.h (CSET): New macro. |
| 5 | (char_table_set_extras, char_table_set_contents) | 18 | (char_table_set_extras, char_table_set_contents) |
| 6 | (sub_char_table_set_contents): New function. | 19 | (sub_char_table_set_contents): New function. |
diff --git a/src/font.h b/src/font.h index 3e9af6df235..6e9387f7632 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -284,8 +284,11 @@ struct font | |||
| 284 | 284 | ||
| 285 | /* Beyond here, there should be no more Lisp_Object components. */ | 285 | /* Beyond here, there should be no more Lisp_Object components. */ |
| 286 | 286 | ||
| 287 | /* Maximum bound width over all existing characters of the font. On | 287 | /* Minimum and maximum glyph widths, in pixels. Some font backends, |
| 288 | X window, this is same as (font->max_bounds.width). */ | 288 | such as xft, lack the information to easily compute minimum and |
| 289 | maximum widths over all characters; in that case, these values | ||
| 290 | are approximate. */ | ||
| 291 | int min_width; | ||
| 289 | int max_width; | 292 | int max_width; |
| 290 | 293 | ||
| 291 | /* By which pixel size the font is opened. */ | 294 | /* By which pixel size the font is opened. */ |
| @@ -301,13 +304,10 @@ struct font | |||
| 301 | 304 | ||
| 302 | /* Average width of glyphs in the font. If the font itself doesn't | 305 | /* Average width of glyphs in the font. If the font itself doesn't |
| 303 | have that information but has glyphs of ASCII characters, the | 306 | have that information but has glyphs of ASCII characters, the |
| 304 | value is the average with of those glyphs. Otherwise, the value | 307 | value is the average width of those glyphs. Otherwise, the value |
| 305 | is 0. */ | 308 | is 0. */ |
| 306 | int average_width; | 309 | int average_width; |
| 307 | 310 | ||
| 308 | /* Minimum glyph width (in pixels). */ | ||
| 309 | int min_width; | ||
| 310 | |||
| 311 | /* Ascent and descent of the font (in pixels). */ | 311 | /* Ascent and descent of the font (in pixels). */ |
| 312 | int ascent, descent; | 312 | int ascent, descent; |
| 313 | 313 | ||
diff --git a/src/xfont.c b/src/xfont.c index 9e929eed678..072bce7bb0a 100644 --- a/src/xfont.c +++ b/src/xfont.c | |||
| @@ -823,6 +823,7 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) | |||
| 823 | font->descent = xfont->descent; | 823 | font->descent = xfont->descent; |
| 824 | font->height = font->ascent + font->descent; | 824 | font->height = font->ascent + font->descent; |
| 825 | font->min_width = xfont->min_bounds.width; | 825 | font->min_width = xfont->min_bounds.width; |
| 826 | font->max_width = xfont->max_bounds.width; | ||
| 826 | if (xfont->min_bounds.width == xfont->max_bounds.width) | 827 | if (xfont->min_bounds.width == xfont->max_bounds.width) |
| 827 | { | 828 | { |
| 828 | /* Fixed width font. */ | 829 | /* Fixed width font. */ |
diff --git a/src/xftfont.c b/src/xftfont.c index 2f8125393bc..34c6a8fa0b4 100644 --- a/src/xftfont.c +++ b/src/xftfont.c | |||
| @@ -414,20 +414,25 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) | |||
| 414 | ascii_printable[ch] = ' ' + ch; | 414 | ascii_printable[ch] = ' ' + ch; |
| 415 | } | 415 | } |
| 416 | BLOCK_INPUT; | 416 | BLOCK_INPUT; |
| 417 | |||
| 418 | /* Unfortunately Xft doesn't provide a way to get minimum char | ||
| 419 | width. So, we set min_width to space_width. */ | ||
| 420 | |||
| 417 | if (spacing != FC_PROPORTIONAL | 421 | if (spacing != FC_PROPORTIONAL |
| 418 | #ifdef FC_DUAL | 422 | #ifdef FC_DUAL |
| 419 | && spacing != FC_DUAL | 423 | && spacing != FC_DUAL |
| 420 | #endif /* FC_DUAL */ | 424 | #endif /* FC_DUAL */ |
| 421 | ) | 425 | ) |
| 422 | { | 426 | { |
| 423 | font->min_width = font->average_width = font->space_width | 427 | font->min_width = font->max_width = font->average_width |
| 424 | = xftfont->max_advance_width; | 428 | = font->space_width = xftfont->max_advance_width; |
| 425 | XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); | 429 | XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); |
| 426 | } | 430 | } |
| 427 | else | 431 | else |
| 428 | { | 432 | { |
| 429 | XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents); | 433 | XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents); |
| 430 | font->space_width = extents.xOff; | 434 | font->min_width = font->max_width = font->space_width |
| 435 | = extents.xOff; | ||
| 431 | if (font->space_width <= 0) | 436 | if (font->space_width <= 0) |
| 432 | /* dirty workaround */ | 437 | /* dirty workaround */ |
| 433 | font->space_width = pixel_size; | 438 | font->space_width = pixel_size; |
| @@ -470,10 +475,6 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) | |||
| 470 | #endif /* HAVE_LIBOTF */ | 475 | #endif /* HAVE_LIBOTF */ |
| 471 | xftfont_info->ft_size = ft_face->size; | 476 | xftfont_info->ft_size = ft_face->size; |
| 472 | 477 | ||
| 473 | /* Unfortunately Xft doesn't provide a way to get minimum char | ||
| 474 | width. So, we use space_width instead. */ | ||
| 475 | font->min_width = font->space_width; | ||
| 476 | |||
| 477 | font->baseline_offset = 0; | 478 | font->baseline_offset = 0; |
| 478 | font->relative_compose = 0; | 479 | font->relative_compose = 0; |
| 479 | font->default_ascent = 0; | 480 | font->default_ascent = 0; |
| @@ -764,6 +765,8 @@ syms_of_xftfont (void) | |||
| 764 | DEFSYM (QCembolden, ":embolden"); | 765 | DEFSYM (QCembolden, ":embolden"); |
| 765 | DEFSYM (QClcdfilter, ":lcdfilter"); | 766 | DEFSYM (QClcdfilter, ":lcdfilter"); |
| 766 | 767 | ||
| 768 | ascii_printable[0] = 0; | ||
| 769 | |||
| 767 | xftfont_driver = ftfont_driver; | 770 | xftfont_driver = ftfont_driver; |
| 768 | xftfont_driver.type = Qxft; | 771 | xftfont_driver.type = Qxft; |
| 769 | xftfont_driver.get_cache = xfont_driver.get_cache; | 772 | xftfont_driver.get_cache = xfont_driver.get_cache; |