]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-config.cc
aac1eeb7094f7657572e32f7beee63f3495ab665
[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 #ifdef 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   Array<String> dirs;
30   struct stat statbuf; 
31   String builddir = prefix_directory + "/mf/out/";
32
33   if (stat (builddir.to_str0 (), &statbuf) == 0)
34     dirs.push (builddir.to_str0 ());
35   else
36     {
37       dirs.push (prefix_directory + "/fonts/otf/");
38       dirs.push (prefix_directory + "/fonts/type1/");
39       dirs.push (prefix_directory + "/fonts/cff/");
40       dirs.push (prefix_directory + "/fonts/svg/");
41     }
42   
43   for (int i = 0; i < dirs.size (); i++)
44     {
45       String dir = dirs[i];
46       if (!FcConfigAppFontAddDir (fcc, (FcChar8 *)dir.to_str0 ()))
47         error (_f ("adding lilypond directory: %s", dir.to_str0 ()));
48       else if (be_verbose_global)
49         message (_f ("adding font directory: %s", dir.to_str0 ()));
50     }
51
52   if (be_verbose_global)
53     progress_indication ("\n");
54 }
55
56 #else
57
58 void
59 init_fontconfig ()
60 {
61 }
62 #endif