[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9ed03040d5: Make average width computation on ftcr more permissiv
From: |
YAMAMOTO Mitsuharu |
Subject: |
master 9ed03040d5: Make average width computation on ftcr more permissive (Bug#43058) |
Date: |
Sun, 25 Sep 2022 20:58:48 -0400 (EDT) |
branch: master
commit 9ed03040d5bfb228c8d41f1df44e74a824d0cd44
Author: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Commit: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Make average width computation on ftcr more permissive (Bug#43058)
* src/ftcrfont.c (ftcrfont_open): Use only non-zero width glyphs for
computing average width.
---
src/ftcrfont.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index a02ff99870..dc765e5aee 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -233,6 +233,7 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int
pixel_size)
cairo_glyph_t stack_glyph;
font->min_width = font->max_width = 0;
font->average_width = font->space_width = 0;
+ int n = 0;
for (char c = 32; c < 127; c++)
{
cairo_glyph_t *glyphs = &stack_glyph;
@@ -252,17 +253,20 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int
pixel_size)
stack_glyph.index = 0;
}
int this_width = ftcrfont_glyph_extents (font, stack_glyph.index, NULL);
- if (this_width > 0
- && (! font->min_width
- || font->min_width > this_width))
- font->min_width = this_width;
- if (this_width > font->max_width)
- font->max_width = this_width;
- if (c == 32)
- font->space_width = this_width;
- font->average_width += this_width;
+ if (this_width > 0)
+ {
+ if (! font->min_width || font->min_width > this_width)
+ font->min_width = this_width;
+ if (this_width > font->max_width)
+ font->max_width = this_width;
+ if (c == 32)
+ font->space_width = this_width;
+ font->average_width += this_width;
+ n++;
+ }
}
- font->average_width /= 95;
+ if (n)
+ font->average_width /= n;
cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents);
font->ascent = lround (extents.ascent);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 9ed03040d5: Make average width computation on ftcr more permissive (Bug#43058),
YAMAMOTO Mitsuharu <=