diff options
| author | Paul Eggert | 2016-12-01 21:47:12 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-12-01 21:48:30 -0800 |
| commit | ebb96114d88af64cbb72f42052cb359ba8010aa2 (patch) | |
| tree | 88795f2e9bc74b5c1a96c04c8cfe069b7d5f601f /src/ftcrfont.c | |
| parent | dd4b913153a818dbd42cb395d2c36f216e09a8ec (diff) | |
| download | emacs-ebb96114d88af64cbb72f42052cb359ba8010aa2.tar.gz emacs-ebb96114d88af64cbb72f42052cb359ba8010aa2.zip | |
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.
Diffstat (limited to 'src/ftcrfont.c')
| -rw-r--r-- | src/ftcrfont.c | 49 |
1 files changed, 32 insertions, 17 deletions
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 | ||
| 68 | struct font_driver ftcrfont_driver; | ||
| 69 | |||
| 70 | static int | 68 | static int |
| 71 | ftcrfont_glyph_extents (struct font *font, | 69 | ftcrfont_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, | |||
| 112 | static Lisp_Object | 110 | static Lisp_Object |
| 113 | ftcrfont_list (struct frame *f, Lisp_Object spec) | 111 | ftcrfont_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) | |||
| 122 | static Lisp_Object | 120 | static Lisp_Object |
| 123 | ftcrfont_match (struct frame *f, Lisp_Object spec) | 121 | ftcrfont_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 | ||
| 132 | extern FT_Face ftfont_get_ft_face (Lisp_Object); | ||
| 133 | |||
| 134 | static Lisp_Object | 130 | static Lisp_Object |
| 135 | ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | 131 | ftcrfont_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 | ||
| 187 | static void | 183 | static void |
| @@ -282,6 +278,34 @@ ftcrfont_draw (struct glyph_string *s, | |||
| 282 | 278 | ||
| 283 | 279 | ||
| 284 | 280 | ||
| 281 | struct 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 | |||
| 285 | void | 309 | void |
| 286 | syms_of_ftcrfont (void) | 310 | syms_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 | } |