diff options
| author | YAMAMOTO Mitsuharu | 2019-06-22 15:33:32 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2019-06-22 15:33:32 +0900 |
| commit | 27d28d43d12999cf04d823ec9e08228d1b862a49 (patch) | |
| tree | be14c15d36c35853ff2618987a1a7f3c9fde12bf | |
| parent | a0797d32c95948d8b5800c5771026dee3903729c (diff) | |
| download | emacs-27d28d43d12999cf04d823ec9e08228d1b862a49.tar.gz emacs-27d28d43d12999cf04d823ec9e08228d1b862a49.zip | |
Make ftcr font backend driver more consistent with xft
* src/ftcrfont.c (ftcrfont_open): Use metrics of glyph ID 0 if there is no
glyph for an ASCII printable.
| -rw-r--r-- | src/ftcrfont.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/ftcrfont.c b/src/ftcrfont.c index a019fe8294a..0cc40b4c944 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c | |||
| @@ -187,7 +187,6 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 187 | 187 | ||
| 188 | block_input (); | 188 | block_input (); |
| 189 | cairo_glyph_t stack_glyph; | 189 | cairo_glyph_t stack_glyph; |
| 190 | int n = 0; | ||
| 191 | font->min_width = font->average_width = font->space_width = 0; | 190 | font->min_width = font->average_width = font->space_width = 0; |
| 192 | for (char c = 32; c < 127; c++) | 191 | for (char c = 32; c < 127; c++) |
| 193 | { | 192 | { |
| @@ -198,28 +197,25 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 198 | 0, 0, &c, 1, &glyphs, &num_glyphs, | 197 | 0, 0, &c, 1, &glyphs, &num_glyphs, |
| 199 | NULL, NULL, NULL); | 198 | NULL, NULL, NULL); |
| 200 | 199 | ||
| 201 | if (status == CAIRO_STATUS_SUCCESS) | 200 | /* In order to simulate the Xft behavior, we use metrics of |
| 201 | glyph ID 0 if there is no glyph for an ASCII printable. */ | ||
| 202 | if (status != CAIRO_STATUS_SUCCESS) | ||
| 203 | stack_glyph.index = 0; | ||
| 204 | else if (glyphs != &stack_glyph) | ||
| 202 | { | 205 | { |
| 203 | if (glyphs != &stack_glyph) | 206 | cairo_glyph_free (glyphs); |
| 204 | cairo_glyph_free (glyphs); | 207 | stack_glyph.index = 0; |
| 205 | else if (stack_glyph.index) | ||
| 206 | { | ||
| 207 | int this_width = ftcrfont_glyph_extents (font, stack_glyph.index, | ||
| 208 | NULL); | ||
| 209 | |||
| 210 | if (this_width > 0 | ||
| 211 | && (! font->min_width | ||
| 212 | || font->min_width > this_width)) | ||
| 213 | font->min_width = this_width; | ||
| 214 | if (c == 32) | ||
| 215 | font->space_width = this_width; | ||
| 216 | font->average_width += this_width; | ||
| 217 | n++; | ||
| 218 | } | ||
| 219 | } | 208 | } |
| 209 | int this_width = ftcrfont_glyph_extents (font, stack_glyph.index, NULL); | ||
| 210 | if (this_width > 0 | ||
| 211 | && (! font->min_width | ||
| 212 | || font->min_width > this_width)) | ||
| 213 | font->min_width = this_width; | ||
| 214 | if (c == 32) | ||
| 215 | font->space_width = this_width; | ||
| 216 | font->average_width += this_width; | ||
| 220 | } | 217 | } |
| 221 | if (n > 0) | 218 | font->average_width /= 95; |
| 222 | font->average_width /= n; | ||
| 223 | 219 | ||
| 224 | cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents); | 220 | cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents); |
| 225 | font->ascent = lround (extents.ascent); | 221 | font->ascent = lround (extents.ascent); |