]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/font-config-scheme.cc
Made tupletSpannerDuration work again.
[lilypond.git] / lily / font-config-scheme.cc
index 79b069befa1767fc3c59145da6dc569ea928c795..482a240c9f0b084f0f9f9486790af1c9be5925d5 100644 (file)
@@ -3,11 +3,12 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
 */
 
 #include "lily-guile.hh"
+#include "std-string.hh"
 
 #include <fontconfig/fontconfig.h>
 
@@ -29,11 +30,27 @@ display_fontset (FcFontSet *fs)
                              "designsize", 0, &str) == FcResultMatch)
        printf ("designsize %s\n ", str);
       
-      printf ("%s\n", font);
+      printf ("%s\n", (const char*) font);
       free (font);
     }
 }
 
+void
+display_strlist (char const*what, FcStrList *slist)
+{
+  while (FcChar8 *dir = FcStrListNext (slist))
+    {
+      printf("%s: %s\n", what, dir);
+    }
+}
+
+void
+display_config (FcConfig *fcc)
+{
+  display_strlist ("Config files", FcConfigGetConfigFiles(fcc));
+  display_strlist ("Config dir", FcConfigGetConfigDirs(fcc));
+  display_strlist ("Font dir", FcConfigGetFontDirs(fcc));
+}
 
 void
 display_list (FcConfig *fcc)
@@ -44,7 +61,7 @@ display_list (FcConfig *fcc)
   if (!os)
     os = FcObjectSetBuild (FC_FAMILY, FC_STYLE, (char *) 0);
 
-  FcFontSet   * fs = FcFontList (fcc, pat, os);
+  FcFontSet *fs = FcFontList (fcc, pat, os);
   FcObjectSetDestroy (os);
   if (pat)
     FcPatternDestroy (pat);
@@ -57,12 +74,45 @@ display_list (FcConfig *fcc)
 }
 
 
+LY_DEFINE (ly_font_config_get_font_file, "ly:font-config-get-font-file", 1, 0, 0,
+          (SCM name),
+          "Get the file for font @var{name}")
+{
+  SCM_ASSERT_TYPE (scm_is_string (name), name,
+                  SCM_ARG1, __FUNCTION__, "string");
+
+  
+  FcPattern*pat = FcPatternCreate ();
+  FcValue val;
+  
+  val.type = FcTypeString;
+  val.u.s = (const FcChar8*)ly_scm2string (name).c_str (); // FC_SLANT_ITALIC;
+  FcPatternAdd(pat, FC_FAMILY, val, FcFalse);
+
+  FcResult result;
+  SCM scm_result = SCM_BOOL_F;
+
+  FcConfigSubstitute (NULL, pat, FcMatchFont);
+  FcDefaultSubstitute (pat);
+  
+  pat = FcFontMatch(NULL, pat, &result);
+  FcChar8 *str = 0;
+  if (FcPatternGetString (pat, FC_FILE, 0, &str) == FcResultMatch)
+    scm_result = scm_makfrom0str ((char const*) str);
+
+  FcPatternDestroy (pat);
+
+  return scm_result;
+}
+          
 LY_DEFINE (ly_font_config_display_fonts, "ly:font-config-display-fonts", 0, 0, 0,
           (),
           "Dump a list of all fonts visible to FontConfig.")
-
 {
   display_list (NULL);
+  display_config (NULL);
   
   return SCM_UNSPECIFIED;
 }
+
+