]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-config.cc
(precision_string): >? fix.
[lilypond.git] / lily / font-config.cc
1 /*
2   font-config.cc -- implement FontConfig related functions
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "config.hh"
10
11 #if HAVE_FONTCONFIG
12
13 #include <fontconfig/fontconfig.h>
14 #include <sys/stat.h>
15 #include "file-path.hh"
16 #include "main.hh"
17 #include "warn.hh"
18
19 void
20 init_fontconfig ()
21 {
22   if (be_verbose_global)
23     message (_ ("Initializing FontConfig..."));
24   
25   if (!FcInit ())
26     error (_ ("initializing FontConfig"));
27
28   FcConfig *fcc = FcConfigGetCurrent ();
29
30
31 #if 0
32   /*
33     Hmm. the cache is always out of date??!
34    */
35   FcChar8 *cache = FcConfigGetCache (fcc);
36   if (!FcDirCacheValid (cache))
37     {
38       warning (_ ("FontConfig cache out of date. Rebuilding may take some time."));
39     }
40 #endif
41   
42   Array<String> dirs;
43   struct stat statbuf; 
44   String builddir = prefix_directory + "/mf/out/";
45
46   if (stat (builddir.to_str0 (), &statbuf) == 0)
47     dirs.push (builddir.to_str0 ());
48   else
49     {
50       dirs.push (prefix_directory + "/fonts/otf/");
51       dirs.push (prefix_directory + "/fonts/type1/");
52       dirs.push (prefix_directory + "/fonts/svg/");
53     }
54   
55   for (int i = 0; i < dirs.size (); i++)
56     {
57       String dir = dirs[i];
58       if (!FcConfigAppFontAddDir (fcc, (FcChar8 *)dir.to_str0 ()))
59         error (_f ("adding font directory: %s", dir.to_str0 ()));
60       else if (be_verbose_global)
61         message (_f ("adding font directory: %s", dir.to_str0 ()));
62     }
63
64   if (be_verbose_global)
65     progress_indication ("\n");
66 }
67
68 #else
69
70 void
71 init_fontconfig ()
72 {
73   
74 }
75
76 #endif