emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/nsfont.m,v


From: Adrian Robert
Subject: [Emacs-diffs] Changes to emacs/src/nsfont.m,v
Date: Wed, 01 Oct 2008 17:12:52 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Adrian Robert <arobert> 08/10/01 17:12:52

Index: nsfont.m
===================================================================
RCS file: /sources/emacs/emacs/src/nsfont.m,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- nsfont.m    30 Sep 2008 01:03:03 -0000      1.14
+++ nsfont.m    1 Oct 2008 17:12:51 -0000       1.15
@@ -121,20 +121,18 @@
 
   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 @@
     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 @@
   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 @@
         }
     }
 
-//NSLog(@"address@hidden",nsfont);
+  if (NSFONT_TRACE)
+    NSLog (@"address@hidden", nsfont);
 
-#if 0
-  {
-    NSNumber *cached = [fontCache objectForKey: nsfont];
+  /* Check the cache */
+  cached = [fontCache objectForKey: nsfont];
     if (cached != nil && !synthItal)
       {
-fprintf (stderr, "*** CACHE HIT!\n");
-        struct font_info *existing =
-          (struct nsfont_info *)[cached unsignedLongValue];
-        /* ... */
+      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_info]
+                                 (unsigned long)font_object]
                forKey: nsfont];
       }
-  }
-#endif
+
+  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 @@
   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];




reply via email to

[Prev in Thread] Current Thread [Next in Thread]