aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/font.c22
-rw-r--r--src/font.h41
-rw-r--r--src/ftcrfont.c49
-rw-r--r--src/ftfont.c144
-rw-r--r--src/ftxfont.c59
-rw-r--r--src/macfont.m47
-rw-r--r--src/nsfont.m54
-rw-r--r--src/xfont.c57
-rw-r--r--src/xftfont.c79
10 files changed, 251 insertions, 303 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 175dcab2487..ae32400708a 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3201,7 +3201,7 @@ cleanup_vector (struct Lisp_Vector *vector)
3201 && ((vector->header.size & PSEUDOVECTOR_SIZE_MASK) 3201 && ((vector->header.size & PSEUDOVECTOR_SIZE_MASK)
3202 == FONT_OBJECT_MAX)) 3202 == FONT_OBJECT_MAX))
3203 { 3203 {
3204 struct font_driver *drv = ((struct font *) vector)->driver; 3204 struct font_driver const *drv = ((struct font *) vector)->driver;
3205 3205
3206 /* The font driver might sometimes be NULL, e.g. if Emacs was 3206 /* The font driver might sometimes be NULL, e.g. if Emacs was
3207 interrupted before it had time to set it up. */ 3207 interrupted before it had time to set it up. */
diff --git a/src/font.c b/src/font.c
index ce632335256..9fe7c26ea9c 100644
--- a/src/font.c
+++ b/src/font.c
@@ -132,7 +132,7 @@ static struct font_driver_list *font_driver_list;
132/* Used to catch bogus pointers in font objects. */ 132/* Used to catch bogus pointers in font objects. */
133 133
134bool 134bool
135valid_font_driver (struct font_driver *drv) 135valid_font_driver (struct font_driver const *drv)
136{ 136{
137 Lisp_Object tail, frame; 137 Lisp_Object tail, frame;
138 struct font_driver_list *fdl; 138 struct font_driver_list *fdl;
@@ -2543,14 +2543,11 @@ font_match_p (Lisp_Object spec, Lisp_Object font)
2543 is a number frames sharing this cache, and FONT-CACHE-DATA is a 2543 is a number frames sharing this cache, and FONT-CACHE-DATA is a
2544 cons (FONT-SPEC . [FONT-ENTITY ...]). */ 2544 cons (FONT-SPEC . [FONT-ENTITY ...]). */
2545 2545
2546static void font_prepare_cache (struct frame *, struct font_driver *);
2547static void font_finish_cache (struct frame *, struct font_driver *);
2548static Lisp_Object font_get_cache (struct frame *, struct font_driver *);
2549static void font_clear_cache (struct frame *, Lisp_Object, 2546static void font_clear_cache (struct frame *, Lisp_Object,
2550 struct font_driver *); 2547 struct font_driver const *);
2551 2548
2552static void 2549static void
2553font_prepare_cache (struct frame *f, struct font_driver *driver) 2550font_prepare_cache (struct frame *f, struct font_driver const *driver)
2554{ 2551{
2555 Lisp_Object cache, val; 2552 Lisp_Object cache, val;
2556 2553
@@ -2572,7 +2569,7 @@ font_prepare_cache (struct frame *f, struct font_driver *driver)
2572 2569
2573 2570
2574static void 2571static void
2575font_finish_cache (struct frame *f, struct font_driver *driver) 2572font_finish_cache (struct frame *f, struct font_driver const *driver)
2576{ 2573{
2577 Lisp_Object cache, val, tmp; 2574 Lisp_Object cache, val, tmp;
2578 2575
@@ -2593,7 +2590,7 @@ font_finish_cache (struct frame *f, struct font_driver *driver)
2593 2590
2594 2591
2595static Lisp_Object 2592static Lisp_Object
2596font_get_cache (struct frame *f, struct font_driver *driver) 2593font_get_cache (struct frame *f, struct font_driver const *driver)
2597{ 2594{
2598 Lisp_Object val = driver->get_cache (f); 2595 Lisp_Object val = driver->get_cache (f);
2599 Lisp_Object type = driver->type; 2596 Lisp_Object type = driver->type;
@@ -2608,7 +2605,8 @@ font_get_cache (struct frame *f, struct font_driver *driver)
2608 2605
2609 2606
2610static void 2607static void
2611font_clear_cache (struct frame *f, Lisp_Object cache, struct font_driver *driver) 2608font_clear_cache (struct frame *f, Lisp_Object cache,
2609 struct font_driver const *driver)
2612{ 2610{
2613 Lisp_Object tail, elt; 2611 Lisp_Object tail, elt;
2614 Lisp_Object entity; 2612 Lisp_Object entity;
@@ -3463,7 +3461,7 @@ font_open_by_name (struct frame *f, Lisp_Object name)
3463 (e.g. syms_of_xfont). */ 3461 (e.g. syms_of_xfont). */
3464 3462
3465void 3463void
3466register_font_driver (struct font_driver *driver, struct frame *f) 3464register_font_driver (struct font_driver const *driver, struct frame *f)
3467{ 3465{
3468 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; 3466 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list;
3469 struct font_driver_list *prev, *list; 3467 struct font_driver_list *prev, *list;
@@ -3524,7 +3522,7 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers)
3524 drivers. */ 3522 drivers. */
3525 for (list = f->font_driver_list; list; list = list->next) 3523 for (list = f->font_driver_list; list; list = list->next)
3526 { 3524 {
3527 struct font_driver *driver = list->driver; 3525 struct font_driver const *driver = list->driver;
3528 if ((EQ (new_drivers, Qt) || ! NILP (Fmemq (driver->type, new_drivers))) 3526 if ((EQ (new_drivers, Qt) || ! NILP (Fmemq (driver->type, new_drivers)))
3529 != list->on) 3527 != list->on)
3530 { 3528 {
@@ -3587,7 +3585,7 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers)
3587 and then use it under w32 or ns. */ 3585 and then use it under w32 or ns. */
3588 for (list = f->font_driver_list; list; list = list->next) 3586 for (list = f->font_driver_list; list; list = list->next)
3589 { 3587 {
3590 struct font_driver *driver = list->driver; 3588 struct font_driver const *driver = list->driver;
3591 eassert (! list->on); 3589 eassert (! list->on);
3592 if (! driver->start_for_frame 3590 if (! driver->start_for_frame
3593 || driver->start_for_frame (f) == 0) 3591 || driver->start_for_frame (f) == 0)
diff --git a/src/font.h b/src/font.h
index c14823bc1eb..af0214c3f23 100644
--- a/src/font.h
+++ b/src/font.h
@@ -380,7 +380,7 @@ struct font
380#endif /* HAVE_WINDOW_SYSTEM */ 380#endif /* HAVE_WINDOW_SYSTEM */
381 381
382 /* Font-driver for the font. */ 382 /* Font-driver for the font. */
383 struct font_driver *driver; 383 struct font_driver const *driver;
384 384
385 /* There are more members in this structure, but they are private 385 /* There are more members in this structure, but they are private
386 to the font-driver. */ 386 to the font-driver. */
@@ -783,7 +783,7 @@ struct font_driver_list
783 font driver list.*/ 783 font driver list.*/
784 bool on; 784 bool on;
785 /* Pointer to the font driver. */ 785 /* Pointer to the font driver. */
786 struct font_driver *driver; 786 struct font_driver const *driver;
787 /* Pointer to the next element of the chain. */ 787 /* Pointer to the next element of the chain. */
788 struct font_driver_list *next; 788 struct font_driver_list *next;
789}; 789};
@@ -841,13 +841,13 @@ extern void font_parse_family_registry (Lisp_Object family,
841extern int font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font); 841extern int font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font);
842extern ptrdiff_t font_unparse_xlfd (Lisp_Object font, int pixel_size, 842extern ptrdiff_t font_unparse_xlfd (Lisp_Object font, int pixel_size,
843 char *name, int bytes); 843 char *name, int bytes);
844extern void register_font_driver (struct font_driver *driver, struct frame *f); 844extern void register_font_driver (struct font_driver const *, struct frame *);
845extern void free_font_driver_list (struct frame *f); 845extern void free_font_driver_list (struct frame *f);
846#ifdef ENABLE_CHECKING 846#ifdef ENABLE_CHECKING
847extern bool valid_font_driver (struct font_driver *); 847extern bool valid_font_driver (struct font_driver const *);
848#else 848#else
849INLINE bool 849INLINE bool
850valid_font_driver (struct font_driver *d) 850valid_font_driver (struct font_driver const *d)
851{ 851{
852 return true; 852 return true;
853} 853}
@@ -874,18 +874,37 @@ extern void font_filter_properties (Lisp_Object font,
874extern void font_drop_xrender_surfaces (struct frame *f); 874extern void font_drop_xrender_surfaces (struct frame *f);
875 875
876#ifdef HAVE_FREETYPE 876#ifdef HAVE_FREETYPE
877extern struct font_driver ftfont_driver; 877extern int ftfont_anchor_point (struct font *, unsigned int, int,
878 int *, int *);
879extern int ftfont_get_bitmap (struct font *, unsigned int,
880 struct font_bitmap *, int);
881extern int ftfont_has_char (Lisp_Object, int);
882extern int ftfont_variation_glyphs (struct font *, int, unsigned[256]);
883extern Lisp_Object ftfont_combining_capability (struct font *);
884extern Lisp_Object ftfont_get_cache (struct frame *);
885extern Lisp_Object ftfont_list (struct frame *, Lisp_Object);
886extern Lisp_Object ftfont_list_family (struct frame *);
887extern Lisp_Object ftfont_match (struct frame *, Lisp_Object);
888extern Lisp_Object ftfont_open (struct frame *, Lisp_Object, int);
889extern Lisp_Object ftfont_otf_capability (struct font *);
890extern Lisp_Object ftfont_shape (Lisp_Object);
891extern unsigned ftfont_encode_char (struct font *, int);
892extern void ftfont_close (struct font *);
893extern void ftfont_filter_properties (Lisp_Object, Lisp_Object);
894extern void ftfont_text_extents (struct font *, unsigned *, int,
895 struct font_metrics *);
878extern void syms_of_ftfont (void); 896extern void syms_of_ftfont (void);
879#endif /* HAVE_FREETYPE */ 897#endif /* HAVE_FREETYPE */
880#ifdef HAVE_X_WINDOWS 898#ifdef HAVE_X_WINDOWS
881extern struct font_driver xfont_driver; 899extern struct font_driver const xfont_driver;
900extern Lisp_Object xfont_get_cache (struct frame *);
882extern void syms_of_xfont (void); 901extern void syms_of_xfont (void);
883extern void syms_of_ftxfont (void); 902extern void syms_of_ftxfont (void);
884#ifdef HAVE_XFT 903#ifdef HAVE_XFT
885extern struct font_driver xftfont_driver; 904extern struct font_driver const xftfont_driver;
886#endif 905#endif
887#if defined HAVE_FREETYPE || defined HAVE_XFT 906#if defined HAVE_FREETYPE || defined HAVE_XFT
888extern struct font_driver ftxfont_driver; 907extern struct font_driver const ftxfont_driver;
889extern void syms_of_xftfont (void); 908extern void syms_of_xftfont (void);
890#endif 909#endif
891#ifdef HAVE_BDFFONT 910#ifdef HAVE_BDFFONT
@@ -898,12 +917,12 @@ extern struct font_driver uniscribe_font_driver;
898extern void syms_of_w32font (void); 917extern void syms_of_w32font (void);
899#endif /* HAVE_NTGUI */ 918#endif /* HAVE_NTGUI */
900#ifdef HAVE_NS 919#ifdef HAVE_NS
901extern struct font_driver nsfont_driver; 920extern struct font_driver const nsfont_driver;
902extern void syms_of_nsfont (void); 921extern void syms_of_nsfont (void);
903extern void syms_of_macfont (void); 922extern void syms_of_macfont (void);
904#endif /* HAVE_NS */ 923#endif /* HAVE_NS */
905#ifdef USE_CAIRO 924#ifdef USE_CAIRO
906extern struct font_driver ftcrfont_driver; 925extern struct font_driver const ftcrfont_driver;
907extern void syms_of_ftcrfont (void); 926extern void syms_of_ftcrfont (void);
908#endif 927#endif
909 928
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index 2676502705d..f62b40f41c4 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -65,8 +65,6 @@ enum metrics_status
65#define METRICS_SET_STATUS(metrics, status) \ 65#define METRICS_SET_STATUS(metrics, status) \
66 ((metrics)->ascent = 0, (metrics)->descent = (status)) 66 ((metrics)->ascent = 0, (metrics)->descent = (status))
67 67
68struct font_driver ftcrfont_driver;
69
70static int 68static int
71ftcrfont_glyph_extents (struct font *font, 69ftcrfont_glyph_extents (struct font *font,
72 unsigned glyph, 70 unsigned glyph,
@@ -101,7 +99,7 @@ ftcrfont_glyph_extents (struct font *font,
101 cache = ftcrfont_info->metrics[row] + col; 99 cache = ftcrfont_info->metrics[row] + col;
102 100
103 if (METRICS_STATUS (cache) == METRICS_INVALID) 101 if (METRICS_STATUS (cache) == METRICS_INVALID)
104 ftfont_driver.text_extents (font, &glyph, 1, cache); 102 ftfont_text_extents (font, &glyph, 1, cache);
105 103
106 if (metrics) 104 if (metrics)
107 *metrics = *cache; 105 *metrics = *cache;
@@ -112,7 +110,7 @@ ftcrfont_glyph_extents (struct font *font,
112static Lisp_Object 110static Lisp_Object
113ftcrfont_list (struct frame *f, Lisp_Object spec) 111ftcrfont_list (struct frame *f, Lisp_Object spec)
114{ 112{
115 Lisp_Object list = ftfont_driver.list (f, spec), tail; 113 Lisp_Object list = ftfont_list (f, spec), tail;
116 114
117 for (tail = list; CONSP (tail); tail = XCDR (tail)) 115 for (tail = list; CONSP (tail); tail = XCDR (tail))
118 ASET (XCAR (tail), FONT_TYPE_INDEX, Qftcr); 116 ASET (XCAR (tail), FONT_TYPE_INDEX, Qftcr);
@@ -122,15 +120,13 @@ ftcrfont_list (struct frame *f, Lisp_Object spec)
122static Lisp_Object 120static Lisp_Object
123ftcrfont_match (struct frame *f, Lisp_Object spec) 121ftcrfont_match (struct frame *f, Lisp_Object spec)
124{ 122{
125 Lisp_Object entity = ftfont_driver.match (f, spec); 123 Lisp_Object entity = ftfont_match (f, spec);
126 124
127 if (VECTORP (entity)) 125 if (VECTORP (entity))
128 ASET (entity, FONT_TYPE_INDEX, Qftcr); 126 ASET (entity, FONT_TYPE_INDEX, Qftcr);
129 return entity; 127 return entity;
130} 128}
131 129
132extern FT_Face ftfont_get_ft_face (Lisp_Object);
133
134static Lisp_Object 130static Lisp_Object
135ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) 131ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
136{ 132{
@@ -181,7 +177,7 @@ ftcrfont_close (struct font *font)
181 cairo_font_face_destroy (ftcrfont_info->cr_font_face); 177 cairo_font_face_destroy (ftcrfont_info->cr_font_face);
182 unblock_input (); 178 unblock_input ();
183 179
184 ftfont_driver.close (font); 180 ftfont_close (font);
185} 181}
186 182
187static void 183static void
@@ -282,6 +278,34 @@ ftcrfont_draw (struct glyph_string *s,
282 278
283 279
284 280
281struct font_driver const ftcrfont_driver =
282 {
283 type: LISPSYM_INITIALLY (Qftcr),
284 get_cache: ftfont_get_cache,
285 list: ftcrfont_list,
286 match: ftcrfont_match,
287 list_family: ftfont_list_family,
288 open: ftcrfont_open,
289 close: ftcrfont_close,
290 has_char: ftfont_has_char,
291 encode_char: ftfont_encode_char,
292 text_extents: ftcrfont_text_extents,
293 draw: ftcrfont_draw,
294 get_bitmap: ftfont_get_bitmap,
295 anchor_point: ftfont_anchor_point,
296#ifdef HAVE_LIBOTF
297 otf_capability: ftfont_otf_capability,
298#endif
299#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
300 shape: ftfont_shape,
301#endif
302#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
303 get_variation_glyphs: ftfont_variation_glyphs,
304#endif
305 filter_properties: ftfont_filter_properties,
306 combining_capability: ftfont_combining_capability,
307 };
308
285void 309void
286syms_of_ftcrfont (void) 310syms_of_ftcrfont (void)
287{ 311{
@@ -289,14 +313,5 @@ syms_of_ftcrfont (void)
289 abort (); 313 abort ();
290 314
291 DEFSYM (Qftcr, "ftcr"); 315 DEFSYM (Qftcr, "ftcr");
292
293 ftcrfont_driver = ftfont_driver;
294 ftcrfont_driver.type = Qftcr;
295 ftcrfont_driver.list = ftcrfont_list;
296 ftcrfont_driver.match = ftcrfont_match;
297 ftcrfont_driver.open = ftcrfont_open;
298 ftcrfont_driver.close = ftcrfont_close;
299 ftcrfont_driver.text_extents = ftcrfont_text_extents;
300 ftcrfont_driver.draw = ftcrfont_draw;
301 register_font_driver (&ftcrfont_driver, NULL); 316 register_font_driver (&ftcrfont_driver, NULL);
302} 317}
diff --git a/src/ftfont.c b/src/ftfont.c
index 17fe66828fa..768b524f0a6 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -35,6 +35,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35#include "font.h" 35#include "font.h"
36#include "ftfont.h" 36#include "ftfont.h"
37 37
38static struct font_driver const ftfont_driver;
39
38/* Flag to tell if FcInit is already called or not. */ 40/* Flag to tell if FcInit is already called or not. */
39static bool fc_initialized; 41static bool fc_initialized;
40 42
@@ -73,17 +75,9 @@ enum ftfont_cache_for
73 FTFONT_CACHE_FOR_ENTITY 75 FTFONT_CACHE_FOR_ENTITY
74 }; 76 };
75 77
76static Lisp_Object ftfont_pattern_entity (FcPattern *, Lisp_Object);
77
78static Lisp_Object ftfont_resolve_generic_family (Lisp_Object,
79 FcPattern *);
80static Lisp_Object ftfont_lookup_cache (Lisp_Object, 78static Lisp_Object ftfont_lookup_cache (Lisp_Object,
81 enum ftfont_cache_for); 79 enum ftfont_cache_for);
82 80
83static void ftfont_filter_properties (Lisp_Object font, Lisp_Object alist);
84
85static Lisp_Object ftfont_combining_capability (struct font *);
86
87#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM)) 81#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
88 82
89static struct 83static struct
@@ -480,83 +474,7 @@ ftfont_get_otf (struct ftfont_info *ftfont_info)
480} 474}
481#endif /* HAVE_LIBOTF */ 475#endif /* HAVE_LIBOTF */
482 476
483static Lisp_Object ftfont_get_cache (struct frame *); 477Lisp_Object
484static Lisp_Object ftfont_list (struct frame *, Lisp_Object);
485static Lisp_Object ftfont_match (struct frame *, Lisp_Object);
486static Lisp_Object ftfont_list_family (struct frame *);
487static Lisp_Object ftfont_open (struct frame *, Lisp_Object, int);
488static void ftfont_close (struct font *);
489static int ftfont_has_char (Lisp_Object, int);
490static unsigned ftfont_encode_char (struct font *, int);
491static void ftfont_text_extents (struct font *, unsigned *, int,
492 struct font_metrics *);
493static int ftfont_get_bitmap (struct font *, unsigned,
494 struct font_bitmap *, int);
495static int ftfont_anchor_point (struct font *, unsigned, int,
496 int *, int *);
497#ifdef HAVE_LIBOTF
498static Lisp_Object ftfont_otf_capability (struct font *);
499# ifdef HAVE_M17N_FLT
500static Lisp_Object ftfont_shape (Lisp_Object);
501# endif
502#endif
503
504#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
505static int ftfont_variation_glyphs (struct font *, int c,
506 unsigned variations[256]);
507#endif /* HAVE_OTF_GET_VARIATION_GLYPHS */
508
509struct font_driver ftfont_driver =
510 {
511 LISPSYM_INITIALLY (Qfreetype),
512 0, /* case insensitive */
513 ftfont_get_cache,
514 ftfont_list,
515 ftfont_match,
516 ftfont_list_family,
517 NULL, /* free_entity */
518 ftfont_open,
519 ftfont_close,
520 /* We can't draw a text without device dependent functions. */
521 NULL, /* prepare_face */
522 NULL, /* done_face */
523 ftfont_has_char,
524 ftfont_encode_char,
525 ftfont_text_extents,
526 /* We can't draw a text without device dependent functions. */
527 NULL, /* draw */
528 ftfont_get_bitmap,
529 NULL, /* free_bitmap */
530 ftfont_anchor_point,
531#ifdef HAVE_LIBOTF
532 ftfont_otf_capability,
533#else /* not HAVE_LIBOTF */
534 NULL,
535#endif /* not HAVE_LIBOTF */
536 NULL, /* otf_drive */
537 NULL, /* start_for_frame */
538 NULL, /* end_for_frame */
539#if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF)
540 ftfont_shape,
541#else /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
542 NULL,
543#endif /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
544 NULL, /* check */
545
546#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
547 ftfont_variation_glyphs,
548#else
549 NULL,
550#endif
551
552 ftfont_filter_properties, /* filter_properties */
553
554 NULL, /* cached_font_ok */
555
556 ftfont_combining_capability,
557 };
558
559static Lisp_Object
560ftfont_get_cache (struct frame *f) 478ftfont_get_cache (struct frame *f)
561{ 479{
562 return freetype_font_cache; 480 return freetype_font_cache;
@@ -873,7 +791,7 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots
873 return pattern; 791 return pattern;
874} 792}
875 793
876static Lisp_Object 794Lisp_Object
877ftfont_list (struct frame *f, Lisp_Object spec) 795ftfont_list (struct frame *f, Lisp_Object spec)
878{ 796{
879 Lisp_Object val = Qnil, family, adstyle; 797 Lisp_Object val = Qnil, family, adstyle;
@@ -1072,7 +990,7 @@ ftfont_list (struct frame *f, Lisp_Object spec)
1072 return val; 990 return val;
1073} 991}
1074 992
1075static Lisp_Object 993Lisp_Object
1076ftfont_match (struct frame *f, Lisp_Object spec) 994ftfont_match (struct frame *f, Lisp_Object spec)
1077{ 995{
1078 Lisp_Object entity = Qnil; 996 Lisp_Object entity = Qnil;
@@ -1122,7 +1040,7 @@ ftfont_match (struct frame *f, Lisp_Object spec)
1122 return entity; 1040 return entity;
1123} 1041}
1124 1042
1125static Lisp_Object 1043Lisp_Object
1126ftfont_list_family (struct frame *f) 1044ftfont_list_family (struct frame *f)
1127{ 1045{
1128 Lisp_Object list = Qnil; 1046 Lisp_Object list = Qnil;
@@ -1301,7 +1219,7 @@ ftfont_open2 (struct frame *f,
1301 return font_object; 1219 return font_object;
1302} 1220}
1303 1221
1304static Lisp_Object 1222Lisp_Object
1305ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) 1223ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1306{ 1224{
1307 Lisp_Object font_object; 1225 Lisp_Object font_object;
@@ -1314,7 +1232,7 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1314 return ftfont_open2 (f, entity, pixel_size, font_object); 1232 return ftfont_open2 (f, entity, pixel_size, font_object);
1315} 1233}
1316 1234
1317static void 1235void
1318ftfont_close (struct font *font) 1236ftfont_close (struct font *font)
1319{ 1237{
1320 /* FIXME: Although this function can be called while garbage-collecting, 1238 /* FIXME: Although this function can be called while garbage-collecting,
@@ -1344,7 +1262,7 @@ ftfont_close (struct font *font)
1344 FT_Done_Size (ftfont_info->ft_size); 1262 FT_Done_Size (ftfont_info->ft_size);
1345} 1263}
1346 1264
1347static int 1265int
1348ftfont_has_char (Lisp_Object font, int c) 1266ftfont_has_char (Lisp_Object font, int c)
1349{ 1267{
1350 struct charset *cs = NULL; 1268 struct charset *cs = NULL;
@@ -1374,7 +1292,7 @@ ftfont_has_char (Lisp_Object font, int c)
1374 } 1292 }
1375} 1293}
1376 1294
1377static unsigned 1295unsigned
1378ftfont_encode_char (struct font *font, int c) 1296ftfont_encode_char (struct font *font, int c)
1379{ 1297{
1380 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 1298 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
@@ -1385,7 +1303,7 @@ ftfont_encode_char (struct font *font, int c)
1385 return (code > 0 ? code : FONT_INVALID_CODE); 1303 return (code > 0 ? code : FONT_INVALID_CODE);
1386} 1304}
1387 1305
1388static void 1306void
1389ftfont_text_extents (struct font *font, unsigned int *code, 1307ftfont_text_extents (struct font *font, unsigned int *code,
1390 int nglyphs, struct font_metrics *metrics) 1308 int nglyphs, struct font_metrics *metrics)
1391{ 1309{
@@ -1429,7 +1347,7 @@ ftfont_text_extents (struct font *font, unsigned int *code,
1429 metrics->width = width; 1347 metrics->width = width;
1430} 1348}
1431 1349
1432static int 1350int
1433ftfont_get_bitmap (struct font *font, unsigned int code, struct font_bitmap *bitmap, int bits_per_pixel) 1351ftfont_get_bitmap (struct font *font, unsigned int code, struct font_bitmap *bitmap, int bits_per_pixel)
1434{ 1352{
1435 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 1353 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
@@ -1472,7 +1390,7 @@ ftfont_get_bitmap (struct font *font, unsigned int code, struct font_bitmap *bit
1472 return 0; 1390 return 0;
1473} 1391}
1474 1392
1475static int 1393int
1476ftfont_anchor_point (struct font *font, unsigned int code, int idx, 1394ftfont_anchor_point (struct font *font, unsigned int code, int idx,
1477 int *x, int *y) 1395 int *x, int *y)
1478{ 1396{
@@ -1538,7 +1456,7 @@ ftfont_otf_features (OTF_GSUB_GPOS *gsub_gpos)
1538} 1456}
1539 1457
1540 1458
1541static Lisp_Object 1459Lisp_Object
1542ftfont_otf_capability (struct font *font) 1460ftfont_otf_capability (struct font *font)
1543{ 1461{
1544 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 1462 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
@@ -2701,7 +2619,7 @@ ftfont_shape (Lisp_Object lgstring)
2701 2619
2702#ifdef HAVE_OTF_GET_VARIATION_GLYPHS 2620#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
2703 2621
2704static int 2622int
2705ftfont_variation_glyphs (struct font *font, int c, unsigned variations[256]) 2623ftfont_variation_glyphs (struct font *font, int c, unsigned variations[256])
2706{ 2624{
2707 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 2625 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
@@ -2759,14 +2677,14 @@ static const char *const ftfont_non_booleans [] = {
2759 NULL, 2677 NULL,
2760}; 2678};
2761 2679
2762static void 2680void
2763ftfont_filter_properties (Lisp_Object font, Lisp_Object alist) 2681ftfont_filter_properties (Lisp_Object font, Lisp_Object alist)
2764{ 2682{
2765 font_filter_properties (font, alist, ftfont_booleans, ftfont_non_booleans); 2683 font_filter_properties (font, alist, ftfont_booleans, ftfont_non_booleans);
2766} 2684}
2767 2685
2768 2686
2769static Lisp_Object 2687Lisp_Object
2770ftfont_combining_capability (struct font *font) 2688ftfont_combining_capability (struct font *font)
2771{ 2689{
2772#ifdef HAVE_M17N_FLT 2690#ifdef HAVE_M17N_FLT
@@ -2776,6 +2694,34 @@ ftfont_combining_capability (struct font *font)
2776#endif 2694#endif
2777} 2695}
2778 2696
2697static struct font_driver const ftfont_driver =
2698 {
2699 /* We can't draw a text without device dependent functions. */
2700 type: LISPSYM_INITIALLY (Qfreetype),
2701 get_cache: ftfont_get_cache,
2702 list: ftfont_list,
2703 match: ftfont_match,
2704 list_family: ftfont_list_family,
2705 open: ftfont_open,
2706 close: ftfont_close,
2707 has_char: ftfont_has_char,
2708 encode_char: ftfont_encode_char,
2709 text_extents: ftfont_text_extents,
2710 get_bitmap: ftfont_get_bitmap,
2711 anchor_point: ftfont_anchor_point,
2712#ifdef HAVE_LIBOTF
2713 otf_capability: ftfont_otf_capability,
2714#endif
2715#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
2716 shape: ftfont_shape,
2717#endif
2718#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
2719 get_variation_glyphs: ftfont_variation_glyphs,
2720#endif
2721 filter_properties: ftfont_filter_properties,
2722 combining_capability: ftfont_combining_capability,
2723 };
2724
2779void 2725void
2780syms_of_ftfont (void) 2726syms_of_ftfont (void)
2781{ 2727{
diff --git a/src/ftxfont.c b/src/ftxfont.c
index bfdeb4051b9..d8792ac27bd 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -31,8 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 31
32/* FTX font driver. */ 32/* FTX font driver. */
33 33
34struct font_driver ftxfont_driver;
35
36struct ftxfont_frame_data 34struct ftxfont_frame_data
37{ 35{
38 /* Background and foreground colors. */ 36 /* Background and foreground colors. */
@@ -125,7 +123,7 @@ ftxfont_draw_bitmap (struct frame *f, GC gc_fore, GC *gcs, struct font *font,
125 unsigned char *b; 123 unsigned char *b;
126 int i, j; 124 int i, j;
127 125
128 if (ftfont_driver.get_bitmap (font, code, &bitmap, size > 0x100 ? 1 : 8) < 0) 126 if (ftfont_get_bitmap (font, code, &bitmap, size > 0x100 ? 1 : 8) < 0)
129 return 0; 127 return 0;
130 if (size > 0x100) 128 if (size > 0x100)
131 { 129 {
@@ -188,8 +186,7 @@ ftxfont_draw_bitmap (struct frame *f, GC gc_fore, GC *gcs, struct font *font,
188 } 186 }
189 } 187 }
190 188
191 if (ftfont_driver.free_bitmap) 189 /* There is no ftfont_free_bitmap, so do not try to free BITMAP. */
192 ftfont_driver.free_bitmap (font, &bitmap);
193 190
194 return bitmap.advance; 191 return bitmap.advance;
195} 192}
@@ -211,7 +208,7 @@ ftxfont_draw_background (struct frame *f, struct font *font, GC gc, int x, int y
211static Lisp_Object 208static Lisp_Object
212ftxfont_list (struct frame *f, Lisp_Object spec) 209ftxfont_list (struct frame *f, Lisp_Object spec)
213{ 210{
214 Lisp_Object list = ftfont_driver.list (f, spec), tail; 211 Lisp_Object list = ftfont_list (f, spec), tail;
215 212
216 for (tail = list; CONSP (tail); tail = XCDR (tail)) 213 for (tail = list; CONSP (tail); tail = XCDR (tail))
217 ASET (XCAR (tail), FONT_TYPE_INDEX, Qftx); 214 ASET (XCAR (tail), FONT_TYPE_INDEX, Qftx);
@@ -221,7 +218,7 @@ ftxfont_list (struct frame *f, Lisp_Object spec)
221static Lisp_Object 218static Lisp_Object
222ftxfont_match (struct frame *f, Lisp_Object spec) 219ftxfont_match (struct frame *f, Lisp_Object spec)
223{ 220{
224 Lisp_Object entity = ftfont_driver.match (f, spec); 221 Lisp_Object entity = ftfont_match (f, spec);
225 222
226 if (VECTORP (entity)) 223 if (VECTORP (entity))
227 ASET (entity, FONT_TYPE_INDEX, Qftx); 224 ASET (entity, FONT_TYPE_INDEX, Qftx);
@@ -231,13 +228,10 @@ ftxfont_match (struct frame *f, Lisp_Object spec)
231static Lisp_Object 228static Lisp_Object
232ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size) 229ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
233{ 230{
234 Lisp_Object font_object; 231 Lisp_Object font_object = ftfont_open (f, entity, pixel_size);
235 struct font *font;
236
237 font_object = ftfont_driver.open (f, entity, pixel_size);
238 if (NILP (font_object)) 232 if (NILP (font_object))
239 return Qnil; 233 return Qnil;
240 font = XFONT_OBJECT (font_object); 234 struct font *font = XFONT_OBJECT (font_object);
241 font->driver = &ftxfont_driver; 235 font->driver = &ftxfont_driver;
242 return font_object; 236 return font_object;
243} 237}
@@ -245,7 +239,7 @@ ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
245static void 239static void
246ftxfont_close (struct font *font) 240ftxfont_close (struct font *font)
247{ 241{
248 ftfont_driver.close (font); 242 ftfont_close (font);
249} 243}
250 244
251static int 245static int
@@ -345,18 +339,39 @@ ftxfont_end_for_frame (struct frame *f)
345 339
346 340
347 341
342struct font_driver const ftxfont_driver =
343 {
344 /* We can't draw a text without device dependent functions. */
345 type: LISPSYM_INITIALLY (Qftx),
346 get_cache: ftfont_get_cache,
347 list: ftxfont_list,
348 match: ftxfont_match,
349 list_family: ftfont_list_family,
350 open: ftxfont_open,
351 close: ftxfont_close,
352 has_char: ftfont_has_char,
353 encode_char: ftfont_encode_char,
354 text_extents: ftfont_text_extents,
355 draw: ftxfont_draw,
356 get_bitmap: ftfont_get_bitmap,
357 anchor_point: ftfont_anchor_point,
358#ifdef HAVE_LIBOTF
359 otf_capability: ftfont_otf_capability,
360#endif
361 end_for_frame: ftxfont_end_for_frame,
362#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
363 shape: ftfont_shape,
364#endif
365#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
366 get_variation_glyphs: ftfont_variation_glyphs,
367#endif
368 filter_properties: ftfont_filter_properties,
369 combining_capability: ftfont_combining_capability,
370 };
371
348void 372void
349syms_of_ftxfont (void) 373syms_of_ftxfont (void)
350{ 374{
351 DEFSYM (Qftx, "ftx"); 375 DEFSYM (Qftx, "ftx");
352
353 ftxfont_driver = ftfont_driver;
354 ftxfont_driver.type = Qftx;
355 ftxfont_driver.list = ftxfont_list;
356 ftxfont_driver.match = ftxfont_match;
357 ftxfont_driver.open = ftxfont_open;
358 ftxfont_driver.close = ftxfont_close;
359 ftxfont_driver.draw = ftxfont_draw;
360 ftxfont_driver.end_for_frame = ftxfont_end_for_frame;
361 register_font_driver (&ftxfont_driver, NULL); 376 register_font_driver (&ftxfont_driver, NULL);
362} 377}
diff --git a/src/macfont.m b/src/macfont.m
index b3a2fb84205..b2f3dff3097 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -38,8 +38,6 @@ Original author: YAMAMOTO Mitsuharu
38 38
39#include <libkern/OSByteOrder.h> 39#include <libkern/OSByteOrder.h>
40 40
41static struct font_driver macfont_driver;
42
43static double mac_font_get_advance_width_for_glyph (CTFontRef, CGGlyph); 41static double mac_font_get_advance_width_for_glyph (CTFontRef, CGGlyph);
44static CGRect mac_font_get_bounding_rect_for_glyph (CTFontRef, CGGlyph); 42static CGRect mac_font_get_bounding_rect_for_glyph (CTFontRef, CGGlyph);
45static CFArrayRef mac_font_create_available_families (void); 43static CFArrayRef mac_font_create_available_families (void);
@@ -893,7 +891,7 @@ macfont_descriptor_entity (CTFontDescriptorRef desc, Lisp_Object extra,
893 891
894 entity = font_make_entity (); 892 entity = font_make_entity ();
895 893
896 ASET (entity, FONT_TYPE_INDEX, macfont_driver.type); 894 ASET (entity, FONT_TYPE_INDEX, Qmac_ct);
897 ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1); 895 ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1);
898 896
899 macfont_store_descriptor_attributes (desc, entity); 897 macfont_store_descriptor_attributes (desc, entity);
@@ -1663,34 +1661,23 @@ static int macfont_variation_glyphs (struct font *, int c,
1663 unsigned variations[256]); 1661 unsigned variations[256]);
1664static void macfont_filter_properties (Lisp_Object, Lisp_Object); 1662static void macfont_filter_properties (Lisp_Object, Lisp_Object);
1665 1663
1666static struct font_driver macfont_driver = 1664static struct font_driver const macfont_driver =
1667 { 1665 {
1668 LISPSYM_INITIALLY (Qmac_ct), 1666 type: LISPSYM_INITIALLY (Qmac_ct),
1669 0, /* case insensitive */ 1667 get_cache: macfont_get_cache,
1670 macfont_get_cache, 1668 list: macfont_list,
1671 macfont_list, 1669 match: macfont_match,
1672 macfont_match, 1670 list_family: macfont_list_family,
1673 macfont_list_family, 1671 free_entity: macfont_free_entity,
1674 macfont_free_entity, 1672 open: macfont_open,
1675 macfont_open, 1673 close: macfont_close,
1676 macfont_close, 1674 has_char: macfont_has_char,
1677 NULL, /* prepare_face */ 1675 encode_char: macfont_encode_char,
1678 NULL, /* done_face */ 1676 text_extents: macfont_text_extents,
1679 macfont_has_char, 1677 draw: macfont_draw,
1680 macfont_encode_char, 1678 shape: macfont_shape,
1681 macfont_text_extents, 1679 get_variation_glyphs: macfont_variation_glyphs,
1682 macfont_draw, 1680 filter_properties: macfont_filter_properties,
1683 NULL, /* get_bitmap */
1684 NULL, /* free_bitmap */
1685 NULL, /* anchor_point */
1686 NULL, /* otf_capability */
1687 NULL, /* otf_drive */
1688 NULL, /* start_for_frame */
1689 NULL, /* end_for_frame */
1690 macfont_shape,
1691 NULL, /* check */
1692 macfont_variation_glyphs,
1693 macfont_filter_properties,
1694 }; 1681 };
1695 1682
1696static Lisp_Object 1683static Lisp_Object
diff --git a/src/nsfont.m b/src/nsfont.m
index c4c3c8dce7e..d14c362eddf 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -610,43 +610,6 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
610 ========================================================================== */ 610 ========================================================================== */
611 611
612 612
613static Lisp_Object nsfont_get_cache (struct frame *frame);
614static Lisp_Object nsfont_list (struct frame *, Lisp_Object);
615static Lisp_Object nsfont_match (struct frame *, Lisp_Object);
616static Lisp_Object nsfont_list_family (struct frame *);
617static Lisp_Object nsfont_open (struct frame *f, Lisp_Object font_entity,
618 int pixel_size);
619static void nsfont_close (struct font *font);
620static int nsfont_has_char (Lisp_Object entity, int c);
621static unsigned int nsfont_encode_char (struct font *font, int c);
622static void nsfont_text_extents (struct font *font, unsigned int *code,
623 int nglyphs, struct font_metrics *metrics);
624static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
625 bool with_background);
626
627struct font_driver nsfont_driver =
628 {
629 LISPSYM_INITIALLY (Qns),
630 1, /* case sensitive */
631 nsfont_get_cache,
632 nsfont_list,
633 nsfont_match,
634 nsfont_list_family,
635 NULL, /*free_entity */
636 nsfont_open,
637 nsfont_close,
638 NULL, /* prepare_face */
639 NULL, /* done_face */
640 nsfont_has_char,
641 nsfont_encode_char,
642 nsfont_text_extents,
643 nsfont_draw,
644 /* excluded: get_bitmap, free_bitmap,
645 anchor_point, otf_capability, otf_driver,
646 start_for_frame, end_for_frame, shape */
647 };
648
649
650/* Return a cache of font-entities on FRAME. The cache must be a 613/* Return a cache of font-entities on FRAME. The cache must be a
651 cons whose cdr part is the actual cache area. */ 614 cons whose cdr part is the actual cache area. */
652static Lisp_Object 615static Lisp_Object
@@ -788,7 +751,7 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
788 751
789 font_object = font_make_object (VECSIZE (struct nsfont_info), 752 font_object = font_make_object (VECSIZE (struct nsfont_info),
790 font_entity, pixel_size); 753 font_entity, pixel_size);
791 ASET (font_object, FONT_TYPE_INDEX, nsfont_driver.type); 754 ASET (font_object, FONT_TYPE_INDEX, Qns);
792 font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); 755 font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
793 font = (struct font *) font_info; 756 font = (struct font *) font_info;
794 if (!font) 757 if (!font)
@@ -1520,6 +1483,21 @@ ns_dump_glyphstring (struct glyph_string *s)
1520 fprintf (stderr, "\n"); 1483 fprintf (stderr, "\n");
1521} 1484}
1522 1485
1486struct font_driver const nsfont_driver =
1487 {
1488 type: LISPSYM_INITIALLY (Qns),
1489 case_sensitive: true,
1490 get_cache: nsfont_get_cache,
1491 list: nsfont_list,
1492 match: nsfont_match,
1493 list_family: nsfont_list_family,
1494 open: nsfont_open,
1495 close: nsfont_close,
1496 has_char: nsfont_has_char,
1497 encode_char: nsfont_encode_char,
1498 text_extents: nsfont_text_extents,
1499 draw: nsfont_draw,
1500 };
1523 1501
1524void 1502void
1525syms_of_nsfont (void) 1503syms_of_nsfont (void)
diff --git a/src/xfont.c b/src/xfont.c
index ccb8f070626..5999f6715cc 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -113,44 +113,7 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
113 ? NULL : pcm); 113 ? NULL : pcm);
114} 114}
115 115
116static Lisp_Object xfont_get_cache (struct frame *); 116Lisp_Object
117static Lisp_Object xfont_list (struct frame *, Lisp_Object);
118static Lisp_Object xfont_match (struct frame *, Lisp_Object);
119static Lisp_Object xfont_list_family (struct frame *);
120static Lisp_Object xfont_open (struct frame *, Lisp_Object, int);
121static void xfont_close (struct font *);
122static void xfont_prepare_face (struct frame *, struct face *);
123static int xfont_has_char (Lisp_Object, int);
124static unsigned xfont_encode_char (struct font *, int);
125static void xfont_text_extents (struct font *, unsigned *, int,
126 struct font_metrics *);
127static int xfont_draw (struct glyph_string *, int, int, int, int, bool);
128static int xfont_check (struct frame *, struct font *);
129
130struct font_driver xfont_driver =
131 {
132 LISPSYM_INITIALLY (Qx),
133 false, /* case insensitive */
134 xfont_get_cache,
135 xfont_list,
136 xfont_match,
137 xfont_list_family,
138 NULL,
139 xfont_open,
140 xfont_close,
141 xfont_prepare_face,
142 NULL,
143 xfont_has_char,
144 xfont_encode_char,
145 xfont_text_extents,
146 xfont_draw,
147 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
148 xfont_check,
149 NULL, /* get_variation_glyphs */
150 NULL, /* filter_properties */
151 };
152
153static Lisp_Object
154xfont_get_cache (struct frame *f) 117xfont_get_cache (struct frame *f)
155{ 118{
156 Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); 119 Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
@@ -1113,6 +1076,24 @@ xfont_check (struct frame *f, struct font *font)
1113} 1076}
1114 1077
1115 1078
1079
1080struct font_driver const xfont_driver =
1081 {
1082 type: LISPSYM_INITIALLY (Qx),
1083 get_cache: xfont_get_cache,
1084 list: xfont_list,
1085 match: xfont_match,
1086 list_family: xfont_list_family,
1087 open: xfont_open,
1088 close: xfont_close,
1089 prepare_face: xfont_prepare_face,
1090 has_char: xfont_has_char,
1091 encode_char: xfont_encode_char,
1092 text_extents: xfont_text_extents,
1093 draw: xfont_draw,
1094 check: xfont_check,
1095 };
1096
1116void 1097void
1117syms_of_xfont (void) 1098syms_of_xfont (void)
1118{ 1099{
diff --git a/src/xftfont.c b/src/xftfont.c
index 861ad80da5c..74f5ec66e74 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -125,15 +125,12 @@ xftfont_get_colors (struct frame *f, struct face *face, GC gc,
125 } 125 }
126} 126}
127 127
128
129struct font_driver xftfont_driver;
130
131static Lisp_Object 128static Lisp_Object
132xftfont_list (struct frame *f, Lisp_Object spec) 129xftfont_list (struct frame *f, Lisp_Object spec)
133{ 130{
134 Lisp_Object list = ftfont_driver.list (f, spec), tail; 131 Lisp_Object list = ftfont_list (f, spec);
135 132
136 for (tail = list; CONSP (tail); tail = XCDR (tail)) 133 for (Lisp_Object tail = list; CONSP (tail); tail = XCDR (tail))
137 ASET (XCAR (tail), FONT_TYPE_INDEX, Qxft); 134 ASET (XCAR (tail), FONT_TYPE_INDEX, Qxft);
138 return list; 135 return list;
139} 136}
@@ -141,7 +138,7 @@ xftfont_list (struct frame *f, Lisp_Object spec)
141static Lisp_Object 138static Lisp_Object
142xftfont_match (struct frame *f, Lisp_Object spec) 139xftfont_match (struct frame *f, Lisp_Object spec)
143{ 140{
144 Lisp_Object entity = ftfont_driver.match (f, spec); 141 Lisp_Object entity = ftfont_match (f, spec);
145 142
146 if (! NILP (entity)) 143 if (! NILP (entity))
147 ASET (entity, FONT_TYPE_INDEX, Qxft); 144 ASET (entity, FONT_TYPE_INDEX, Qxft);
@@ -542,7 +539,7 @@ xftfont_has_char (Lisp_Object font, int c)
542 return (ENCODE_CHAR (cs, c) != CHARSET_INVALID_CODE (cs)); 539 return (ENCODE_CHAR (cs, c) != CHARSET_INVALID_CODE (cs));
543 540
544 if (FONT_ENTITY_P (font)) 541 if (FONT_ENTITY_P (font))
545 return ftfont_driver.has_char (font, c); 542 return ftfont_has_char (font, c);
546 xftfont_info = (struct xftfont_info *) XFONT_OBJECT (font); 543 xftfont_info = (struct xftfont_info *) XFONT_OBJECT (font);
547 return (XftCharExists (xftfont_info->display, xftfont_info->xftfont, 544 return (XftCharExists (xftfont_info->display, xftfont_info->xftfont,
548 (FcChar32) c) == FcTrue); 545 (FcChar32) c) == FcTrue);
@@ -668,12 +665,9 @@ xftfont_shape (Lisp_Object lgstring)
668{ 665{
669 struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); 666 struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
670 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; 667 struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
671 FT_Face ft_face; 668 FT_Face ft_face = XftLockFace (xftfont_info->xftfont);
672 Lisp_Object val;
673
674 ft_face = XftLockFace (xftfont_info->xftfont);
675 xftfont_info->ft_size = ft_face->size; 669 xftfont_info->ft_size = ft_face->size;
676 val = ftfont_driver.shape (lgstring); 670 Lisp_Object val = ftfont_shape (lgstring);
677 XftUnlockFace (xftfont_info->xftfont); 671 XftUnlockFace (xftfont_info->xftfont);
678 return val; 672 return val;
679} 673}
@@ -697,6 +691,10 @@ xftfont_end_for_frame (struct frame *f)
697 return 0; 691 return 0;
698} 692}
699 693
694/* When using X double buffering, the XftDraw structure we build
695 seems to be useless once a frame is resized, so recreate it on
696 ConfigureNotify and in some other cases. */
697
700static void 698static void
701xftfont_drop_xrender_surfaces (struct frame *f) 699xftfont_drop_xrender_surfaces (struct frame *f)
702{ 700{
@@ -751,6 +749,40 @@ xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object,
751 return ok; 749 return ok;
752} 750}
753 751
752struct font_driver const xftfont_driver =
753 {
754 /* We can't draw a text without device dependent functions. */
755 type: LISPSYM_INITIALLY (Qxft),
756 get_cache: xfont_get_cache,
757 list: xftfont_list,
758 match: xftfont_match,
759 list_family: ftfont_list_family,
760 open: xftfont_open,
761 close: xftfont_close,
762 prepare_face: xftfont_prepare_face,
763 done_face: xftfont_done_face,
764 has_char: xftfont_has_char,
765 encode_char: xftfont_encode_char,
766 text_extents: xftfont_text_extents,
767 draw: xftfont_draw,
768 get_bitmap: ftfont_get_bitmap,
769 anchor_point: ftfont_anchor_point,
770#ifdef HAVE_LIBOTF
771 otf_capability: ftfont_otf_capability,
772#endif
773 end_for_frame: xftfont_end_for_frame,
774#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
775 shape: xftfont_shape,
776#endif
777#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
778 get_variation_glyphs: ftfont_variation_glyphs,
779#endif
780 filter_properties: ftfont_filter_properties,
781 cached_font_ok: xftfont_cached_font_ok,
782 combining_capability: ftfont_combining_capability,
783 drop_xrender_surfaces: xftfont_drop_xrender_surfaces,
784 };
785
754void 786void
755syms_of_xftfont (void) 787syms_of_xftfont (void)
756{ 788{
@@ -770,28 +802,5 @@ This is needed with some fonts to correct vertical overlap of glyphs. */);
770 802
771 ascii_printable[0] = 0; 803 ascii_printable[0] = 0;
772 804
773 xftfont_driver = ftfont_driver;
774 xftfont_driver.type = Qxft;
775 xftfont_driver.get_cache = xfont_driver.get_cache;
776 xftfont_driver.list = xftfont_list;
777 xftfont_driver.match = xftfont_match;
778 xftfont_driver.open = xftfont_open;
779 xftfont_driver.close = xftfont_close;
780 xftfont_driver.prepare_face = xftfont_prepare_face;
781 xftfont_driver.done_face = xftfont_done_face;
782 xftfont_driver.has_char = xftfont_has_char;
783 xftfont_driver.encode_char = xftfont_encode_char;
784 xftfont_driver.text_extents = xftfont_text_extents;
785 xftfont_driver.draw = xftfont_draw;
786 xftfont_driver.end_for_frame = xftfont_end_for_frame;
787 xftfont_driver.cached_font_ok = xftfont_cached_font_ok;
788#if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF)
789 xftfont_driver.shape = xftfont_shape;
790#endif
791 /* When using X double buffering, the XftDraw structure we build
792 seems to be useless once a frame is resized, so recreate it on
793 ConfigureNotify and in some other cases. */
794 xftfont_driver.drop_xrender_surfaces = xftfont_drop_xrender_surfaces;
795
796 register_font_driver (&xftfont_driver, NULL); 805 register_font_driver (&xftfont_driver, NULL);
797} 806}