]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-config.cc
(init_fontconfig): resurrect mf/out/ check.
[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 FcConfig *font_config_global = 0;
20
21 void
22 init_fontconfig ()
23 {
24   if (be_verbose_global)
25     message (_ ("Initializing FontConfig..."));
26
27   if (!FcInit ())
28     error (_ ("initializing FontConfig failed"));
29
30   font_config_global = FcConfigGetCurrent ();
31   Array<String> dirs;
32   String builddir = prefix_directory + "/mf/out/";
33
34   struct stat statbuf;
35   if (stat (builddir.to_str0 (), &statbuf) == 0)
36     dirs.push (builddir.to_str0 ());
37   else
38     {
39       /*
40         ugh. C&P main.cc
41       */
42       dirs.push (prefix_directory + "/fonts/otf/");
43       dirs.push (prefix_directory + "/fonts/type1/");
44       dirs.push (prefix_directory + "/fonts/cff/");
45       dirs.push (prefix_directory + "/fonts/svg/");
46     }  
47   for (int i = 0; i < dirs.size (); i++)
48     {
49       String dir = dirs[i];
50       if (!FcConfigAppFontAddDir (font_config_global, (FcChar8 *)dir.to_str0 ()))
51         error (_f ("adding font directory: %s", dir.to_str0 ()));
52       else if (be_verbose_global)
53         message (_f ("adding font directory: %s", dir.to_str0 ()));
54     }
55
56   if (be_verbose_global)
57     progress_indication ("\n");
58 }
59
60 #else
61
62 void
63 init_fontconfig ()
64 {
65 }
66
67 #endif