Use Xft returned font metrics instead of freetype ones, as the
freetype metrics do not take into account the scaling applied by Xft.
Add an emoji character in the list used for width computation when
UNICODE3 is enabled.
This, combined with currently pending support for bgra glyphs in
libXft enables color emoji in rxvt-unicode.
---
src/rxvtfont.C | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/rxvtfont.C b/src/rxvtfont.C
index c56921c8..18f79d0e 100644
--- a/src/rxvtfont.C
+++ b/src/rxvtfont.C
@@ -154,10 +154,13 @@ static const struct rxvt_fallback_font {
// these characters are used to guess the font height and width
// pango uses a similar algorithm and doesn't trust the font either.
-static uint16_t extent_test_chars[] = {
+static text_t extent_test_chars[] = {
'0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_',
0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ
0x304c, 0x672c, // が本
+#if UNICODE_3
+ 0x1f604, // ?
+#endif
};
#define dTermDisplay Display *disp = term->dpy
@@ -926,7 +929,7 @@ rxvt_font_x11::load (const rxvt_fontprop &prop, bool
force_prop)
width = 1;
- for (uint16_t *t = extent_test_chars; t < extent_test_chars +
ecb_array_length (extent_test_chars); t++)
+ for (text_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length
(extent_test_chars); t++)
{
if (FROM_UNICODE (cs, *t) == NOCHAR)
continue;
@@ -1239,9 +1242,9 @@ rxvt_font_xft::load (const rxvt_fontprop &prop, bool
force_prop)
FT_Face face = XftLockFace (f);
- ascent = (face->size->metrics.ascender + 63) >> 6;
- descent = (-face->size->metrics.descender + 63) >> 6;
- height = max (ascent + descent, (face->size->metrics.height + 63) >> 6);
+ ascent = f->ascent;
+ descent = f->descent;
+ height = max (ascent + descent, f->height);
width = 0;
bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE;
@@ -1250,9 +1253,9 @@ rxvt_font_xft::load (const rxvt_fontprop &prop, bool
force_prop)
int glheight = height;
- for (uint16_t *t = extent_test_chars; t < extent_test_chars +
ecb_array_length (extent_test_chars); t++)
+ for (text_t *t = extent_test_chars; t < extent_test_chars +
ecb_array_length (extent_test_chars); t++)
{
- FcChar16 ch = *t;
+ text_t ch = *t;
if (cs != CS_UNICODE
&& ch > 0x100
@@ -1265,7 +1268,11 @@ rxvt_font_xft::load (const rxvt_fontprop &prop, bool
force_prop)
continue;
XGlyphInfo g;
+#if UNICODE_3
+ XftTextExtents32 (disp, f, &ch, 1, &g);
+#else
XftTextExtents16 (disp, f, &ch, 1, &g);
+#endif
g.width -= g.x;
--
2.24.0
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/rxvt-unicode