From a089ffb45c3473bfdb95edcf351544775dad547e Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 4 Jan 2007 14:09:04 +0100 Subject: [PATCH] use progress_indication to dump font info. Test for this. --- lily/font-config-scheme.cc | 47 ++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/lily/font-config-scheme.cc b/lily/font-config-scheme.cc index 482a240c9f..351319c662 100644 --- a/lily/font-config-scheme.cc +++ b/lily/font-config-scheme.cc @@ -8,13 +8,16 @@ */ #include "lily-guile.hh" -#include "std-string.hh" +#include "string-convert.hh" +#include "warn.hh" #include -void +string display_fontset (FcFontSet *fs) { + string retval; + int j; for (j = 0; j < fs->nfont; j++) { @@ -23,36 +26,42 @@ display_fontset (FcFontSet *fs) font = FcNameUnparse (fs->fonts[j]); if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &str) == FcResultMatch) - printf ("FILE %s\n", str); + retval += String_convert::form_string ("FILE %s\n", str); if (FcPatternGetString (fs->fonts[j], FC_FAMILY, 0, &str) == FcResultMatch) - printf ("family %s\n ", str); + retval += String_convert::form_string ("family %s\n ", str); if (FcPatternGetString (fs->fonts[j], "designsize", 0, &str) == FcResultMatch) - printf ("designsize %s\n ", str); + retval += String_convert::form_string ("designsize %s\n ", str); - printf ("%s\n", (const char*) font); + retval += String_convert::form_string ("%s\n", (const char*) font); free (font); } + + return retval; } -void +string display_strlist (char const*what, FcStrList *slist) { + string retval; while (FcChar8 *dir = FcStrListNext (slist)) { - printf("%s: %s\n", what, dir); + retval += String_convert::form_string ("%s: %s\n", what, dir); } + return retval; } -void +string display_config (FcConfig *fcc) { - display_strlist ("Config files", FcConfigGetConfigFiles(fcc)); - display_strlist ("Config dir", FcConfigGetConfigDirs(fcc)); - display_strlist ("Font dir", FcConfigGetFontDirs(fcc)); + string retval; + retval += display_strlist ("Config files", FcConfigGetConfigFiles(fcc)); + retval += display_strlist ("Config dir", FcConfigGetConfigDirs(fcc)); + retval += display_strlist ("Font dir", FcConfigGetFontDirs(fcc)); + return retval; } -void +string display_list (FcConfig *fcc) { FcPattern*pat = FcPatternCreate (); @@ -66,11 +75,13 @@ display_list (FcConfig *fcc) if (pat) FcPatternDestroy (pat); + string retval; if (fs) { - display_fontset (fs); + retval = display_fontset (fs); FcFontSetDestroy (fs); } + return retval; } @@ -98,7 +109,7 @@ LY_DEFINE (ly_font_config_get_font_file, "ly:font-config-get-font-file", 1, 0, 0 pat = FcFontMatch(NULL, pat, &result); FcChar8 *str = 0; if (FcPatternGetString (pat, FC_FILE, 0, &str) == FcResultMatch) - scm_result = scm_makfrom0str ((char const*) str); + scm_result = scm_from_locale_string ((char const*) str); FcPatternDestroy (pat); @@ -109,8 +120,10 @@ 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); + string str = display_list (NULL); + str += display_config (NULL); + + progress_indication (str); return SCM_UNSPECIFIED; } -- 2.39.5