Commit ebb96114 authored by Paul Eggert's avatar Paul Eggert

Make struct font_drivers read-only

This simplifies the code a bit, and makes the structs more
shareable and less likely to become corrupt.
* src/alloc.c (cleanup_vector):
* src/font.c (valid_font_driver, font_prepare_cache)
(font_finish_cache, font_get_cache, font_clear_cache)
(register_font_driver, font_update_drivers):
* src/font.h (struct font, struct font_driver_list)
(valid_font_driver):
struct font_drivers are now const.
* src/font.c, src/ftcrfont.c, src/ftfont.c, src/nsfont.m, src/xfont.c:
Omit no-longer-necessary decls.
* src/ftcrfont.c (syms_of_ftcrfont):
* src/ftxfont.c (syms_of_ftxfont):
* src/xftfont.c (syms_of_xftfont):
Omit no-longer-necessary initialization code.
* src/ftcrfont.c (ftcrfont_driver):
* src/ftfont.c (ftfont_driver):
* src/ftxfont.c (ftxfont_driver):
* src/macfont.m (macfont_driver):
* src/nsfont.m (nsfont_driver):
* src/xfont.c (xfont_driver):
* src/xftfont.c (xftfont_driver):
Use C99-style initializer for ease of maintenance, and make it const.
* src/ftcrfont.c, src/ftxfont.c, src/xftfont.c:
Refer to functions like ftfont_text_extents directly.
* src/ftfont.c (ftfont_get_cache, ftfont_list, ftfont_list_family)
(ftfont_has_char, ftfont_encode_char, ftfont_text_extents)
(ftfont_get_bitmap, ftfont_anchor_point, ftfont_otf_capability)
(ftfont_variation_glyphs, ftfont_filter_properties)
(ftfont_combining_capability):
* src/xfont.c (xfont_get_cache):
Now extern, so that other modules’ struct font_drivers can use
them directly.
* src/macfont.m (macfont_descriptor_entity):
* src/nsfont.m (nsfont_open):
Use constant directly; this is clearer.
parent dd4b9131
......@@ -3201,7 +3201,7 @@ cleanup_vector (struct Lisp_Vector *vector)
&& ((vector->header.size & PSEUDOVECTOR_SIZE_MASK)
== FONT_OBJECT_MAX))
{
struct font_driver *drv = ((struct font *) vector)->driver;
struct font_driver const *drv = ((struct font *) vector)->driver;
/* The font driver might sometimes be NULL, e.g. if Emacs was
interrupted before it had time to set it up. */
......
......@@ -132,7 +132,7 @@ static struct font_driver_list *font_driver_list;
/* Used to catch bogus pointers in font objects. */
bool
valid_font_driver (struct font_driver *drv)
valid_font_driver (struct font_driver const *drv)
{
Lisp_Object tail, frame;
struct font_driver_list *fdl;
......@@ -2543,14 +2543,11 @@ font_match_p (Lisp_Object spec, Lisp_Object font)
is a number frames sharing this cache, and FONT-CACHE-DATA is a
cons (FONT-SPEC . [FONT-ENTITY ...]). */
static void font_prepare_cache (struct frame *, struct font_driver *);
static void font_finish_cache (struct frame *, struct font_driver *);
static Lisp_Object font_get_cache (struct frame *, struct font_driver *);
static void font_clear_cache (struct frame *, Lisp_Object,
struct font_driver *);
struct font_driver const *);
static void
font_prepare_cache (struct frame *f, struct font_driver *driver)
font_prepare_cache (struct frame *f, struct font_driver const *driver)
{
Lisp_Object cache, val;
......@@ -2572,7 +2569,7 @@ font_prepare_cache (struct frame *f, struct font_driver *driver)
static void
font_finish_cache (struct frame *f, struct font_driver *driver)
font_finish_cache (struct frame *f, struct font_driver const *driver)
{
Lisp_Object cache, val, tmp;
......@@ -2593,7 +2590,7 @@ font_finish_cache (struct frame *f, struct font_driver *driver)
static Lisp_Object
font_get_cache (struct frame *f, struct font_driver *driver)
font_get_cache (struct frame *f, struct font_driver const *driver)
{
Lisp_Object val = driver->get_cache (f);
Lisp_Object type = driver->type;
......@@ -2608,7 +2605,8 @@ font_get_cache (struct frame *f, struct font_driver *driver)
static void
font_clear_cache (struct frame *f, Lisp_Object cache, struct font_driver *driver)
font_clear_cache (struct frame *f, Lisp_Object cache,
struct font_driver const *driver)
{
Lisp_Object tail, elt;
Lisp_Object entity;
......@@ -3463,7 +3461,7 @@ font_open_by_name (struct frame *f, Lisp_Object name)
(e.g. syms_of_xfont). */
void
register_font_driver (struct font_driver *driver, struct frame *f)
register_font_driver (struct font_driver const *driver, struct frame *f)
{
struct font_driver_list *root = f ? f->font_driver_list : font_driver_list;
struct font_driver_list *prev, *list;
......@@ -3524,7 +3522,7 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers)
drivers. */
for (list = f->font_driver_list; list; list = list->next)
{
struct font_driver *driver = list->driver;
struct font_driver const *driver = list->driver;
if ((EQ (new_drivers, Qt) || ! NILP (Fmemq (driver->type, new_drivers)))
!= list->on)
{
......@@ -3587,7 +3585,7 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers)
and then use it under w32 or ns. */
for (list = f->font_driver_list; list; list = list->next)
{
struct font_driver *driver = list->driver;
struct font_driver const *driver = list->driver;
eassert (! list->on);
if (! driver->start_for_frame
|| driver->start_for_frame (f) == 0)
......
......@@ -380,7 +380,7 @@ struct font
#endif /* HAVE_WINDOW_SYSTEM */
/* Font-driver for the font. */
struct font_driver *driver;
struct font_driver const *driver;
/* There are more members in this structure, but they are private
to the font-driver. */
......@@ -783,7 +783,7 @@ struct font_driver_list
font driver list.*/
bool on;
/* Pointer to the font driver. */
struct font_driver *driver;
struct font_driver const *driver;
/* Pointer to the next element of the chain. */
struct font_driver_list *next;
};
......@@ -841,13 +841,13 @@ extern void font_parse_family_registry (Lisp_Object family,
extern int font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font);
extern ptrdiff_t font_unparse_xlfd (Lisp_Object font, int pixel_size,
char *name, int bytes);
extern void register_font_driver (struct font_driver *driver, struct frame *f);
extern void register_font_driver (struct font_driver const *, struct frame *);
extern void free_font_driver_list (struct frame *f);
#ifdef ENABLE_CHECKING
extern bool valid_font_driver (struct font_driver *);
extern bool valid_font_driver (struct font_driver const *);
#else
INLINE bool
valid_font_driver (struct font_driver *d)
valid_font_driver (struct font_driver const *d)
{
return true;
}
......@@ -874,18 +874,37 @@ extern void font_filter_properties (Lisp_Object font,
extern void font_drop_xrender_surfaces (struct frame *f);
#ifdef HAVE_FREETYPE
extern struct font_driver ftfont_driver;
extern int ftfont_anchor_point (struct font *, unsigned int, int,
int *, int *);
extern int ftfont_get_bitmap (struct font *, unsigned int,
struct font_bitmap *, int);
extern int ftfont_has_char (Lisp_Object, int);
extern int ftfont_variation_glyphs (struct font *, int, unsigned[256]);
extern Lisp_Object ftfont_combining_capability (struct font *);
extern Lisp_Object ftfont_get_cache (struct frame *);
extern Lisp_Object ftfont_list (struct frame *, Lisp_Object);
extern Lisp_Object ftfont_list_family (struct frame *);
extern Lisp_Object ftfont_match (struct frame *, Lisp_Object);
extern Lisp_Object ftfont_open (struct frame *, Lisp_Object, int);
extern Lisp_Object ftfont_otf_capability (struct font *);
extern Lisp_Object ftfont_shape (Lisp_Object);
extern unsigned ftfont_encode_char (struct font *, int);
extern void ftfont_close (struct font *);
extern void ftfont_filter_properties (Lisp_Object, Lisp_Object);
extern void ftfont_text_extents (struct font *, unsigned *, int,
struct font_metrics *);
extern void syms_of_ftfont (void);
#endif /* HAVE_FREETYPE */
#ifdef HAVE_X_WINDOWS
extern struct font_driver xfont_driver;
extern struct font_driver const xfont_driver;
extern Lisp_Object xfont_get_cache (struct frame *);
extern void syms_of_xfont (void);
extern void syms_of_ftxfont (void);
#ifdef HAVE_XFT
extern struct font_driver xftfont_driver;
extern struct font_driver const xftfont_driver;
#endif
#if defined HAVE_FREETYPE || defined HAVE_XFT
extern struct font_driver ftxfont_driver;
extern struct font_driver const ftxfont_driver;
extern void syms_of_xftfont (void);
#endif
#ifdef HAVE_BDFFONT
......@@ -898,12 +917,12 @@ extern struct font_driver uniscribe_font_driver;
extern void syms_of_w32font (void);
#endif /* HAVE_NTGUI */
#ifdef HAVE_NS
extern struct font_driver nsfont_driver;
extern struct font_driver const nsfont_driver;
extern void syms_of_nsfont (void);
extern void syms_of_macfont (void);
#endif /* HAVE_NS */
#ifdef USE_CAIRO
extern struct font_driver ftcrfont_driver;
extern struct font_driver const ftcrfont_driver;
extern void syms_of_ftcrfont (void);
#endif
......
......@@ -65,8 +65,6 @@ enum metrics_status
#define METRICS_SET_STATUS(metrics, status) \
((metrics)->ascent = 0, (metrics)->descent = (status))
struct font_driver ftcrfont_driver;
static int
ftcrfont_glyph_extents (struct font *font,
unsigned glyph,
......@@ -101,7 +99,7 @@ ftcrfont_glyph_extents (struct font *font,
cache = ftcrfont_info->metrics[row] + col;
if (METRICS_STATUS (cache) == METRICS_INVALID)
ftfont_driver.text_extents (font, &glyph, 1, cache);
ftfont_text_extents (font, &glyph, 1, cache);
if (metrics)
*metrics = *cache;
......@@ -112,7 +110,7 @@ ftcrfont_glyph_extents (struct font *font,
static Lisp_Object
ftcrfont_list (struct frame *f, Lisp_Object spec)
{
Lisp_Object list = ftfont_driver.list (f, spec), tail;
Lisp_Object list = ftfont_list (f, spec), tail;
for (tail = list; CONSP (tail); tail = XCDR (tail))
ASET (XCAR (tail), FONT_TYPE_INDEX, Qftcr);
......@@ -122,15 +120,13 @@ ftcrfont_list (struct frame *f, Lisp_Object spec)
static Lisp_Object
ftcrfont_match (struct frame *f, Lisp_Object spec)
{
Lisp_Object entity = ftfont_driver.match (f, spec);
Lisp_Object entity = ftfont_match (f, spec);
if (VECTORP (entity))
ASET (entity, FONT_TYPE_INDEX, Qftcr);
return entity;
}
extern FT_Face ftfont_get_ft_face (Lisp_Object);
static Lisp_Object
ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
{
......@@ -181,7 +177,7 @@ ftcrfont_close (struct font *font)
cairo_font_face_destroy (ftcrfont_info->cr_font_face);
unblock_input ();
ftfont_driver.close (font);
ftfont_close (font);
}
static void
......@@ -282,6 +278,34 @@ ftcrfont_draw (struct glyph_string *s,
struct font_driver const ftcrfont_driver =
{
type: LISPSYM_INITIALLY (Qftcr),
get_cache: ftfont_get_cache,
list: ftcrfont_list,
match: ftcrfont_match,
list_family: ftfont_list_family,
open: ftcrfont_open,
close: ftcrfont_close,
has_char: ftfont_has_char,
encode_char: ftfont_encode_char,
text_extents: ftcrfont_text_extents,
draw: ftcrfont_draw,
get_bitmap: ftfont_get_bitmap,
anchor_point: ftfont_anchor_point,
#ifdef HAVE_LIBOTF
otf_capability: ftfont_otf_capability,
#endif
#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
shape: ftfont_shape,
#endif
#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
get_variation_glyphs: ftfont_variation_glyphs,
#endif
filter_properties: ftfont_filter_properties,
combining_capability: ftfont_combining_capability,
};
void
syms_of_ftcrfont (void)
{
......@@ -289,14 +313,5 @@ syms_of_ftcrfont (void)
abort ();
DEFSYM (Qftcr, "ftcr");
ftcrfont_driver = ftfont_driver;
ftcrfont_driver.type = Qftcr;
ftcrfont_driver.list = ftcrfont_list;
ftcrfont_driver.match = ftcrfont_match;
ftcrfont_driver.open = ftcrfont_open;
ftcrfont_driver.close = ftcrfont_close;
ftcrfont_driver.text_extents = ftcrfont_text_extents;
ftcrfont_driver.draw = ftcrfont_draw;
register_font_driver (&ftcrfont_driver, NULL);
}
......@@ -35,6 +35,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "font.h"
#include "ftfont.h"
static struct font_driver const ftfont_driver;
/* Flag to tell if FcInit is already called or not. */
static bool fc_initialized;
......@@ -73,17 +75,9 @@ enum ftfont_cache_for
FTFONT_CACHE_FOR_ENTITY
};
static Lisp_Object ftfont_pattern_entity (FcPattern *, Lisp_Object);
static Lisp_Object ftfont_resolve_generic_family (Lisp_Object,
FcPattern *);
static Lisp_Object ftfont_lookup_cache (Lisp_Object,
enum ftfont_cache_for);
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
......@@ -480,83 +474,7 @@ ftfont_get_otf (struct ftfont_info *ftfont_info)
}
#endif /* HAVE_LIBOTF */
static Lisp_Object ftfont_get_cache (struct frame *);
static Lisp_Object ftfont_list (struct frame *, Lisp_Object);
static Lisp_Object ftfont_match (struct frame *, Lisp_Object);
static Lisp_Object ftfont_list_family (struct frame *);
static Lisp_Object ftfont_open (struct frame *, Lisp_Object, int);
static void ftfont_close (struct font *);
static int ftfont_has_char (Lisp_Object, int);
static unsigned ftfont_encode_char (struct font *, int);
static void ftfont_text_extents (struct font *, unsigned *, int,
struct font_metrics *);
static int ftfont_get_bitmap (struct font *, unsigned,
struct font_bitmap *, int);
static int ftfont_anchor_point (struct font *, unsigned, int,
int *, int *);
#ifdef HAVE_LIBOTF
static Lisp_Object ftfont_otf_capability (struct font *);
# ifdef HAVE_M17N_FLT
static Lisp_Object ftfont_shape (Lisp_Object);
# endif
#endif
#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
static int ftfont_variation_glyphs (struct font *, int c,
unsigned variations[256]);
#endif /* HAVE_OTF_GET_VARIATION_GLYPHS */
struct font_driver ftfont_driver =
{
LISPSYM_INITIALLY (Qfreetype),
0, /* case insensitive */
ftfont_get_cache,
ftfont_list,
ftfont_match,
ftfont_list_family,
NULL, /* free_entity */
ftfont_open,
ftfont_close,
/* We can't draw a text without device dependent functions. */
NULL, /* prepare_face */
NULL, /* done_face */
ftfont_has_char,
ftfont_encode_char,
ftfont_text_extents,
/* We can't draw a text without device dependent functions. */
NULL, /* draw */
ftfont_get_bitmap,
NULL, /* free_bitmap */
ftfont_anchor_point,
#ifdef HAVE_LIBOTF
ftfont_otf_capability,
#else /* not HAVE_LIBOTF */
NULL,
#endif /* not HAVE_LIBOTF */
NULL, /* otf_drive */
NULL, /* start_for_frame */
NULL, /* end_for_frame */
#if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF)
ftfont_shape,
#else /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
NULL,
#endif /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
NULL, /* check */
#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
ftfont_variation_glyphs,
#else
NULL,
#endif
ftfont_filter_properties, /* filter_properties */
NULL, /* cached_font_ok */
ftfont_combining_capability,
};
static Lisp_Object
Lisp_Object
ftfont_get_cache (struct frame *f)
{
return freetype_font_cache;
......@@ -873,7 +791,7 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots
return pattern;
}
static Lisp_Object
Lisp_Object
ftfont_list (struct frame *f, Lisp_Object spec)
{
Lisp_Object val = Qnil, family, adstyle;
......@@ -1072,7 +990,7 @@ ftfont_list (struct frame *f, Lisp_Object spec)
return val;
}
static Lisp_Object
Lisp_Object
ftfont_match (struct frame *f, Lisp_Object spec)
{
Lisp_Object entity = Qnil;
......@@ -1122,7 +1040,7 @@ ftfont_match (struct frame *f, Lisp_Object spec)
return entity;
}
static Lisp_Object
Lisp_Object
ftfont_list_family (struct frame *f)
{
Lisp_Object list = Qnil;
......@@ -1301,7 +1219,7 @@ ftfont_open2 (struct frame *f,
return font_object;
}
static Lisp_Object
Lisp_Object
ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
{
Lisp_Object font_object;
......@@ -1314,7 +1232,7 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
return ftfont_open2 (f, entity, pixel_size, font_object);
}
static void
void
ftfont_close (struct font *font)
{
/* FIXME: Although this function can be called while garbage-collecting,
......@@ -1344,7 +1262,7 @@ ftfont_close (struct font *font)
FT_Done_Size (ftfont_info->ft_size);
}
static int
int
ftfont_has_char (Lisp_Object font, int c)
{
struct charset *cs = NULL;
......@@ -1374,7 +1292,7 @@ ftfont_has_char (Lisp_Object font, int c)
}
}
static unsigned
unsigned
ftfont_encode_char (struct font *font, int c)
{
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
......@@ -1385,7 +1303,7 @@ ftfont_encode_char (struct font *font, int c)
return (code > 0 ? code : FONT_INVALID_CODE);
}
static void
void
ftfont_text_extents (struct font *font, unsigned int *code,
int nglyphs, struct font_metrics *metrics)
{
......@@ -1429,7 +1347,7 @@ ftfont_text_extents (struct font *font, unsigned int *code,
metrics->width = width;
}
static int
int
ftfont_get_bitmap (struct font *font, unsigned int code, struct font_bitmap *bitmap, int bits_per_pixel)
{
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
return 0;
}
static int
int
ftfont_anchor_point (struct font *font, unsigned int code, int idx,
int *x, int *y)
{
......@@ -1538,7 +1456,7 @@ ftfont_otf_features (OTF_GSUB_GPOS *gsub_gpos)
}
static Lisp_Object
Lisp_Object
ftfont_otf_capability (struct font *font)
{
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
......@@ -2701,7 +2619,7 @@ ftfont_shape (Lisp_Object lgstring)
#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
static int
int
ftfont_variation_glyphs (struct font *font, int c, unsigned variations[256])
{
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
......@@ -2759,14 +2677,14 @@ static const char *const ftfont_non_booleans [] = {
NULL,
};
static void
void
ftfont_filter_properties (Lisp_Object font, Lisp_Object alist)
{
font_filter_properties (font, alist, ftfont_booleans, ftfont_non_booleans);
}
static Lisp_Object
Lisp_Object
ftfont_combining_capability (struct font *font)
{
#ifdef HAVE_M17N_FLT
......@@ -2776,6 +2694,34 @@ ftfont_combining_capability (struct font *font)
#endif
}
static struct font_driver const ftfont_driver =
{
/* We can't draw a text without device dependent functions. */
type: LISPSYM_INITIALLY (Qfreetype),
get_cache: ftfont_get_cache,
list: ftfont_list,
match: ftfont_match,
list_family: ftfont_list_family,
open: ftfont_open,
close: ftfont_close,
has_char: ftfont_has_char,
encode_char: ftfont_encode_char,
text_extents: ftfont_text_extents,
get_bitmap: ftfont_get_bitmap,
anchor_point: ftfont_anchor_point,
#ifdef HAVE_LIBOTF
otf_capability: ftfont_otf_capability,
#endif
#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
shape: ftfont_shape,
#endif
#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
get_variation_glyphs: ftfont_variation_glyphs,
#endif
filter_properties: ftfont_filter_properties,
combining_capability: ftfont_combining_capability,
};
void
syms_of_ftfont (void)
{
......
......@@ -31,8 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* FTX font driver. */
struct font_driver ftxfont_driver;
struct ftxfont_frame_data
{
/* Background and foreground colors. */
......@@ -125,7 +123,7 @@ ftxfont_draw_bitmap (struct frame *f, GC gc_fore, GC *gcs, struct font *font,
unsigned char *b;
int i, j;
if (ftfont_driver.get_bitmap (font, code, &bitmap, size > 0x100 ? 1 : 8) < 0)
if (ftfont_get_bitmap (font, code, &bitmap, size > 0x100 ? 1 : 8) < 0)
return 0;
if (size > 0x100)
{
......@@ -188,8 +186,7 @@ ftxfont_draw_bitmap (struct frame *f, GC gc_fore, GC *gcs, struct font *font,
}
}
if (ftfont_driver.free_bitmap)
ftfont_driver.free_bitmap (font, &bitmap);
/* There is no ftfont_free_bitmap, so do not try to free BITMAP. */
return bitmap.advance;
}
......@@ -211,7 +208,7 @@ ftxfont_draw_background (struct frame *f, struct font *font, GC gc, int x, int y
static Lisp_Object
ftxfont_list (struct frame *f, Lisp_Object spec)
{
Lisp_Object list = ftfont_driver.list (f, spec), tail;
Lisp_Object list = ftfont_list (f, spec), tail;
for (tail = list; CONSP (tail); tail = XCDR (tail))
ASET (XCAR (tail), FONT_TYPE_INDEX, Qftx);
......@@ -221,7 +218,7 @@ ftxfont_list (struct frame *f, Lisp_Object spec)
static Lisp_Object
ftxfont_match (struct frame *f, Lisp_Object spec)
{
Lisp_Object entity = ftfont_driver.match (f, spec);
Lisp_Object entity = ftfont_match (f, spec);
if (VECTORP (entity))
ASET (entity, FONT_TYPE_INDEX, Qftx);
......@@ -231,13 +228,10 @@ ftxfont_match (struct frame *f, Lisp_Object spec)
static Lisp_Object
ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
{
Lisp_Object font_object;
struct font *font;
font_object = ftfont_driver.open (f, entity, pixel_size);
Lisp_Object font_object = ftfont_open (f, entity, pixel_size);
if (NILP (font_object))
return Qnil;
font = XFONT_OBJECT (font_object);
struct font *font = XFONT_OBJECT (font_object);
font->driver = &ftxfont_driver;
return font_object;
}
......@@ -245,7 +239,7 @@ ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
static void
ftxfont_close (struct font *font)
{
ftfont_driver.close (font);
ftfont_close (font);
}
static int
......@@ -345,18 +339,39 @@ ftxfont_end_for_frame (struct frame *f)
struct font_driver const ftxfont_driver =
{
/* We can't draw a text without device dependent functions. */
type: LISPSYM_INITIALLY (Qftx),
get_cache: ftfont_get_cache,
list: ftxfont_list,
match: ftxfont_match,
list_family: ftfont_list_family,
open: ftxfont_open,
close: ftxfont_close,
has_char: ftfont_has_char,
encode_char: ftfont_encode_char,
text_extents: ftfont_text_extents,
draw: ftxfont_draw,
get_bitmap: ftfont_get_bitmap,
anchor_point: ftfont_anchor_point,
#ifdef HAVE_LIBOTF
otf_capability: ftfont_otf_capability,
#endif
end_for_frame: ftxfont_end_for_frame,
#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
shape: ftfont_shape,
#endif
#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
get_variation_glyphs: ftfont_variation_glyphs,
#endif
filter_properties: ftfont_filter_properties,
combining_capability: ftfont_combining_capability,
};
void
syms_of_ftxfont (void)
{
DEFSYM (Qftx, "ftx");
ftxfont_driver = ftfont_driver;
ftxfont_driver.type = Qftx;
ftxfont_driver.list = ftxfont_list;
ftxfont_driver.match = ftxfont_match;
ftxfont_driver.open = ftxfont_open;
ftxfont_driver.close = ftxfont_close;
ftxfont_driver.draw = ftxfont_draw;
ftxfont_driver.end_for_frame = ftxfont_end_for_frame;
register_font_driver (&ftxfont_driver, NULL);
}
......@@ -38,8 +38,6 @@
#include <libkern/OSByteOrder.h>
static struct font_driver macfont_driver;
static double mac_font_get_advance_width_for_glyph (CTFontRef, CGGlyph);
static CGRect mac_font_get_bounding_rect_for_glyph (CTFontRef, CGGlyph);
static CFArrayRef mac_font_create_available_families (void);
......@@ -893,7 +891,7 @@ static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char,
entity = font_make_entity ();
ASET (entity, FONT_TYPE_INDEX, macfont_driver.type);
ASET (entity, FONT_TYPE_INDEX, Qmac_ct);
ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1);
macfont_store_descriptor_attributes (desc, entity);
......@@ -1663,34 +1661,23 @@ static int macfont_variation_glyphs (struct font *, int c,
unsigned variations[256]);
static void macfont_filter_properties (Lisp_Object, Lisp_Object);