GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: a tiny graphical app kit for ruby
Homepage: http://code.whytheluckystiff.net/shoes
Clone URL: git://github.com/why/shoes.git
 * shoes/native/cocoa.m: working on the font list for os x.
why (author)
Mon Oct 06 09:09:21 -0700 2008
commit  7184a4ae56a1253fbe08cc58011d4694e07a4cc2
tree    78e5f62125914dcbf21f939949950d3b58a60ecc
parent  64b8d0f6ac27568721d0969190e0180d3e19fd78
...
488
489
490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
492
493
...
517
518
519
520
521
522
523
524
525
526
527
528
 
529
530
531
...
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
...
542
543
544
 
545
 
546
547
548
549
550
551
552
553
554
555
0
@@ -488,6 +488,31 @@ create_help_menu(NSMenu *main)
0
 }
0
 
0
 VALUE
0
+shoes_font_list()
0
+{
0
+ ATSFontIterator fi = NULL;
0
+ ATSFontRef fontRef = 0;
0
+ NSMutableArray *outArray;
0
+ VALUE ary = rb_ary_new();
0
+ while (noErr == ATSFontIteratorCreate(kATSFontContextLocal, nil, nil,
0
+ kATSOptionFlagsUnRestrictedScope, &fi))
0
+ {
0
+ if (noErr == ATSFontIteratorNext(fi, &fontRef))
0
+ {
0
+ NSString *fontName;
0
+ ATSFontGetName(fontRef, kATSOptionFlagsDefault, &fontName);
0
+ if (fontName != NULL)
0
+ rb_ary_push(families, rb_str_new2([fontName UTF8String]));
0
+ }
0
+ }
0
+
0
+ ATSFontIteratorRelease(&fi);
0
+ rb_funcall(ary, rb_intern("uniq!"), 0);
0
+ rb_funcall(ary, rb_intern("sort!"), 0);
0
+ return ary;
0
+}
0
+
0
+VALUE
0
 shoes_load_font(const char *filename)
0
 {
0
   FSRef fsRef;
0
@@ -517,15 +542,14 @@ shoes_load_font(const char *filename)
0
           fontName = NULL;
0
           ATSFontGetName(fonts[i], kATSOptionFlagsDefault, &fontName);
0
           if (fontName != NULL)
0
- {
0
             rb_ary_push(families, rb_str_new2([fontName UTF8String]));
0
- }
0
         }
0
         SHOE_FREE(fonts);
0
       }
0
     }
0
   }
0
 
0
+ shoes_update_fonts(shoes_font_list());
0
   return families;
0
 }
0
 

Comments

    No one has commented yet.