From 1ab69630dcb8c7a1b1b4171211a7c8ebf11b0d1c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Sun, 2 Jun 2019 13:18:39 +0900 Subject: [PATCH] Make fthbfont and derivatives use common HarfBuzz code in hbfont.c * src/font.h (fthbfont_shape, fthbfont_combining_capability) [HAVE_HARFBUZZ]: Remove prototypes. * src/ftfont.c: Don't include math.h. (uni_combining, uni_general, uni_mirroring, get_hb_unicode_funcs) (fthbfont_shape_by_hb, fthbfont_combining_capability, fthbfont_shape) [HAVE_HARFBUZZ]: Remove functions. * src/ftfont.c (syms_of_ftfont_for_pdumper) [HAVE_HARFBUZZ]: * src/xftfont.c (syms_of_xftfont_for_pdumper) [HAVE_HARFBUZZ]: * src/ftcrfont.c (syms_of_ftcrfont_for_pdumper) [HAVE_HARFBUZZ]: Use hbfont_shape and hbfont_combining_capability for fthbfont_shape and fthbfont_combining_capability, respectively. --- configure.ac | 7 +++++++ src/ftcrfont.c | 6 +++--- src/ftfont.c | 30 +++++++++++++++++++++++++----- src/ftxfont.c | 2 +- src/xftfont.c | 2 +- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index b228571c177..bd51f54212c 100644 --- a/configure.ac +++ b/configure.ac @@ -3413,6 +3413,13 @@ if test "${HAVE_X11}" = "yes"; then if test "${HAVE_FREETYPE}" = "yes"; then AC_DEFINE(HAVE_FREETYPE, 1, [Define to 1 if using the freetype and fontconfig libraries.]) + OLD_CFLAGS=$CFLAGS + OLD_LIBS=$LIBS + CFLAGS="$CFLAGS $FREETYPE_CFLAGS" + LIBS="$FREETYPE_LIBS $LIBS" + AC_CHECK_FUNCS(FT_Face_GetCharVariantIndex) + CFLAGS=$OLD_CFLAGS + LIBS=$OLD_LIBS if test "${with_libotf}" != "no"; then EMACS_CHECK_MODULES([LIBOTF], [libotf]) if test "$HAVE_LIBOTF" = "yes"; then diff --git a/src/ftcrfont.c b/src/ftcrfont.c index 0c3b74ff289..1c28a7ceb67 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -455,7 +455,7 @@ ftcrfont_shape (Lisp_Object lgstring, Lisp_Object direction) } #endif -#ifdef HAVE_OTF_GET_VARIATION_GLYPHS +#if defined HAVE_OTF_GET_VARIATION_GLYPHS || defined HAVE_FT_FACE_GETCHARVARIANTINDEX static int ftcrfont_variation_glyphs (struct font *font, int c, unsigned variations[256]) { @@ -470,7 +470,7 @@ ftcrfont_variation_glyphs (struct font *font, int c, unsigned variations[256]) return result; } -#endif /* HAVE_OTF_GET_VARIATION_GLYPHS */ +#endif /* HAVE_OTF_GET_VARIATION_GLYPHS || HAVE_FT_FACE_GETCHARVARIANTINDEX */ static int ftcrfont_draw (struct glyph_string *s, @@ -583,7 +583,7 @@ struct font_driver const ftcrfont_driver = #if defined HAVE_M17N_FLT && defined HAVE_LIBOTF .shape = ftcrfont_shape, #endif -#ifdef HAVE_OTF_GET_VARIATION_GLYPHS +#if defined HAVE_OTF_GET_VARIATION_GLYPHS || defined HAVE_FT_FACE_GETCHARVARIANTINDEX .get_variation_glyphs = ftcrfont_variation_glyphs, #endif .filter_properties = ftfont_filter_properties, diff --git a/src/ftfont.c b/src/ftfont.c index 97ab4d0e377..efd0fcbd8c0 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -2820,21 +2820,41 @@ ftfont_shape (Lisp_Object lgstring, Lisp_Object direction) #endif /* HAVE_M17N_FLT */ -#ifdef HAVE_OTF_GET_VARIATION_GLYPHS +#endif /* HAVE_LIBOTF */ +#if defined HAVE_OTF_GET_VARIATION_GLYPHS || defined HAVE_FT_FACE_GETCHARVARIANTINDEX int ftfont_variation_glyphs (struct font *font, int c, unsigned variations[256]) { struct font_info *ftfont_info = (struct font_info *) font; +#ifdef HAVE_OTF_GET_VARIATION_GLYPHS OTF *otf = ftfont_get_otf (ftfont_info); if (! otf) return 0; return OTF_get_variation_glyphs (otf, c, variations); -} +#else /* !HAVE_OTF_GET_VARIATION_GLYPHS */ + FT_Face ft_face = ftfont_info->ft_size->face; + int i, n = 0; -#endif /* HAVE_OTF_GET_VARIATION_GLYPHS */ -#endif /* HAVE_LIBOTF */ + for (i = 0; i < 16; i++) + { + variations[i] = FT_Face_GetCharVariantIndex (ft_face, c, 0xFE00 + i); + if (variations[i]) + n++; + } + for (; i < 256; i++) + { + variations[i] = FT_Face_GetCharVariantIndex (ft_face, c, + 0xE0100 + (i - 16)); + if (variations[i]) + n++; + } + + return n; +#endif /* !HAVE_OTF_GET_VARIATION_GLYPHS */ +} +#endif /* HAVE_OTF_GET_VARIATION_GLYPHS || HAVE_FT_FACE_GETCHARVARIANTINDEX */ #ifdef HAVE_HARFBUZZ @@ -2936,7 +2956,7 @@ static struct font_driver const ftfont_driver = #if defined HAVE_M17N_FLT && defined HAVE_LIBOTF .shape = ftfont_shape, #endif -#ifdef HAVE_OTF_GET_VARIATION_GLYPHS +#if defined HAVE_OTF_GET_VARIATION_GLYPHS || defined HAVE_FT_FACE_GETCHARVARIANTINDEX .get_variation_glyphs = ftfont_variation_glyphs, #endif .filter_properties = ftfont_filter_properties, diff --git a/src/ftxfont.c b/src/ftxfont.c index da3e3fbae10..b1467360ad6 100644 --- a/src/ftxfont.c +++ b/src/ftxfont.c @@ -351,7 +351,7 @@ struct font_driver const ftxfont_driver = #if defined HAVE_M17N_FLT && defined HAVE_LIBOTF .shape = ftfont_shape, #endif -#ifdef HAVE_OTF_GET_VARIATION_GLYPHS +#if defined HAVE_OTF_GET_VARIATION_GLYPHS || defined HAVE_FT_FACE_GETCHARVARIANTINDEX .get_variation_glyphs = ftfont_variation_glyphs, #endif .filter_properties = ftfont_filter_properties, diff --git a/src/xftfont.c b/src/xftfont.c index c1b93b76f57..04cda12fb52 100644 --- a/src/xftfont.c +++ b/src/xftfont.c @@ -661,7 +661,7 @@ struct font_driver const xftfont_driver = #if defined HAVE_M17N_FLT && defined HAVE_LIBOTF .shape = xftfont_shape, #endif -#ifdef HAVE_OTF_GET_VARIATION_GLYPHS +#if defined HAVE_OTF_GET_VARIATION_GLYPHS || defined HAVE_FT_FACE_GETCHARVARIANTINDEX .get_variation_glyphs = ftfont_variation_glyphs, #endif .filter_properties = ftfont_filter_properties, -- 2.39.2