]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-config-scheme.cc
279ffb57b3a2bdb3e69a2c8701110d78145a5d4d
[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],
29                               "designsize", 0, &str) == FcResultMatch)
30         printf ("designsize %s\n ", str);
31       
32       printf ("%s\n", (const char*) font);
33       free (font);
34     }
35 }
36
37
38 void
39 display_list (FcConfig *fcc)
40 {
41   FcPattern*pat = FcPatternCreate ();
42
43   FcObjectSet *os = 0;
44   if (!os)
45     os = FcObjectSetBuild (FC_FAMILY, FC_STYLE, (char *) 0);
46
47   FcFontSet   * fs = FcFontList (fcc, pat, os);
48   FcObjectSetDestroy (os);
49   if (pat)
50     FcPatternDestroy (pat);
51
52   if (fs)
53     {
54       display_fontset (fs);
55       FcFontSetDestroy (fs);
56     }
57 }
58
59
60 LY_DEFINE (ly_font_config_display_fonts, "ly:font-config-display-fonts", 0, 0, 0,
61            (),
62            "Dump a list of all fonts visible to FontConfig.")
63
64 {
65   display_list (NULL);
66   
67   return SCM_UNSPECIFIED;
68 }