aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorK. Handa2016-01-02 16:36:21 +0900
committerK. Handa2016-01-02 16:36:21 +0900
commit536f48e9a2251b9e654ea974bd90ff2f40218753 (patch)
treefa48333ec65910b24ffab90f2dda3d200fb56215 /src
parentd259328fb87db8cc67d52771efcfa653e52c5b71 (diff)
downloademacs-536f48e9a2251b9e654ea974bd90ff2f40218753.tar.gz
emacs-536f48e9a2251b9e654ea974bd90ff2f40218753.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/font.c27
-rw-r--r--src/font.h6
-rw-r--r--src/ftfont.c30
3 files changed, 52 insertions, 11 deletions
diff --git a/src/font.c b/src/font.c
index 016b7e0a88e..6fa599524c9 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4036,7 +4036,13 @@ The value of :otf is a cons (GSUB . GPOS) where GSUB and GPOS are lists
4036representing the OpenType features supported by the font by this form: 4036representing the OpenType features supported by the font by this form:
4037 ((SCRIPT (LANGSYS FEATURE ...) ...) ...) 4037 ((SCRIPT (LANGSYS FEATURE ...) ...) ...)
4038SCRIPT, LANGSYS, and FEATURE are all symbols representing OpenType 4038SCRIPT, LANGSYS, and FEATURE are all symbols representing OpenType
4039Layout tags. */) 4039Layout tags.
4040
4041In addition to the keys listed abobe, the following keys are reserved
4042for the specific meanings as below:
4043
4044The value of :combining-capability is non-nil if the font-backend of
4045FONT supports rendering of combining characters for non-OTF fonts. */)
4040 (Lisp_Object font, Lisp_Object key) 4046 (Lisp_Object font, Lisp_Object key)
4041{ 4047{
4042 int idx; 4048 int idx;
@@ -4051,14 +4057,22 @@ Layout tags. */)
4051 if (idx >= 0 && idx < FONT_EXTRA_INDEX) 4057 if (idx >= 0 && idx < FONT_EXTRA_INDEX)
4052 return AREF (font, idx); 4058 return AREF (font, idx);
4053 val = Fassq (key, AREF (font, FONT_EXTRA_INDEX)); 4059 val = Fassq (key, AREF (font, FONT_EXTRA_INDEX));
4054 if (NILP (val) && EQ (key, QCotf) && FONT_OBJECT_P (font)) 4060 if (NILP (val) && FONT_OBJECT_P (font))
4055 { 4061 {
4056 struct font *fontp = XFONT_OBJECT (font); 4062 struct font *fontp = XFONT_OBJECT (font);
4057 4063
4058 if (fontp->driver->otf_capability) 4064 if (EQ (key, QCotf))
4059 val = fontp->driver->otf_capability (fontp); 4065 {
4060 else 4066 if (fontp->driver->otf_capability)
4061 val = Fcons (Qnil, Qnil); 4067 val = fontp->driver->otf_capability (fontp);
4068 else
4069 val = Fcons (Qnil, Qnil);
4070 }
4071 else if (EQ (key, QCcombining_capability))
4072 {
4073 if (fontp->driver->combining_capability)
4074 val = fontp->driver->combining_capability (fontp);
4075 }
4062 } 4076 }
4063 else 4077 else
4064 val = Fcdr (val); 4078 val = Fcdr (val);
@@ -5290,6 +5304,7 @@ syms_of_font (void)
5290 DEFSYM (QCscalable, ":scalable"); 5304 DEFSYM (QCscalable, ":scalable");
5291 DEFSYM (QCavgwidth, ":avgwidth"); 5305 DEFSYM (QCavgwidth, ":avgwidth");
5292 DEFSYM (QCfont_entity, ":font-entity"); 5306 DEFSYM (QCfont_entity, ":font-entity");
5307 DEFSYM (QCcombining_capability, ":combining-capability");
5293 5308
5294 /* Symbols representing values of font spacing property. */ 5309 /* Symbols representing values of font spacing property. */
5295 DEFSYM (Qc, "c"); 5310 DEFSYM (Qc, "c");
diff --git a/src/font.h b/src/font.h
index 1d13e1cb6b0..f6f862ac7df 100644
--- a/src/font.h
+++ b/src/font.h
@@ -715,6 +715,12 @@ struct font_driver
715 bool (*cached_font_ok) (struct frame *f, 715 bool (*cached_font_ok) (struct frame *f,
716 Lisp_Object font_object, 716 Lisp_Object font_object,
717 Lisp_Object entity); 717 Lisp_Object entity);
718
719 /* Optional
720
721 Return non-nil if the driver support rendering of combining
722 characters for FONT according to Unicode combining class. */
723 Lisp_Object (*combining_capability) (struct font *font);
718}; 724};
719 725
720 726
diff --git a/src/ftfont.c b/src/ftfont.c
index 17e41a9339e..575bf53701c 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/>. */
30#include "dispextern.h" 30#include "dispextern.h"
31#include "character.h" 31#include "character.h"
32#include "charset.h" 32#include "charset.h"
33#include "category.h"
33#include "composite.h" 34#include "composite.h"
34#include "font.h" 35#include "font.h"
35#include "ftfont.h" 36#include "ftfont.h"
@@ -81,6 +82,8 @@ static Lisp_Object ftfont_lookup_cache (Lisp_Object,
81 82
82static void ftfont_filter_properties (Lisp_Object font, Lisp_Object alist); 83static void ftfont_filter_properties (Lisp_Object font, Lisp_Object alist);
83 84
85static Lisp_Object ftfont_combining_capability (struct font *);
86
84#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM)) 87#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
85 88
86static struct 89static struct
@@ -547,6 +550,10 @@ struct font_driver ftfont_driver =
547#endif 550#endif
548 551
549 ftfont_filter_properties, /* filter_properties */ 552 ftfont_filter_properties, /* filter_properties */
553
554 NULL, /* cached_font_ok */
555
556 ftfont_combining_capability,
550 }; 557 };
551 558
552static Lisp_Object 559static Lisp_Object
@@ -2533,7 +2540,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2533 2540
2534 len = i; 2541 len = i;
2535 2542
2536 if (with_variation_selector) 2543 if (otf && with_variation_selector)
2537 { 2544 {
2538 setup_otf_gstring (len); 2545 setup_otf_gstring (len);
2539 for (i = 0; i < len; i++) 2546 for (i = 0; i < len; i++)
@@ -2583,14 +2590,19 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2583 flt_font_ft.otf = otf; 2590 flt_font_ft.otf = otf;
2584 flt_font_ft.matrix = matrix->xx != 0 ? matrix : 0; 2591 flt_font_ft.matrix = matrix->xx != 0 ? matrix : 0;
2585 2592
2586 if (1 < len) 2593 if (1 < len || ! otf)
2587 { 2594 {
2588 /* A little bit ad hoc. Perhaps, shaper must get script and 2595 /* A little bit ad hoc. Perhaps, shaper must get script and
2589 language information, and select a proper flt for them 2596 language information, and select a proper flt for them
2590 here. */ 2597 here. */
2591 int c1 = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 1)); 2598 int c1 = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 1));
2592 if (0x300 <= c1 && c1 <= 0x36F) 2599 if (CHAR_HAS_CATEGORY (c1, '^'))
2593 flt = mflt_get (msymbol ("combining")); 2600 flt = mflt_get (msymbol ("combining"));
2601 else if (! otf)
2602 flt = mflt_find (LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 0)),
2603 &flt_font_ft.flt_font);
2604 if (! flt)
2605 return make_number (0);
2594 } 2606 }
2595 2607
2596 MFLTGlyphFT *glyphs = (MFLTGlyphFT *) gstring.glyphs; 2608 MFLTGlyphFT *glyphs = (MFLTGlyphFT *) gstring.glyphs;
@@ -2675,8 +2687,6 @@ ftfont_shape (Lisp_Object lgstring)
2675 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 2687 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
2676 OTF *otf = ftfont_get_otf (ftfont_info); 2688 OTF *otf = ftfont_get_otf (ftfont_info);
2677 2689
2678 if (! otf)
2679 return make_number (0);
2680 return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf, 2690 return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf,
2681 &ftfont_info->matrix); 2691 &ftfont_info->matrix);
2682} 2692}
@@ -2750,6 +2760,16 @@ ftfont_filter_properties (Lisp_Object font, Lisp_Object alist)
2750} 2760}
2751 2761
2752 2762
2763static Lisp_Object
2764ftfont_combining_capability (struct font *font)
2765{
2766#ifdef HAVE_M17N_FLT
2767 return Qt;
2768#else
2769 return Qnil;
2770#endif
2771}
2772
2753void 2773void
2754syms_of_ftfont (void) 2774syms_of_ftfont (void)
2755{ 2775{