comparison src/nsfont.m @ 98399:6b3b02fd9846

* nsfont.m (nsfont_trait_distance): Fix bug. (nsfont_list): Return a list rather than a vector (syncs with Handa changes of 2008-05-14). (nsfont_open): Improve logging.
author Adrian Robert <Adrian.B.Robert@gmail.com>
date Tue, 30 Sep 2008 01:03:00 +0000
parents 713cc05ca791
children db015b441c0c
comparison
equal deleted inserted replaced
98398:39408ed11da9 98399:6b3b02fd9846
176 176
177 if (NSFONT_TRACE) 177 if (NSFONT_TRACE)
178 { 178 {
179 fprintf (stderr, "created font_entity:\n "); 179 fprintf (stderr, "created font_entity:\n ");
180 debug_print (font_entity); 180 debug_print (font_entity);
181 } 181 }
182 182
183 [suffix release]; 183 [suffix release];
184 free (escapedFamily); 184 free (escapedFamily);
185 return font_entity; 185 return font_entity;
186 } 186 }
188 188
189 /* Computes Hamming distance btwn two "vectors" of 0's and 1's. */ 189 /* Computes Hamming distance btwn two "vectors" of 0's and 1's. */
190 static int 190 static int
191 nsfont_trait_distance (unsigned int traits1, unsigned int traits2) 191 nsfont_trait_distance (unsigned int traits1, unsigned int traits2)
192 { 192 {
193 int i, d =0; 193 int i, d = 0;
194 for (i =0; i<sizeof (unsigned int)*8; i++) 194 for (i = 0; i < sizeof (unsigned int) * 8; i++)
195 { 195 {
196 d += (traits1 & 0x1) ^ (traits2 & 0x1); 196 d += (traits1 & 0x1) ^ (traits2 & 0x1);
197 traits1 >> 1; 197 traits1 >>= 1;
198 traits2 >> 1; 198 traits2 >>= 1;
199 } 199 }
200 return d; 200 return d;
201 } 201 }
202 202
203 203
265 return (dpyinfo->name_list_element); 265 return (dpyinfo->name_list_element);
266 } 266 }
267 267
268 268
269 /* List fonts exactly matching with FONT_SPEC on FRAME. The value 269 /* List fonts exactly matching with FONT_SPEC on FRAME. The value
270 is a vector of font-entities. This is the sole API that 270 is a **list** of font-entities. This is the sole API that
271 allocates font-entities. */ 271 allocates font-entities. */
272 static Lisp_Object 272 static Lisp_Object
273 nsfont_list (Lisp_Object frame, Lisp_Object font_spec) 273 nsfont_list (Lisp_Object frame, Lisp_Object font_spec)
274 { 274 {
275 Lisp_Object list = Qnil; 275 Lisp_Object list = Qnil;
347 } 347 }
348 348
349 if (NSFONT_TRACE) 349 if (NSFONT_TRACE)
350 fprintf (stderr, " Returning %d entities.\n", XINT (Flength (list))); 350 fprintf (stderr, " Returning %d entities.\n", XINT (Flength (list)));
351 351
352 return (NILP (list) ? Qnil : Fvconcat (1, &list));/* Qnil was null_vector */ 352 return list;
353 } 353 }
354 354
355 355
356 /* Return a font entity most closely maching with FONT_SPEC on 356 /* Return a font entity most closely maching with FONT_SPEC on
357 FRAME. The closeness is determined by the font backend, thus 357 FRAME. The closeness is determined by the font backend, thus
538 synthItal = !NILP (tem) && !strncmp ("synthItal", SDATA (SYMBOL_NAME (tem)), 538 synthItal = !NILP (tem) && !strncmp ("synthItal", SDATA (SYMBOL_NAME (tem)),
539 9); 539 9);
540 family = nsfont_get_family (font_entity); 540 family = nsfont_get_family (font_entity);
541 if (NSFONT_TRACE) 541 if (NSFONT_TRACE)
542 { 542 {
543 fprintf (stderr, "family: '%s'\ttraits = %ld\tbold = %d\n", 543 fprintf (stderr, "family: '%s'\ttraits = %ld\tbold = %d\titalic = %d\n",
544 [family UTF8String], traits, traits & NSBoldFontMask); 544 [family UTF8String], traits, traits & NSBoldFontMask,
545 traits & NSItalicFontMask);
545 } 546 }
546 547
547 /* see http://cocoadev.com/forums/comments.php?DiscussionID =74 */ 548 /* see http://cocoadev.com/forums/comments.php?DiscussionID =74 */
548 fixLeopardBug = traits & NSBoldFontMask ? 10 : 5; 549 fixLeopardBug = traits & NSBoldFontMask ? 10 : 5;
549 nsfont = [fontMgr fontWithFamily: family 550 nsfont = [fontMgr fontWithFamily: family
573 { 574 {
574 fprintf (stderr, "*** Emacs.app: unable to load backup font\n"); 575 fprintf (stderr, "*** Emacs.app: unable to load backup font\n");
575 return Qnil; 576 return Qnil;
576 } 577 }
577 } 578 }
579
580 //NSLog(@"%@\n",nsfont);
578 581
579 #if 0 582 #if 0
580 { 583 {
581 NSNumber *cached = [fontCache objectForKey: nsfont]; 584 NSNumber *cached = [fontCache objectForKey: nsfont];
582 if (cached != nil && !synthItal) 585 if (cached != nil && !synthItal)