Fix type predicates/docstrings for two music properties.
[lilypond/mpolesky.git] / lily / font-config.cc
blobcffe4d9d69dae10f6ad645ed7d15dee24a004037
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "config.hh"
22 #if HAVE_FONTCONFIG
24 #include <cstdio>
25 #include <fontconfig/fontconfig.h>
26 #include <sys/stat.h>
28 #include "file-path.hh"
29 #include "international.hh"
30 #include "main.hh"
31 #include "warn.hh"
34 FcConfig *font_config_global = 0;
36 void
37 init_fontconfig ()
39 if (be_verbose_global)
40 message (_ ("Initializing FontConfig..."));
42 font_config_global = FcInitLoadConfig ();
43 FcChar8 *cache_file = FcConfigGetCache (font_config_global);
45 #if 0
46 // always returns 0 for FC 2.4
47 if (!cache_file)
48 programming_error ("Cannot find file for FontConfig cache.");
49 #endif
51 This is a terrible kludge, but there is apparently no way for
52 FontConfig to signal whether it needs to rescan directories.
53 */
54 if (cache_file
55 && !is_file ((char const *)cache_file))
56 message (_f ("Rebuilding FontConfig cache %s, this may take a while...", cache_file));
58 vector<string> dirs;
60 /* Extra trailing slash suddenly breaks fontconfig (fc-cache 2.5.0)
61 on windows. */
62 dirs.push_back (lilypond_datadir + "/fonts/otf");
64 for (vsize i = 0; i < dirs.size (); i++)
66 string dir = dirs[i];
67 if (!FcConfigAppFontAddDir (font_config_global, (FcChar8 *)dir.c_str ()))
68 error (_f ("failed adding font directory: %s", dir.c_str ()));
69 else if (be_verbose_global)
70 message (_f ("adding font directory: %s", dir.c_str ()));
73 if (be_verbose_global)
74 message (_ ("Building font database."));
75 FcConfigBuildFonts (font_config_global);
76 FcConfigSetCurrent (font_config_global);
77 if (be_verbose_global)
78 message ("\n");
80 if (cache_file
81 && !is_file ((char*)cache_file))
83 /* inhibit future messages. */
84 FILE *f = fopen ((char*)cache_file, "w");
85 if (f)
86 fclose (f);
91 #else
93 void
94 init_fontconfig ()
98 #endif