[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cairo font selection for Ethiopic
From: |
YAMAMOTO Mitsuharu |
Subject: |
Re: Cairo font selection for Ethiopic |
Date: |
Fri, 21 Jun 2019 10:54:03 +0900 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/25.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
On Fri, 21 Jun 2019 04:30:09 +0900,
Stephen Berman wrote:
>
> I don't know if this is a bug or just the way Cairo works. On two
> different GNU/Linux systems I have built Emacs both --with-cairo and
> without. The non-Cairo builds use Xft as the font backend. On those
> builds the Ethiopic scripts (Amharic and Tigrinya) in HELLO are
> displayed with the Goha-Tibeb Zemen font. In the Cairo builds this font
> is not used for these scripts; instead, on one system they are displayed
> with a mix of GNU Unifont and mutt-clearlyu, and on the other system,
> which lacks these fonts, only hex boxes are displayed. Is there
> something about Goha-Tibeb Zemen that is incompatible with Cairo?
Goha-Tibeb Zemen does not have glyphs for ASCII printables that the
ftcr font backend relies on computing minimum/average/space width when
opening the font. The patch below should simulate the Xft behavior.
YAMAMOTO Mitsuharu
address@hidden
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)
block_input ();
cairo_glyph_t stack_glyph;
- int n = 0;
font->min_width = font->average_width = font->space_width = 0;
for (char c = 32; c < 127; c++)
{
@@ -198,28 +197,25 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int
pixel_size)
0, 0, &c, 1, &glyphs, &num_glyphs,
NULL, NULL, NULL);
- if (status == CAIRO_STATUS_SUCCESS)
+ /* In order to simulate the Xft behavior, we use metrics of
+ glyph ID 0 if there is no glyph for an ASCII printable. */
+ if (status != CAIRO_STATUS_SUCCESS)
+ stack_glyph.index = 0;
+ else if (glyphs != &stack_glyph)
{
- if (glyphs != &stack_glyph)
- cairo_glyph_free (glyphs);
- else if (stack_glyph.index)
- {
- 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 (c == 32)
- font->space_width = this_width;
- font->average_width += this_width;
- n++;
- }
+ cairo_glyph_free (glyphs);
+ 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 (c == 32)
+ font->space_width = this_width;
+ font->average_width += this_width;
}
- if (n > 0)
- font->average_width /= n;
+ font->average_width /= 95;
cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents);
font->ascent = lround (extents.ascent);
- Cairo font selection for Ethiopic, Stephen Berman, 2019/06/20
- Re: Cairo font selection for Ethiopic,
YAMAMOTO Mitsuharu <=
- Re: Cairo font selection for Ethiopic, Stephen Berman, 2019/06/21
- Re: Cairo font selection for Ethiopic, mituharu, 2019/06/21
- Re: Cairo font selection for Ethiopic, Stephen Berman, 2019/06/21
- Re: Cairo font selection for Ethiopic, YAMAMOTO Mitsuharu, 2019/06/21
- Re: Cairo font selection for Ethiopic, Stephen Berman, 2019/06/22
- Re: Cairo font selection for Ethiopic, mituharu, 2019/06/22
- Re: Cairo font selection for Ethiopic, Stephen Berman, 2019/06/22