diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/font.c | 6 | ||||
| -rw-r--r-- | src/nsfont.m | 78 |
3 files changed, 43 insertions, 47 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8603222ea32..eb667c7a0ce 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2008-10-01 Adrian Robert <Adrian.B.Robert@gmail.com> | 1 | 2008-10-01 Adrian Robert <Adrian.B.Robert@gmail.com> |
| 2 | 2 | ||
| 3 | * nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal | ||
| 4 | styles. | ||
| 5 | (nsfont_open): Reenable the cache. | ||
| 6 | |||
| 7 | 2008-10-01 Adrian Robert <Adrian.B.Robert@gmail.com> | ||
| 8 | |||
| 3 | * font.c (font_matching_entity): Reflect ATTRS in font selection. | 9 | * font.c (font_matching_entity): Reflect ATTRS in font selection. |
| 4 | (font_find_for_lface) [HAVE_NS]: Don't ignore case. | 10 | (font_find_for_lface) [HAVE_NS]: Don't ignore case. |
| 5 | 11 | ||
diff --git a/src/font.c b/src/font.c index 816ce9a674f..fa179d624b5 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -2770,9 +2770,9 @@ font_matching_entity (f, attrs, spec) | |||
| 2770 | XSETFRAME (frame, f); | 2770 | XSETFRAME (frame, f); |
| 2771 | ftype = AREF (spec, FONT_TYPE_INDEX); | 2771 | ftype = AREF (spec, FONT_TYPE_INDEX); |
| 2772 | size = AREF (spec, FONT_SIZE_INDEX); | 2772 | size = AREF (spec, FONT_SIZE_INDEX); |
| 2773 | if (FLOATP (size)) | ||
| 2774 | ASET (spec, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec))); | ||
| 2775 | 2773 | ||
| 2774 | if (FLOATP (size)) | ||
| 2775 | ASET (work, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec))); | ||
| 2776 | FONT_SET_STYLE (work, FONT_WEIGHT_INDEX, attrs[LFACE_WEIGHT_INDEX]); | 2776 | FONT_SET_STYLE (work, FONT_WEIGHT_INDEX, attrs[LFACE_WEIGHT_INDEX]); |
| 2777 | FONT_SET_STYLE (work, FONT_SLANT_INDEX, attrs[LFACE_SLANT_INDEX]); | 2777 | FONT_SET_STYLE (work, FONT_SLANT_INDEX, attrs[LFACE_SLANT_INDEX]); |
| 2778 | FONT_SET_STYLE (work, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); | 2778 | FONT_SET_STYLE (work, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); |
| @@ -2799,8 +2799,6 @@ font_matching_entity (f, attrs, spec) | |||
| 2799 | if (! NILP (entity)) | 2799 | if (! NILP (entity)) |
| 2800 | break; | 2800 | break; |
| 2801 | } | 2801 | } |
| 2802 | ASET (spec, FONT_TYPE_INDEX, ftype); | ||
| 2803 | ASET (spec, FONT_SIZE_INDEX, size); | ||
| 2804 | font_add_log ("match", work, entity); | 2802 | font_add_log ("match", work, entity); |
| 2805 | return entity; | 2803 | return entity; |
| 2806 | } | 2804 | } |
diff --git a/src/nsfont.m b/src/nsfont.m index 813b04be662..7adced73c12 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -121,20 +121,18 @@ nsfont_spec_to_traits (Lisp_Object font_spec) | |||
| 121 | 121 | ||
| 122 | n = FONT_WEIGHT_NUMERIC (font_spec); | 122 | n = FONT_WEIGHT_NUMERIC (font_spec); |
| 123 | if (n != -1) | 123 | if (n != -1) |
| 124 | traits |= (n > STYLE_REF) ? NSBoldFontMask : NSUnboldFontMask; | 124 | traits |= (n > STYLE_REF) ? NSBoldFontMask |
| 125 | : (n < STYLE_REF) ? NSUnboldFontMask : 0; | ||
| 125 | 126 | ||
| 126 | n = FONT_SLANT_NUMERIC (font_spec); | 127 | n = FONT_SLANT_NUMERIC (font_spec); |
| 127 | if (n != -1) | 128 | if (n != -1) |
| 128 | traits |= (n > STYLE_REF) ? NSItalicFontMask : NSUnitalicFontMask; | 129 | traits |= (n > STYLE_REF) ? NSItalicFontMask |
| 130 | : (n < STYLE_REF) ? NSUnitalicFontMask : 0; | ||
| 129 | 131 | ||
| 130 | n = FONT_WIDTH_NUMERIC (font_spec); | 132 | n = FONT_WIDTH_NUMERIC (font_spec); |
| 131 | if (n > -1) | 133 | if (n > -1) |
| 132 | { | 134 | traits |= (n > STYLE_REF + 10) ? NSExpandedFontMask |
| 133 | if (n < STYLE_REF - 10) | 135 | : (n < STYLE_REF - 10) ? NSExpandedFontMask : 0; |
| 134 | traits |= NSCondensedFontMask; | ||
| 135 | else if (n > STYLE_REF + 10) | ||
| 136 | traits |= NSExpandedFontMask; | ||
| 137 | } | ||
| 138 | 136 | ||
| 139 | /*fprintf (stderr, " returning traits = %u\n", traits); */ | 137 | /*fprintf (stderr, " returning traits = %u\n", traits); */ |
| 140 | return traits; | 138 | return traits; |
| @@ -377,7 +375,7 @@ nsfont_match (Lisp_Object frame, Lisp_Object font_spec) | |||
| 377 | fprintf (stderr, "adstyle: '%s'\n", SDATA (tem)); | 375 | fprintf (stderr, "adstyle: '%s'\n", SDATA (tem)); |
| 378 | #endif | 376 | #endif |
| 379 | tem = AREF (font_spec, FONT_REGISTRY_INDEX); | 377 | tem = AREF (font_spec, FONT_REGISTRY_INDEX); |
| 380 | if (!EQ (tem, Qiso10646_1) && !EQ (tem, Qunicode_bmp)) | 378 | if (!NILP (tem) && !EQ (tem, Qiso10646_1) && !EQ (tem, Qunicode_bmp)) |
| 381 | return nsfont_fallback_entity (); | 379 | return nsfont_fallback_entity (); |
| 382 | 380 | ||
| 383 | family = nsfont_get_family (font_spec); | 381 | family = nsfont_get_family (font_spec); |
| @@ -500,26 +498,17 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) | |||
| 500 | Lisp_Object font_object; | 498 | Lisp_Object font_object; |
| 501 | int i; | 499 | int i; |
| 502 | int fixLeopardBug; | 500 | int fixLeopardBug; |
| 503 | #if 0 | ||
| 504 | static NSMutableDictionary *fontCache = nil; | 501 | static NSMutableDictionary *fontCache = nil; |
| 502 | NSNumber *cached; | ||
| 505 | 503 | ||
| 506 | /* 2008/03/08: The same font may end up being requested for different | 504 | /* 2008/03/08: The same font may end up being requested for different |
| 507 | entities, due to small differences in numeric values or other issues, | 505 | entities, due to small differences in numeric values or other issues, |
| 508 | or for different copies of the same entity. Therefore we cache to | 506 | or for different copies of the same entity. Therefore we cache to |
| 509 | avoid creating multiple struct font objects (with metrics cache, etc.) | 507 | avoid creating multiple struct font objects (with metrics cache, etc.) |
| 510 | for the same NSFont object. | 508 | for the same NSFont object. |
| 511 | 2008/06/01: This is still an issue, but after font backend refactoring | 509 | 2008/06/01: This is still an issue after font backend refactoring. */ |
| 512 | caching will be more difficult, needs to be reworked before enabling. */ | ||
| 513 | if (fontCache == nil) | 510 | if (fontCache == nil) |
| 514 | fontCache = [[NSMutableDictionary alloc] init]; | 511 | fontCache = [[NSMutableDictionary alloc] init]; |
| 515 | #endif | ||
| 516 | |||
| 517 | font_object = font_make_object (VECSIZE (struct nsfont_info), font_entity, | ||
| 518 | pixel_size); | ||
| 519 | font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); | ||
| 520 | font = (struct font *)font_info; | ||
| 521 | if (!font) | ||
| 522 | return Qnil; /* FIXME: this copies w32, but causes a segfault */ | ||
| 523 | 512 | ||
| 524 | if (NSFONT_TRACE) | 513 | if (NSFONT_TRACE) |
| 525 | { | 514 | { |
| @@ -577,28 +566,32 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) | |||
| 577 | } | 566 | } |
| 578 | } | 567 | } |
| 579 | 568 | ||
| 580 | //NSLog(@"%@\n",nsfont); | 569 | if (NSFONT_TRACE) |
| 570 | NSLog (@"%@\n", nsfont); | ||
| 581 | 571 | ||
| 582 | #if 0 | 572 | /* Check the cache */ |
| 583 | { | 573 | cached = [fontCache objectForKey: nsfont]; |
| 584 | NSNumber *cached = [fontCache objectForKey: nsfont]; | 574 | if (cached != nil && !synthItal) |
| 585 | if (cached != nil && !synthItal) | 575 | { |
| 586 | { | 576 | if (NSFONT_TRACE) |
| 587 | fprintf (stderr, "*** CACHE HIT!\n"); | 577 | fprintf(stderr, "*** nsfont_open CACHE HIT!\n"); |
| 588 | struct font_info *existing = | 578 | return (Lisp_Object)[cached unsignedLongValue]; |
| 589 | (struct nsfont_info *)[cached unsignedLongValue]; | 579 | } |
| 590 | /* ... */ | 580 | else |
| 591 | } | 581 | { |
| 592 | else | 582 | font_object = font_make_object (VECSIZE (struct nsfont_info), |
| 593 | { | 583 | font_entity, pixel_size); |
| 594 | if (!synthItal) | 584 | if (!synthItal) |
| 595 | [fontCache | 585 | [fontCache |
| 596 | setObject: [NSNumber numberWithUnsignedLong: | 586 | setObject: [NSNumber numberWithUnsignedLong: |
| 597 | (unsigned long)font_info] | 587 | (unsigned long)font_object] |
| 598 | forKey: nsfont]; | 588 | forKey: nsfont]; |
| 599 | } | 589 | } |
| 600 | } | 590 | |
| 601 | #endif | 591 | font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); |
| 592 | font = (struct font *)font_info; | ||
| 593 | if (!font) | ||
| 594 | return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */ | ||
| 602 | 595 | ||
| 603 | font_info->glyphs = (unsigned short **) | 596 | font_info->glyphs = (unsigned short **) |
| 604 | xmalloc (0x100 * sizeof (unsigned short *)); | 597 | xmalloc (0x100 * sizeof (unsigned short *)); |
| @@ -609,8 +602,7 @@ fprintf (stderr, "*** CACHE HIT!\n"); | |||
| 609 | bzero (font_info->glyphs, 0x100 * sizeof (unsigned short *)); | 602 | bzero (font_info->glyphs, 0x100 * sizeof (unsigned short *)); |
| 610 | bzero (font_info->metrics, 0x100 * sizeof (struct font_metrics *)); | 603 | bzero (font_info->metrics, 0x100 * sizeof (struct font_metrics *)); |
| 611 | 604 | ||
| 612 | 605 | BLOCK_INPUT; | |
| 613 | BLOCK_INPUT; | ||
| 614 | 606 | ||
| 615 | /* for metrics */ | 607 | /* for metrics */ |
| 616 | sfont = [nsfont screenFont]; | 608 | sfont = [nsfont screenFont]; |