summaryrefslogtreecommitdiff
path: root/src/ftfont.c
diff options
context:
space:
mode:
authorK. Handa <handa@gnu.org>2016-01-02 16:36:21 +0900
committerK. Handa <handa@gnu.org>2016-01-26 22:58:07 +0900
commit4a3db0f72955815c41114129129424c3b31ea3eb (patch)
tree77c468bfdaaa6485274337263e5e4d3245545eaa /src/ftfont.c
parent60902756b0d794b16b9c1c67c4c40a3ac04d1c1b (diff)
downloademacs-4a3db0f72955815c41114129129424c3b31ea3eb.tar.gz
support rendering of wider range of combinging characters by ftfont backend
* lisp/language/hebrew.el (hebrew-shape-gstring): If the font backend supports rendering of combining characters, call font-shape-gstring. * src/font.c (Ffont_get): Handle `combining-capability' property. (syms_of_font): New symbol ":combining-capability'. * src/font.h (struct font_driver): New member combining_capability. * src/ftfont.c: Include "category.h". (ftfont_driver): Initialize combining_capability to ftfont_combining_capability. (ftfont_shape_by_flt): If OTF is null, try to find a suitable FLT in advance. (ftfont_combining_capability): New function. (cherry picked from commit 536f48e9a2251b9e654ea974bd90ff2f40218753)
Diffstat (limited to 'src/ftfont.c')
-rw-r--r--src/ftfont.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/ftfont.c b/src/ftfont.c
index 8412dd0e286..bb8af96d7b1 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -30,6 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "dispextern.h"
#include "character.h"
#include "charset.h"
+#include "category.h"
#include "composite.h"
#include "font.h"
#include "ftfont.h"
@@ -81,6 +82,8 @@ static Lisp_Object ftfont_lookup_cache (Lisp_Object,
static void ftfont_filter_properties (Lisp_Object font, Lisp_Object alist);
+static Lisp_Object ftfont_combining_capability (struct font *);
+
#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
static struct
@@ -547,6 +550,10 @@ struct font_driver ftfont_driver =
#endif
ftfont_filter_properties, /* filter_properties */
+
+ NULL, /* cached_font_ok */
+
+ ftfont_combining_capability,
};
static Lisp_Object
@@ -2533,7 +2540,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
len = i;
- if (with_variation_selector)
+ if (otf && with_variation_selector)
{
setup_otf_gstring (len);
for (i = 0; i < len; i++)
@@ -2583,14 +2590,19 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
flt_font_ft.otf = otf;
flt_font_ft.matrix = matrix->xx != 0 ? matrix : 0;
- if (1 < len)
+ if (1 < len || ! otf)
{
/* A little bit ad hoc. Perhaps, shaper must get script and
language information, and select a proper flt for them
here. */
int c1 = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 1));
- if (0x300 <= c1 && c1 <= 0x36F)
+ if (CHAR_HAS_CATEGORY (c1, '^'))
flt = mflt_get (msymbol ("combining"));
+ else if (! otf)
+ flt = mflt_find (LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 0)),
+ &flt_font_ft.flt_font);
+ if (! flt)
+ return make_number (0);
}
MFLTGlyphFT *glyphs = (MFLTGlyphFT *) gstring.glyphs;
@@ -2675,8 +2687,6 @@ ftfont_shape (Lisp_Object lgstring)
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
OTF *otf = ftfont_get_otf (ftfont_info);
- if (! otf)
- return make_number (0);
return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf,
&ftfont_info->matrix);
}
@@ -2750,6 +2760,16 @@ ftfont_filter_properties (Lisp_Object font, Lisp_Object alist)
}
+static Lisp_Object
+ftfont_combining_capability (struct font *font)
+{
+#ifdef HAVE_M17N_FLT
+ return Qt;
+#else
+ return Qnil;
+#endif
+}
+
void
syms_of_ftfont (void)
{