2 font-config.cc -- implement FontConfig related functions
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
13 #include <fontconfig/fontconfig.h>
16 #include "file-path.hh"
21 FcConfig *font_config_global = 0;
26 if (be_verbose_global)
27 message (_ ("Initializing FontConfig..."));
29 font_config_global = FcInitLoadConfig ();
30 FcChar8 *cache_file = FcConfigGetCache (font_config_global);
33 This is a terrible kludge, but there is apparently no way for
34 FontConfig to signal whether it needs to rescan directories.
36 if (!is_file ((char*)cache_file))
37 message (_f ("Rebuilding FontConfig cache %s. this may take a while...", cache_file));
39 FcConfigBuildFonts (font_config_global);
40 FcConfigSetCurrent (font_config_global);
44 dirs.push (prefix_directory + "/fonts/otf/");
45 dirs.push (prefix_directory + "/fonts/type1/");
47 for (int i = 0; i < dirs.size (); 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 ()));
56 font_config_global = FcConfigGetCurrent ();
58 if (be_verbose_global)
59 progress_indication ("\n");
61 if (!is_file ((char*)cache_file))
63 /* inhibit future messages. */
64 FILE *f = fopen ((char*)cache_file, "w");