Commit 8d0e382e authored by Adrian Robert's avatar Adrian Robert

* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles....

* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal styles. (nsfont_open): Reenable the cache.
parent 4009e4f8
2008-10-01 Adrian Robert <Adrian.B.Robert@gmail.com>
* nsfont.m (nsfont_spec_to_traits): Use UnXX masks only for non-normal
styles.
(nsfont_open): Reenable the cache.
2008-10-01 Adrian Robert <Adrian.B.Robert@gmail.com>
* font.c (font_matching_entity): Reflect ATTRS in font selection.
......
......@@ -2770,9 +2770,9 @@ font_matching_entity (f, attrs, spec)
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]);
......@@ -2799,8 +2799,6 @@ font_matching_entity (f, attrs, spec)
if (! NILP (entity))
break;
}
ASET (spec, FONT_TYPE_INDEX, ftype);
ASET (spec, FONT_SIZE_INDEX, size);
font_add_log ("match", work, entity);
return entity;
}
......
......@@ -121,20 +121,18 @@ static void ns_glyph_metrics (struct nsfont_info *font_info,
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;
......@@ -377,7 +375,7 @@ static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
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);
......@@ -500,26 +498,17 @@ static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
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)
{
......@@ -577,28 +566,32 @@ avoid creating multiple struct font objects (with metrics cache, etc.)
}
}
//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 *));
......@@ -609,8 +602,7 @@ avoid creating multiple struct font objects (with metrics cache, etc.)
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];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment