]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-config-scheme.cc
*** empty log message ***
[lilypond.git] / lily / font-config-scheme.cc
1 /*
2   font-config-scheme.cc -- implement FontConfig bindings.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "lily-guile.hh"
11
12 #include <fontconfig/fontconfig.h>
13
14 void
15 display_fontset (FcFontSet *fs)
16 {
17   int j;
18   for (j = 0; j < fs->nfont; j++)
19     {
20       FcChar8 *font;
21       FcChar8 *str;
22
23       font = FcNameUnparse (fs->fonts[j]);
24       if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &str) == FcResultMatch)
25         printf ("FILE %s\n", str);
26       if (FcPatternGetString (fs->fonts[j], FC_FAMILY, 0, &str) == FcResultMatch)
27         printf ("family %s\n ", str);
28       if (FcPatternGetString (fs->fonts[j], "designsize", 0, &str) == FcResultMatch)
29         printf ("designsize %s\n ", str);
30       printf ("%s\n", font);
31       free (font);
32     }
33 }
34
35
36 void
37 display_list (FcConfig *fcc)
38 {
39   FcPattern*pat = FcPatternCreate ();
40
41   FcObjectSet *os = 0;
42   if (!os)
43     os = FcObjectSetBuild (FC_FAMILY, FC_STYLE, (char *) 0);
44
45   FcFontSet   * fs = FcFontList (fcc, pat, os);
46   FcObjectSetDestroy (os);
47   if (pat)
48     FcPatternDestroy (pat);
49
50   if (fs)
51     {
52       display_fontset (fs);
53       FcFontSetDestroy (fs);
54     }
55 }
56
57
58 LY_DEFINE (ly_font_config_display_fonts, "ly:font-config-display-fonts", 0, 0, 0,
59            (),
60            "Dump a list of all fonts visible to FontConfig.")
61
62 {
63   display_list (NULL);
64   
65   return SCM_UNSPECIFIED;
66 }