X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ffont-config-scheme.cc;h=482a240c9f0b084f0f9f9486790af1c9be5925d5;hb=1f6390c76c5bbe70c51789785d4e04ee236340bc;hp=94ba57b76dc0f839d41eec3ba3fd727bed3d1e6e;hpb=161b1f2747316ea1652f080d3b7d0ae7848ed441;p=lilypond.git diff --git a/lily/font-config-scheme.cc b/lily/font-config-scheme.cc index 94ba57b76d..482a240c9f 100644 --- a/lily/font-config-scheme.cc +++ b/lily/font-config-scheme.cc @@ -3,11 +3,12 @@ source file of the GNU LilyPond music typesetter - (c) 2005 Han-Wen Nienhuys + (c) 2005--2006 Han-Wen Nienhuys */ #include "lily-guile.hh" +#include "std-string.hh" #include @@ -25,13 +26,31 @@ display_fontset (FcFontSet *fs) printf ("FILE %s\n", str); if (FcPatternGetString (fs->fonts[j], FC_FAMILY, 0, &str) == FcResultMatch) printf ("family %s\n ", str); - if (FcPatternGetString (fs->fonts[j], "designsize", 0, &str) == FcResultMatch) + if (FcPatternGetString (fs->fonts[j], + "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) @@ -42,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); @@ -55,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; } + +