diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 61 | ||||
| -rw-r--r-- | src/font.c | 91 |
2 files changed, 121 insertions, 31 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f753ef11714..333dd802676 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,64 @@ | |||
| 1 | 2008-02-17 Kenichi Handa <handa@m17n.org> | ||
| 2 | |||
| 3 | * ftfont.c (ftfont_shape): Return Lispy number. | ||
| 4 | |||
| 5 | * xfaces.c (prepare_face_for_display): Use display_info->font->fid | ||
| 6 | for GCs. | ||
| 7 | (Finternal_set_font_selection_order): Call font_update_sort_order | ||
| 8 | only when enable_font_backend is set. | ||
| 9 | (realize_x_face): Set face->font_info to that of default face only | ||
| 10 | when enable_font_backend is set. | ||
| 11 | |||
| 12 | * xdisp.c (handle_composition_prop): Set it->c to the fist | ||
| 13 | characte of the composed region. | ||
| 14 | (fill_composite_glyph_string): Set base_face->font_info to | ||
| 15 | s->font_info. Get a face for ascii from base_face->ascii_face. | ||
| 16 | (BUILD_COMPOSITE_GLYPH_STRING): Call fill_composite_glyph_string | ||
| 17 | with a face already decided. | ||
| 18 | (x_produce_glyphs): Be sure to set it->ascent and it->descent to | ||
| 19 | non-negative. | ||
| 20 | (x_produce_glyphs): If the composition method is | ||
| 21 | ..._WITH_GLYPH_STRING, call font_prepare_composition | ||
| 22 | unconditionally. | ||
| 23 | |||
| 24 | * xfns.c (x_make_gc): Use the default font id of the frame for | ||
| 25 | GCs. | ||
| 26 | |||
| 27 | * xterm.h (struct x_display_info): New member font. | ||
| 28 | |||
| 29 | * xterm.c (x_set_cursor_gc): Use display_info->font->fid for GCs. | ||
| 30 | (x_set_mouse_face_gc, x_new_font): Likewise. | ||
| 31 | (x_term_init): Setup display_info->font. | ||
| 32 | (x_delete_terminal): Free display_info->font. | ||
| 33 | |||
| 34 | * xfont.c (xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT. | ||
| 35 | |||
| 36 | * ftxfont.c (ftxfont_default_fid): Delete it. | ||
| 37 | (ftxfont_open): Set xfont->fid to 0. | ||
| 38 | (ftxfont_end_for_frame): Clear data specifi to the frame and the | ||
| 39 | font-driver. | ||
| 40 | |||
| 41 | * xftfont.c (xftfont_default_fid): Delete it. | ||
| 42 | (xftfont_open): Set xfont->fid to 0. | ||
| 43 | |||
| 44 | * fontset.c (FONTSET_OBJLIST): New macro. | ||
| 45 | (fontset_find_font): Update font-object list of the fontset. | ||
| 46 | (free_realized_fontset): New function. | ||
| 47 | (free_face_fontset): Call free_realized_fontset. | ||
| 48 | (Ffont_info): Call font_close_object only when enable_font_backend | ||
| 49 | is set. | ||
| 50 | |||
| 51 | * font.c [HAVE_X_WINDOWS]: Include xterm.h. | ||
| 52 | [HAVE_NTGUI]: Include w32term.h. | ||
| 53 | [MAC_OS]: Include macterm.ch. | ||
| 54 | (font_otf_ValueRecord): Use make_number. | ||
| 55 | (font_finish_cache): Fix handling of reference count. | ||
| 56 | (font_clear_cache): Update num_fonts. | ||
| 57 | (font_open_entity): Update smallest_char_width and | ||
| 58 | smallest_font_height of the frame. | ||
| 59 | (font_close_object): Update num_fonts. | ||
| 60 | (Fclear_font_cache): Fix finding the target cache data. | ||
| 61 | |||
| 1 | 2008-02-16 Glenn Morris <rgm@gnu.org> | 62 | 2008-02-16 Glenn Morris <rgm@gnu.org> |
| 2 | 63 | ||
| 3 | * fontset.c (Finternal_char_font): Fix compilation warning. | 64 | * fontset.c (Finternal_char_font): Fix compilation warning. |
diff --git a/src/font.c b/src/font.c index 3dedaf56f58..70b239694c0 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -40,6 +40,18 @@ Boston, MA 02110-1301, USA. */ | |||
| 40 | #include "fontset.h" | 40 | #include "fontset.h" |
| 41 | #include "font.h" | 41 | #include "font.h" |
| 42 | 42 | ||
| 43 | #ifdef HAVE_X_WINDOWS | ||
| 44 | #include "xterm.h" | ||
| 45 | #endif /* HAVE_X_WINDOWS */ | ||
| 46 | |||
| 47 | #ifdef HAVE_NTGUI | ||
| 48 | #include "w32term.h" | ||
| 49 | #endif /* HAVE_NTGUI */ | ||
| 50 | |||
| 51 | #ifdef MAC_OS | ||
| 52 | #include "macterm.h" | ||
| 53 | #endif /* MAC_OS */ | ||
| 54 | |||
| 43 | #ifndef FONT_DEBUG | 55 | #ifndef FONT_DEBUG |
| 44 | #define FONT_DEBUG | 56 | #define FONT_DEBUG |
| 45 | #endif | 57 | #endif |
| @@ -1815,13 +1827,13 @@ font_otf_ValueRecord (value_format, value_record) | |||
| 1815 | Lisp_Object val = Fmake_vector (make_number (8), Qnil); | 1827 | Lisp_Object val = Fmake_vector (make_number (8), Qnil); |
| 1816 | 1828 | ||
| 1817 | if (value_format & OTF_XPlacement) | 1829 | if (value_format & OTF_XPlacement) |
| 1818 | ASET (val, 0, value_record->XPlacement); | 1830 | ASET (val, 0, make_number (value_record->XPlacement)); |
| 1819 | if (value_format & OTF_YPlacement) | 1831 | if (value_format & OTF_YPlacement) |
| 1820 | ASET (val, 1, value_record->YPlacement); | 1832 | ASET (val, 1, make_number (value_record->YPlacement)); |
| 1821 | if (value_format & OTF_XAdvance) | 1833 | if (value_format & OTF_XAdvance) |
| 1822 | ASET (val, 2, value_record->XAdvance); | 1834 | ASET (val, 2, make_number (value_record->XAdvance)); |
| 1823 | if (value_format & OTF_YAdvance) | 1835 | if (value_format & OTF_YAdvance) |
| 1824 | ASET (val, 3, value_record->YAdvance); | 1836 | ASET (val, 3, make_number (value_record->YAdvance)); |
| 1825 | if (value_format & OTF_XPlaDevice) | 1837 | if (value_format & OTF_XPlaDevice) |
| 1826 | ASET (val, 4, font_otf_DeviceTable (&value_record->XPlaDevice)); | 1838 | ASET (val, 4, font_otf_DeviceTable (&value_record->XPlaDevice)); |
| 1827 | if (value_format & OTF_YPlaDevice) | 1839 | if (value_format & OTF_YPlaDevice) |
| @@ -2197,6 +2209,7 @@ font_prepare_cache (f, driver) | |||
| 2197 | } | 2209 | } |
| 2198 | } | 2210 | } |
| 2199 | 2211 | ||
| 2212 | |||
| 2200 | static void | 2213 | static void |
| 2201 | font_finish_cache (f, driver) | 2214 | font_finish_cache (f, driver) |
| 2202 | FRAME_PTR f; | 2215 | FRAME_PTR f; |
| @@ -2211,17 +2224,15 @@ font_finish_cache (f, driver) | |||
| 2211 | cache = val, val = XCDR (val); | 2224 | cache = val, val = XCDR (val); |
| 2212 | xassert (! NILP (val)); | 2225 | xassert (! NILP (val)); |
| 2213 | tmp = XCDR (XCAR (val)); | 2226 | tmp = XCDR (XCAR (val)); |
| 2227 | XSETCAR (tmp, make_number (XINT (XCAR (tmp)) - 1)); | ||
| 2214 | if (XINT (XCAR (tmp)) == 0) | 2228 | if (XINT (XCAR (tmp)) == 0) |
| 2215 | { | 2229 | { |
| 2216 | font_clear_cache (f, XCAR (val), driver); | 2230 | font_clear_cache (f, XCAR (val), driver); |
| 2217 | XSETCDR (cache, XCDR (val)); | 2231 | XSETCDR (cache, XCDR (val)); |
| 2218 | } | 2232 | } |
| 2219 | else | ||
| 2220 | { | ||
| 2221 | XSETCAR (tmp, make_number (XINT (XCAR (tmp)) - 1)); | ||
| 2222 | } | ||
| 2223 | } | 2233 | } |
| 2224 | 2234 | ||
| 2235 | |||
| 2225 | static Lisp_Object | 2236 | static Lisp_Object |
| 2226 | font_get_cache (f, driver) | 2237 | font_get_cache (f, driver) |
| 2227 | FRAME_PTR f; | 2238 | FRAME_PTR f; |
| @@ -2238,6 +2249,8 @@ font_get_cache (f, driver) | |||
| 2238 | return val; | 2249 | return val; |
| 2239 | } | 2250 | } |
| 2240 | 2251 | ||
| 2252 | static int num_fonts; | ||
| 2253 | |||
| 2241 | static void | 2254 | static void |
| 2242 | font_clear_cache (f, cache, driver) | 2255 | font_clear_cache (f, cache, driver) |
| 2243 | FRAME_PTR f; | 2256 | FRAME_PTR f; |
| @@ -2273,6 +2286,7 @@ font_clear_cache (f, cache, driver) | |||
| 2273 | driver->close (f, font); | 2286 | driver->close (f, font); |
| 2274 | p->pointer = NULL; | 2287 | p->pointer = NULL; |
| 2275 | p->integer = 0; | 2288 | p->integer = 0; |
| 2289 | num_fonts--; | ||
| 2276 | } | 2290 | } |
| 2277 | if (driver->free_entity) | 2291 | if (driver->free_entity) |
| 2278 | driver->free_entity (entity); | 2292 | driver->free_entity (entity); |
| @@ -2406,8 +2420,6 @@ font_matching_entity (frame, spec) | |||
| 2406 | return entity; | 2420 | return entity; |
| 2407 | } | 2421 | } |
| 2408 | 2422 | ||
| 2409 | static int num_fonts; | ||
| 2410 | |||
| 2411 | 2423 | ||
| 2412 | /* Open a font of ENTITY and PIXEL_SIZE on frame F, and return the | 2424 | /* Open a font of ENTITY and PIXEL_SIZE on frame F, and return the |
| 2413 | opened font object. */ | 2425 | opened font object. */ |
| @@ -2419,7 +2431,7 @@ font_open_entity (f, entity, pixel_size) | |||
| 2419 | int pixel_size; | 2431 | int pixel_size; |
| 2420 | { | 2432 | { |
| 2421 | struct font_driver_list *driver_list; | 2433 | struct font_driver_list *driver_list; |
| 2422 | Lisp_Object objlist, size, val; | 2434 | Lisp_Object objlist, size, val, font_object; |
| 2423 | struct font *font; | 2435 | struct font *font; |
| 2424 | 2436 | ||
| 2425 | size = AREF (entity, FONT_SIZE_INDEX); | 2437 | size = AREF (entity, FONT_SIZE_INDEX); |
| @@ -2427,35 +2439,49 @@ font_open_entity (f, entity, pixel_size) | |||
| 2427 | if (XINT (size) != 0) | 2439 | if (XINT (size) != 0) |
| 2428 | pixel_size = XINT (size); | 2440 | pixel_size = XINT (size); |
| 2429 | 2441 | ||
| 2442 | font_object = Qnil; | ||
| 2430 | for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); | 2443 | for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); |
| 2431 | objlist = XCDR (objlist)) | 2444 | objlist = XCDR (objlist)) |
| 2432 | { | 2445 | { |
| 2433 | font = XSAVE_VALUE (XCAR (objlist))->pointer; | 2446 | font = XSAVE_VALUE (XCAR (objlist))->pointer; |
| 2434 | if (font->pixel_size == pixel_size) | 2447 | if (font->pixel_size == pixel_size) |
| 2435 | { | 2448 | { |
| 2436 | XSAVE_VALUE (XCAR (objlist))->integer++; | 2449 | font_object = XCAR (objlist); |
| 2437 | return XCAR (objlist); | 2450 | XSAVE_VALUE (font_object)->integer++; |
| 2451 | break; | ||
| 2438 | } | 2452 | } |
| 2439 | } | 2453 | } |
| 2440 | 2454 | ||
| 2441 | xassert (FONT_ENTITY_P (entity)); | 2455 | if (NILP (font_object)) |
| 2442 | val = AREF (entity, FONT_TYPE_INDEX); | 2456 | { |
| 2443 | for (driver_list = f->font_driver_list; | 2457 | val = AREF (entity, FONT_TYPE_INDEX); |
| 2444 | driver_list && ! EQ (driver_list->driver->type, val); | 2458 | for (driver_list = f->font_driver_list; |
| 2445 | driver_list = driver_list->next); | 2459 | driver_list && ! EQ (driver_list->driver->type, val); |
| 2446 | if (! driver_list) | 2460 | driver_list = driver_list->next); |
| 2447 | return Qnil; | 2461 | if (! driver_list) |
| 2462 | return Qnil; | ||
| 2448 | 2463 | ||
| 2449 | font = driver_list->driver->open (f, entity, pixel_size); | 2464 | font = driver_list->driver->open (f, entity, pixel_size); |
| 2450 | if (! font) | 2465 | if (! font) |
| 2451 | return Qnil; | 2466 | return Qnil; |
| 2452 | font->scalable = XINT (size) == 0; | 2467 | font->scalable = XINT (size) == 0; |
| 2453 | 2468 | ||
| 2454 | val = make_save_value (font, 1); | 2469 | font_object = make_save_value (font, 1); |
| 2455 | ASET (entity, FONT_OBJLIST_INDEX, | 2470 | ASET (entity, FONT_OBJLIST_INDEX, |
| 2456 | Fcons (val, AREF (entity, FONT_OBJLIST_INDEX))); | 2471 | Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX))); |
| 2457 | num_fonts++; | 2472 | num_fonts++; |
| 2458 | return val; | 2473 | } |
| 2474 | |||
| 2475 | if (FRAME_SMALLEST_CHAR_WIDTH (f) > font->min_width) | ||
| 2476 | FRAME_SMALLEST_CHAR_WIDTH (f) = font->min_width; | ||
| 2477 | if (FRAME_SMALLEST_CHAR_WIDTH (f) <= 0) | ||
| 2478 | FRAME_SMALLEST_CHAR_WIDTH (f) = 1; | ||
| 2479 | if (FRAME_SMALLEST_FONT_HEIGHT (f) > font->font.height) | ||
| 2480 | FRAME_SMALLEST_FONT_HEIGHT (f) = font->font.height; | ||
| 2481 | if (FRAME_SMALLEST_FONT_HEIGHT (f) <= 0) | ||
| 2482 | FRAME_SMALLEST_FONT_HEIGHT (f) = 1; | ||
| 2483 | |||
| 2484 | return font_object; | ||
| 2459 | } | 2485 | } |
| 2460 | 2486 | ||
| 2461 | 2487 | ||
| @@ -2470,8 +2496,8 @@ font_close_object (f, font_object) | |||
| 2470 | Lisp_Object objlist; | 2496 | Lisp_Object objlist; |
| 2471 | Lisp_Object tail, prev = Qnil; | 2497 | Lisp_Object tail, prev = Qnil; |
| 2472 | 2498 | ||
| 2499 | xassert (XSAVE_VALUE (font_object)->integer > 0); | ||
| 2473 | XSAVE_VALUE (font_object)->integer--; | 2500 | XSAVE_VALUE (font_object)->integer--; |
| 2474 | xassert (XSAVE_VALUE (font_object)->integer >= 0); | ||
| 2475 | if (XSAVE_VALUE (font_object)->integer > 0) | 2501 | if (XSAVE_VALUE (font_object)->integer > 0) |
| 2476 | return; | 2502 | return; |
| 2477 | 2503 | ||
| @@ -2487,6 +2513,7 @@ font_close_object (f, font_object) | |||
| 2487 | ASET (font->entity, FONT_OBJLIST_INDEX, XCDR (objlist)); | 2513 | ASET (font->entity, FONT_OBJLIST_INDEX, XCDR (objlist)); |
| 2488 | else | 2514 | else |
| 2489 | XSETCDR (prev, XCDR (objlist)); | 2515 | XSETCDR (prev, XCDR (objlist)); |
| 2516 | num_fonts--; | ||
| 2490 | return; | 2517 | return; |
| 2491 | } | 2518 | } |
| 2492 | abort (); | 2519 | abort (); |
| @@ -3364,8 +3391,10 @@ DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, | |||
| 3364 | Lisp_Object val; | 3391 | Lisp_Object val; |
| 3365 | 3392 | ||
| 3366 | val = XCDR (cache); | 3393 | val = XCDR (cache); |
| 3367 | while (! EQ (XCAR (val), driver_list->driver->type)) | 3394 | while (! NILP (val) |
| 3395 | && ! EQ (XCAR (XCAR (val)), driver_list->driver->type)) | ||
| 3368 | val = XCDR (val); | 3396 | val = XCDR (val); |
| 3397 | xassert (! NILP (val)); | ||
| 3369 | val = XCDR (XCAR (val)); | 3398 | val = XCDR (XCAR (val)); |
| 3370 | if (XINT (XCAR (val)) == 0) | 3399 | if (XINT (XCAR (val)) == 0) |
| 3371 | { | 3400 | { |