diff options
| author | Dmitry Antipov | 2013-12-12 18:26:06 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-12-12 18:26:06 +0400 |
| commit | cf86e18b159f754d6e5537b7b9cbefc32297f7d2 (patch) | |
| tree | b584773b90d5cb4c5993cc194037686110a89e36 | |
| parent | c4246a6008ef0c69db296df4aab95530f8e2b95e (diff) | |
| download | emacs-cf86e18b159f754d6e5537b7b9cbefc32297f7d2.tar.gz emacs-cf86e18b159f754d6e5537b7b9cbefc32297f7d2.zip | |
* font.h (struct font_entity) [HAVE_NS]: New field to record
font driver which was used to create this entity.
(struct font) [HAVE_WINDOW_SYSTEM]: New field to record
frame where the font was opened.
(font_close_object): Add prototype.
* font.c (font_make_entity) [HAVE_NS]: Zero out driver field.
(font_close_object): Not static any more. Lost frame arg.
Adjust comment and users.
* alloc.c (cleanup_vector): Call font_close_object to adjust
per-frame font counters correctly. If HAVE_NS, also call
driver-specific cleanup for font-entity objects.
* ftfont.c (ftfont_open):
* nsfont.m (nsfont_open):
* w32font.c (w32font_open_internal):
* xfont.c (xfont_open):
* xftfont.c (xftfont_open): Save frame pointer in font object.
* macfont.m (macfont_open): Likewise.
(macfont_descriptor_entity): Save driver pointer to be able
to call its free_entity routine when font-entity is swept.
* ftxfont.c (ftxfont_open): Add eassert because frame
pointer should be saved by ftfont_driver.open.
| -rw-r--r-- | src/ChangeLog | 24 | ||||
| -rw-r--r-- | src/alloc.c | 20 | ||||
| -rw-r--r-- | src/font.c | 20 | ||||
| -rw-r--r-- | src/font.h | 7 | ||||
| -rw-r--r-- | src/ftfont.c | 1 | ||||
| -rw-r--r-- | src/ftxfont.c | 1 | ||||
| -rw-r--r-- | src/macfont.m | 2 | ||||
| -rw-r--r-- | src/nsfont.m | 1 | ||||
| -rw-r--r-- | src/w32font.c | 1 | ||||
| -rw-r--r-- | src/xfont.c | 1 | ||||
| -rw-r--r-- | src/xftfont.c | 1 |
11 files changed, 67 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 33675599390..e0f9b9e8689 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,29 @@ | |||
| 1 | 2013-12-12 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2013-12-12 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | * font.h (struct font_entity) [HAVE_NS]: New field to record | ||
| 4 | font driver which was used to create this entity. | ||
| 5 | (struct font) [HAVE_WINDOW_SYSTEM]: New field to record | ||
| 6 | frame where the font was opened. | ||
| 7 | (font_close_object): Add prototype. | ||
| 8 | * font.c (font_make_entity) [HAVE_NS]: Zero out driver field. | ||
| 9 | (font_close_object): Not static any more. Lost frame arg. | ||
| 10 | Adjust comment and users. | ||
| 11 | * alloc.c (cleanup_vector): Call font_close_object to adjust | ||
| 12 | per-frame font counters correctly. If HAVE_NS, also call | ||
| 13 | driver-specific cleanup for font-entity objects. | ||
| 14 | * ftfont.c (ftfont_open): | ||
| 15 | * nsfont.m (nsfont_open): | ||
| 16 | * w32font.c (w32font_open_internal): | ||
| 17 | * xfont.c (xfont_open): | ||
| 18 | * xftfont.c (xftfont_open): Save frame pointer in font object. | ||
| 19 | * macfont.m (macfont_open): Likewise. | ||
| 20 | (macfont_descriptor_entity): Save driver pointer to be able | ||
| 21 | to call its free_entity routine when font-entity is swept. | ||
| 22 | * ftxfont.c (ftxfont_open): Add eassert because frame | ||
| 23 | pointer should be saved by ftfont_driver.open. | ||
| 24 | |||
| 25 | 2013-12-12 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 26 | |||
| 3 | * xterm.c (x_make_frame_visible): Restore hack which is needed when | 27 | * xterm.c (x_make_frame_visible): Restore hack which is needed when |
| 4 | input polling is used. This is still meaningful for Cygwin, see | 28 | input polling is used. This is still meaningful for Cygwin, see |
| 5 | http://lists.gnu.org/archive/html/emacs-devel/2013-12/msg00351.html. | 29 | http://lists.gnu.org/archive/html/emacs-devel/2013-12/msg00351.html. |
diff --git a/src/alloc.c b/src/alloc.c index aeda42637cd..022d1e5dcbb 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -2874,10 +2874,22 @@ vector_nbytes (struct Lisp_Vector *v) | |||
| 2874 | static void | 2874 | static void |
| 2875 | cleanup_vector (struct Lisp_Vector *vector) | 2875 | cleanup_vector (struct Lisp_Vector *vector) |
| 2876 | { | 2876 | { |
| 2877 | if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FONT) | 2877 | if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FONT)) |
| 2878 | && ((vector->header.size & PSEUDOVECTOR_SIZE_MASK) | 2878 | { |
| 2879 | == FONT_OBJECT_MAX)) | 2879 | ptrdiff_t size = vector->header.size & PSEUDOVECTOR_SIZE_MASK; |
| 2880 | ((struct font *) vector)->driver->close ((struct font *) vector); | 2880 | Lisp_Object obj = make_lisp_ptr (vector, Lisp_Vectorlike); |
| 2881 | |||
| 2882 | if (size == FONT_OBJECT_MAX) | ||
| 2883 | font_close_object (obj); | ||
| 2884 | #ifdef HAVE_NS | ||
| 2885 | else if (size == FONT_ENTITY_MAX) | ||
| 2886 | { | ||
| 2887 | struct font_entity *entity = (struct font_entity *) vector; | ||
| 2888 | if (entity->driver && entity->driver->free_entity) | ||
| 2889 | entity->driver->free_entity (obj); | ||
| 2890 | } | ||
| 2891 | #endif /* HAVE_NS */ | ||
| 2892 | } | ||
| 2881 | } | 2893 | } |
| 2882 | 2894 | ||
| 2883 | /* Reclaim space used by unmarked vectors. */ | 2895 | /* Reclaim space used by unmarked vectors. */ |
diff --git a/src/font.c b/src/font.c index fb56b3d3fb3..d0a10332028 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -173,6 +173,9 @@ font_make_entity (void) | |||
| 173 | allocate_pseudovector (VECSIZE (struct font_entity), | 173 | allocate_pseudovector (VECSIZE (struct font_entity), |
| 174 | FONT_ENTITY_MAX, PVEC_FONT)); | 174 | FONT_ENTITY_MAX, PVEC_FONT)); |
| 175 | XSETFONT (font_entity, entity); | 175 | XSETFONT (font_entity, entity); |
| 176 | #ifdef HAVE_NS | ||
| 177 | entity->driver = NULL; | ||
| 178 | #endif | ||
| 176 | return font_entity; | 179 | return font_entity; |
| 177 | } | 180 | } |
| 178 | 181 | ||
| @@ -2881,10 +2884,10 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 2881 | } | 2884 | } |
| 2882 | 2885 | ||
| 2883 | 2886 | ||
| 2884 | /* Close FONT_OBJECT that is opened on frame F. */ | 2887 | /* Close FONT_OBJECT. */ |
| 2885 | 2888 | ||
| 2886 | static void | 2889 | void |
| 2887 | font_close_object (struct frame *f, Lisp_Object font_object) | 2890 | font_close_object (Lisp_Object font_object) |
| 2888 | { | 2891 | { |
| 2889 | struct font *font = XFONT_OBJECT (font_object); | 2892 | struct font *font = XFONT_OBJECT (font_object); |
| 2890 | 2893 | ||
| @@ -2894,8 +2897,9 @@ font_close_object (struct frame *f, Lisp_Object font_object) | |||
| 2894 | FONT_ADD_LOG ("close", font_object, Qnil); | 2897 | FONT_ADD_LOG ("close", font_object, Qnil); |
| 2895 | font->driver->close (font); | 2898 | font->driver->close (font); |
| 2896 | #ifdef HAVE_WINDOW_SYSTEM | 2899 | #ifdef HAVE_WINDOW_SYSTEM |
| 2897 | eassert (FRAME_DISPLAY_INFO (f)->n_fonts); | 2900 | eassert (font->frame); |
| 2898 | FRAME_DISPLAY_INFO (f)->n_fonts--; | 2901 | eassert (FRAME_DISPLAY_INFO (font->frame)->n_fonts); |
| 2902 | FRAME_DISPLAY_INFO (font->frame)->n_fonts--; | ||
| 2899 | #endif | 2903 | #endif |
| 2900 | } | 2904 | } |
| 2901 | 2905 | ||
| @@ -4548,11 +4552,11 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0, | |||
| 4548 | } | 4552 | } |
| 4549 | 4553 | ||
| 4550 | DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, | 4554 | DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, |
| 4551 | doc: /* Close FONT-OBJECT. */) | 4555 | doc: /* Close FONT-OBJECT. Optional FRAME is unused. */) |
| 4552 | (Lisp_Object font_object, Lisp_Object frame) | 4556 | (Lisp_Object font_object, Lisp_Object frame) |
| 4553 | { | 4557 | { |
| 4554 | CHECK_FONT_OBJECT (font_object); | 4558 | CHECK_FONT_OBJECT (font_object); |
| 4555 | font_close_object (decode_live_frame (frame), font_object); | 4559 | font_close_object (font_object); |
| 4556 | return Qnil; | 4560 | return Qnil; |
| 4557 | } | 4561 | } |
| 4558 | 4562 | ||
| @@ -4887,7 +4891,7 @@ If the named font is not yet loaded, return nil. */) | |||
| 4887 | /* As font_object is still in FONT_OBJLIST of the entity, we can't | 4891 | /* As font_object is still in FONT_OBJLIST of the entity, we can't |
| 4888 | close it now. Perhaps, we should manage font-objects | 4892 | close it now. Perhaps, we should manage font-objects |
| 4889 | by `reference-count'. */ | 4893 | by `reference-count'. */ |
| 4890 | font_close_object (f, font_object); | 4894 | font_close_object (font_object); |
| 4891 | #endif | 4895 | #endif |
| 4892 | return info; | 4896 | return info; |
| 4893 | } | 4897 | } |
diff --git a/src/font.h b/src/font.h index 539ebeba52a..7781816860a 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -265,6 +265,9 @@ struct font_entity | |||
| 265 | { | 265 | { |
| 266 | struct vectorlike_header header; | 266 | struct vectorlike_header header; |
| 267 | Lisp_Object props[FONT_ENTITY_MAX]; | 267 | Lisp_Object props[FONT_ENTITY_MAX]; |
| 268 | #ifdef HAVE_NS | ||
| 269 | struct font_driver *driver; | ||
| 270 | #endif | ||
| 268 | }; | 271 | }; |
| 269 | 272 | ||
| 270 | /* A value which may appear in the member `encoding' of struct font | 273 | /* A value which may appear in the member `encoding' of struct font |
| @@ -316,6 +319,9 @@ struct font | |||
| 316 | 319 | ||
| 317 | #if defined (HAVE_WINDOW_SYSTEM) | 320 | #if defined (HAVE_WINDOW_SYSTEM) |
| 318 | 321 | ||
| 322 | /* The frame where the font was opened. */ | ||
| 323 | struct frame *frame; | ||
| 324 | |||
| 319 | /* Vertical pixel width of the underline. If is zero if that | 325 | /* Vertical pixel width of the underline. If is zero if that |
| 320 | information is not in the font. */ | 326 | information is not in the font. */ |
| 321 | int underline_thickness; | 327 | int underline_thickness; |
| @@ -735,6 +741,7 @@ extern Lisp_Object merge_font_spec (Lisp_Object, Lisp_Object); | |||
| 735 | 741 | ||
| 736 | extern Lisp_Object font_make_entity (void); | 742 | extern Lisp_Object font_make_entity (void); |
| 737 | extern Lisp_Object font_make_object (int, Lisp_Object, int); | 743 | extern Lisp_Object font_make_object (int, Lisp_Object, int); |
| 744 | extern void font_close_object (Lisp_Object); | ||
| 738 | 745 | ||
| 739 | extern Lisp_Object find_font_encoding (Lisp_Object); | 746 | extern Lisp_Object find_font_encoding (Lisp_Object); |
| 740 | extern int font_registry_charsets (Lisp_Object, struct charset **, | 747 | extern int font_registry_charsets (Lisp_Object, struct charset **, |
diff --git a/src/ftfont.c b/src/ftfont.c index 6a2303ab4a7..36780454257 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -1236,6 +1236,7 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 1236 | ASET (font_object, FONT_FILE_INDEX, filename); | 1236 | ASET (font_object, FONT_FILE_INDEX, filename); |
| 1237 | ASET (font_object, FONT_FORMAT_INDEX, ftfont_font_format (NULL, filename)); | 1237 | ASET (font_object, FONT_FORMAT_INDEX, ftfont_font_format (NULL, filename)); |
| 1238 | font = XFONT_OBJECT (font_object); | 1238 | font = XFONT_OBJECT (font_object); |
| 1239 | font->frame = f; | ||
| 1239 | ftfont_info = (struct ftfont_info *) font; | 1240 | ftfont_info = (struct ftfont_info *) font; |
| 1240 | ftfont_info->ft_size = ft_face->size; | 1241 | ftfont_info->ft_size = ft_face->size; |
| 1241 | ftfont_info->index = XINT (idx); | 1242 | ftfont_info->index = XINT (idx); |
diff --git a/src/ftxfont.c b/src/ftxfont.c index d1aa3e40403..b44905d88cd 100644 --- a/src/ftxfont.c +++ b/src/ftxfont.c | |||
| @@ -255,6 +255,7 @@ ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 255 | if (NILP (font_object)) | 255 | if (NILP (font_object)) |
| 256 | return Qnil; | 256 | return Qnil; |
| 257 | font = XFONT_OBJECT (font_object); | 257 | font = XFONT_OBJECT (font_object); |
| 258 | eassert (font->frame == f); | ||
| 258 | font->driver = &ftxfont_driver; | 259 | font->driver = &ftxfont_driver; |
| 259 | return font_object; | 260 | return font_object; |
| 260 | } | 261 | } |
diff --git a/src/macfont.m b/src/macfont.m index 10623eb12fe..66833cd1b80 100644 --- a/src/macfont.m +++ b/src/macfont.m | |||
| @@ -882,6 +882,7 @@ macfont_descriptor_entity (FontDescriptorRef desc, Lisp_Object extra, | |||
| 882 | CFStringRef name; | 882 | CFStringRef name; |
| 883 | 883 | ||
| 884 | entity = font_make_entity (); | 884 | entity = font_make_entity (); |
| 885 | XFONT_ENTITY (entity)->driver = &macfont_driver; | ||
| 885 | 886 | ||
| 886 | ASET (entity, FONT_TYPE_INDEX, macfont_driver.type); | 887 | ASET (entity, FONT_TYPE_INDEX, macfont_driver.type); |
| 887 | ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1); | 888 | ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1); |
| @@ -2491,6 +2492,7 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size) | |||
| 2491 | ASET (font_object, FONT_FULLNAME_INDEX, | 2492 | ASET (font_object, FONT_FULLNAME_INDEX, |
| 2492 | AREF (font_object, FONT_NAME_INDEX)); | 2493 | AREF (font_object, FONT_NAME_INDEX)); |
| 2493 | font = XFONT_OBJECT (font_object); | 2494 | font = XFONT_OBJECT (font_object); |
| 2495 | font->frame = f; | ||
| 2494 | font->pixel_size = size; | 2496 | font->pixel_size = size; |
| 2495 | font->driver = &macfont_driver; | 2497 | font->driver = &macfont_driver; |
| 2496 | font->encoding_charset = font->repertory_charset = -1; | 2498 | font->encoding_charset = font->repertory_charset = -1; |
diff --git a/src/nsfont.m b/src/nsfont.m index 0f546408316..a794c9eed41 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -805,6 +805,7 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size) | |||
| 805 | return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */ | 805 | return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */ |
| 806 | } | 806 | } |
| 807 | 807 | ||
| 808 | font->frame = f; | ||
| 808 | font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs); | 809 | font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs); |
| 809 | font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics); | 810 | font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics); |
| 810 | 811 | ||
diff --git a/src/w32font.c b/src/w32font.c index 654e0d9cae4..20469274969 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -999,6 +999,7 @@ w32font_open_internal (struct frame *f, Lisp_Object font_entity, | |||
| 999 | = DECODE_SYSTEM (build_string (logfont.lfFaceName)); | 999 | = DECODE_SYSTEM (build_string (logfont.lfFaceName)); |
| 1000 | } | 1000 | } |
| 1001 | 1001 | ||
| 1002 | font->frame = f; | ||
| 1002 | font->max_width = w32_font->metrics.tmMaxCharWidth; | 1003 | font->max_width = w32_font->metrics.tmMaxCharWidth; |
| 1003 | /* Parts of Emacs display assume that height = ascent + descent... | 1004 | /* Parts of Emacs display assume that height = ascent + descent... |
| 1004 | so height is defined later, after ascent and descent. | 1005 | so height is defined later, after ascent and descent. |
diff --git a/src/xfont.c b/src/xfont.c index d4d6ee7c10f..83ef604d5cd 100644 --- a/src/xfont.c +++ b/src/xfont.c | |||
| @@ -806,6 +806,7 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 806 | ASET (font_object, FONT_FILE_INDEX, Qnil); | 806 | ASET (font_object, FONT_FILE_INDEX, Qnil); |
| 807 | ASET (font_object, FONT_FORMAT_INDEX, Qx); | 807 | ASET (font_object, FONT_FORMAT_INDEX, Qx); |
| 808 | font = XFONT_OBJECT (font_object); | 808 | font = XFONT_OBJECT (font_object); |
| 809 | font->frame = f; | ||
| 809 | ((struct xfont_info *) font)->xfont = xfont; | 810 | ((struct xfont_info *) font)->xfont = xfont; |
| 810 | ((struct xfont_info *) font)->display = FRAME_X_DISPLAY (f); | 811 | ((struct xfont_info *) font)->display = FRAME_X_DISPLAY (f); |
| 811 | font->pixel_size = pixel_size; | 812 | font->pixel_size = pixel_size; |
diff --git a/src/xftfont.c b/src/xftfont.c index 37b33b3ead8..6423f8e19b3 100644 --- a/src/xftfont.c +++ b/src/xftfont.c | |||
| @@ -365,6 +365,7 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 365 | ASET (font_object, FONT_FORMAT_INDEX, | 365 | ASET (font_object, FONT_FORMAT_INDEX, |
| 366 | ftfont_font_format (xftfont->pattern, filename)); | 366 | ftfont_font_format (xftfont->pattern, filename)); |
| 367 | font = XFONT_OBJECT (font_object); | 367 | font = XFONT_OBJECT (font_object); |
| 368 | font->frame = f; | ||
| 368 | font->pixel_size = size; | 369 | font->pixel_size = size; |
| 369 | font->driver = &xftfont_driver; | 370 | font->driver = &xftfont_driver; |
| 370 | font->encoding_charset = font->repertory_charset = -1; | 371 | font->encoding_charset = font->repertory_charset = -1; |