XSETFRAME (frame, f);
ftype = AREF (spec, FONT_TYPE_INDEX);
size = AREF (spec, FONT_SIZE_INDEX);
- if (FLOATP (size))
- ASET (spec, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec)));
+ if (FLOATP (size))
+ ASET (work, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec)));
FONT_SET_STYLE (work, FONT_WEIGHT_INDEX, attrs[LFACE_WEIGHT_INDEX]);
FONT_SET_STYLE (work, FONT_SLANT_INDEX, attrs[LFACE_SLANT_INDEX]);
FONT_SET_STYLE (work, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]);
if (! NILP (entity))
break;
}
- ASET (spec, FONT_TYPE_INDEX, ftype);
- ASET (spec, FONT_SIZE_INDEX, size);
font_add_log ("match", work, entity);
return entity;
}
n = FONT_WEIGHT_NUMERIC (font_spec);
if (n != -1)
- traits |= (n > STYLE_REF) ? NSBoldFontMask : NSUnboldFontMask;
+ traits |= (n > STYLE_REF) ? NSBoldFontMask
+ : (n < STYLE_REF) ? NSUnboldFontMask : 0;
n = FONT_SLANT_NUMERIC (font_spec);
if (n != -1)
- traits |= (n > STYLE_REF) ? NSItalicFontMask : NSUnitalicFontMask;
+ traits |= (n > STYLE_REF) ? NSItalicFontMask
+ : (n < STYLE_REF) ? NSUnitalicFontMask : 0;
n = FONT_WIDTH_NUMERIC (font_spec);
if (n > -1)
- {
- if (n < STYLE_REF - 10)
- traits |= NSCondensedFontMask;
- else if (n > STYLE_REF + 10)
- traits |= NSExpandedFontMask;
- }
+ traits |= (n > STYLE_REF + 10) ? NSExpandedFontMask
+ : (n < STYLE_REF - 10) ? NSExpandedFontMask : 0;
/*fprintf (stderr, " returning traits = %u\n", traits); */
return traits;
fprintf (stderr, "adstyle: '%s'\n", SDATA (tem));
#endif
tem = AREF (font_spec, FONT_REGISTRY_INDEX);
- if (!EQ (tem, Qiso10646_1) && !EQ (tem, Qunicode_bmp))
+ if (!NILP (tem) && !EQ (tem, Qiso10646_1) && !EQ (tem, Qunicode_bmp))
return nsfont_fallback_entity ();
family = nsfont_get_family (font_spec);
Lisp_Object font_object;
int i;
int fixLeopardBug;
-#if 0
static NSMutableDictionary *fontCache = nil;
+ NSNumber *cached;
/* 2008/03/08: The same font may end up being requested for different
entities, due to small differences in numeric values or other issues,
or for different copies of the same entity. Therefore we cache to
avoid creating multiple struct font objects (with metrics cache, etc.)
for the same NSFont object.
- 2008/06/01: This is still an issue, but after font backend refactoring
- caching will be more difficult, needs to be reworked before enabling. */
+ 2008/06/01: This is still an issue after font backend refactoring. */
if (fontCache == nil)
fontCache = [[NSMutableDictionary alloc] init];
-#endif
-
- font_object = font_make_object (VECSIZE (struct nsfont_info), font_entity,
- pixel_size);
- font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
- font = (struct font *)font_info;
- if (!font)
- return Qnil; /* FIXME: this copies w32, but causes a segfault */
if (NSFONT_TRACE)
{
}
}
-//NSLog(@"%@\n",nsfont);
+ if (NSFONT_TRACE)
+ NSLog (@"%@\n", nsfont);
-#if 0
- {
- NSNumber *cached = [fontCache objectForKey: nsfont];
- if (cached != nil && !synthItal)
- {
-fprintf (stderr, "*** CACHE HIT!\n");
- struct font_info *existing =
- (struct nsfont_info *)[cached unsignedLongValue];
- /* ... */
- }
- else
- {
- if (!synthItal)
- [fontCache
- setObject: [NSNumber numberWithUnsignedLong:
- (unsigned long)font_info]
- forKey: nsfont];
- }
- }
-#endif
+ /* Check the cache */
+ cached = [fontCache objectForKey: nsfont];
+ if (cached != nil && !synthItal)
+ {
+ if (NSFONT_TRACE)
+ fprintf(stderr, "*** nsfont_open CACHE HIT!\n");
+ return (Lisp_Object)[cached unsignedLongValue];
+ }
+ else
+ {
+ font_object = font_make_object (VECSIZE (struct nsfont_info),
+ font_entity, pixel_size);
+ if (!synthItal)
+ [fontCache
+ setObject: [NSNumber numberWithUnsignedLong:
+ (unsigned long)font_object]
+ forKey: nsfont];
+ }
+
+ font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
+ font = (struct font *)font_info;
+ if (!font)
+ return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */
font_info->glyphs = (unsigned short **)
xmalloc (0x100 * sizeof (unsigned short *));
bzero (font_info->glyphs, 0x100 * sizeof (unsigned short *));
bzero (font_info->metrics, 0x100 * sizeof (struct font_metrics *));
-
-BLOCK_INPUT;
+ BLOCK_INPUT;
/* for metrics */
sfont = [nsfont screenFont];