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/gtk.c: the FONTS list is now working on GTK/Fontconfig as 
 well.
why (author)
Mon Oct 06 08:54:38 -0700 2008
commit  e99be98d7841b322878eef8f6b1e9bd8d87bcfaa
tree    b4faeebe0549af063dd8c15e69ed06ea23158706
parent  592b099993dcd43a3c8727584757c5b0afaa30c0
...
21
22
23
24
 
25
26
 
27
28
29
...
31
32
33
 
34
35
36
37
38
39
 
40
41
42
 
 
 
 
 
43
44
45
46
47
48
49
50
51
52
53
54
 
 
55
56
57
...
21
22
23
 
24
25
 
26
27
28
29
...
31
32
33
34
35
36
37
38
39
40
41
42
 
 
43
44
45
46
47
48
49
50
51
52
 
53
54
55
56
57
 
58
59
60
61
62
0
@@ -21,9 +21,9 @@
0
 #define SHOES_GTK_INVISIBLE_CHAR (gunichar)0x2022
0
 
0
 static VALUE
0
-shoes_make_font_list(FcFontSet *fonts)
0
+shoes_make_font_list(FcFontSet *fonts, VALUE ary)
0
 {
0
- VALUE ary = rb_ary_new();
0
+ int i = 0;
0
   for (i = 0; i < fonts->nfont; i++)
0
   {
0
     FcValue val;
0
@@ -31,27 +31,32 @@ shoes_make_font_list(FcFontSet *fonts)
0
     if (FcPatternGet(p, FC_FAMILY, 0, &val) == FcResultMatch)
0
       rb_ary_push(ary, rb_str_new2(val.u.s));
0
   }
0
+ rb_funcall(ary, rb_intern("sort!"), 0);
0
   return ary;
0
 }
0
 
0
 VALUE
0
 shoes_font_list()
0
 {
0
+ VALUE ary = rb_ary_new();
0
   FcConfig *fc = FcConfigGetCurrent();
0
- FcFontSet *fonts = FcConfigGetFonts(fc, FcSetSystem);
0
- return shoes_make_font_list(fonts);
0
+ FcFontSet *fonts = FcConfigGetFonts(fc, FcSetApplication);
0
+ if (fonts) shoes_make_font_list(fonts, ary);
0
+ fonts = FcConfigGetFonts(fc, FcSetSystem);
0
+ if (fonts) shoes_make_font_list(fonts, ary);
0
+ return ary;
0
 }
0
 
0
 VALUE
0
 shoes_load_font(const char *filename)
0
 {
0
- int i = 0;
0
   FcConfig *fc = FcConfigGetCurrent();
0
   FcFontSet *fonts = FcFontSetCreate();
0
   if (!FcFileScan(fonts, NULL, NULL, NULL, filename, FcTrue))
0
     return Qnil;
0
 
0
- VALUE ary = shoes_make_font_list(fonts);
0
+ VALUE ary = rb_ary_new();
0
+ shoes_make_font_list(fonts, ary);
0
   FcFontSetDestroy(fonts);
0
 
0
   if (!FcConfigAppFontAddFile(fc, filename))

Comments

    No one has commented yet.