From d1df267f3880d560d778edb115a63acce689737f Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 14 Jul 2003 16:50:46 +0000 Subject: List all mozilla fonts and not only the language specific, otherwise we 2003-07-14 Marco Pesenti Gritti * embed/mozilla/mozilla-embed-single.cpp: List all mozilla fonts and not only the language specific, otherwise we get empty list. Use fontconfig aliases as defaults. This is temporary until we design simpler fonts configuration. --- embed/mozilla/mozilla-embed-single.cpp | 54 +++++++++++----------------------- 1 file changed, 17 insertions(+), 37 deletions(-) (limited to 'embed') diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 6d03e08d4..ca2e4fd3f 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -795,54 +795,34 @@ impl_get_font_list (EphyEmbedSingle *shell, char **default_font) { nsresult rv; + PRUint32 fontCount; + PRUnichar **fontArray; + GList *l = NULL; - nsCOMPtr mozFontList; - mozFontList = do_CreateInstance("@mozilla.org/gfx/fontlist;1", &rv); + nsCOMPtr mozFontEnumerator; + mozFontEnumerator = do_CreateInstance("@mozilla.org/gfx/fontenumerator;1", &rv); if(NS_FAILED(rv)) return G_FAILED; - nsCOMPtr fontEnum; - mozFontList->AvailableFonts(NS_ConvertUTF8toUCS2(langGroup).get(), - NS_ConvertUTF8toUCS2(fontType).get(), - getter_AddRefs(fontEnum)); - if(NS_FAILED(rv)) return G_FAILED; + rv = mozFontEnumerator->EnumerateFonts (nsnull, nsnull, + &fontCount, &fontArray); + if (NS_FAILED (rv)) return G_FAILED; - GList *l = NULL; - PRBool enumResult; - for(fontEnum->HasMoreElements(&enumResult) ; - enumResult == PR_TRUE; - fontEnum->HasMoreElements(&enumResult)) + for (int i = 0; i < fontCount; i++) { - nsCOMPtr fontName; - fontEnum->GetNext(getter_AddRefs(fontName)); - if(NS_FAILED(rv)) return G_FAILED; - - nsString fontString; - fontName->GetData(fontString); - char *gFontString; - gFontString = g_strdup(NS_ConvertUCS2toUTF8(fontString).get()); + + gFontString = g_strdup(NS_ConvertUCS2toUTF8 (fontArray[i]).get()); l = g_list_prepend (l, gFontString); + nsMemory::Free (fontArray[i]); } + + nsMemory::Free (fontArray); + *fontList = g_list_reverse (l); if (default_font != NULL) { - char key[255]; - char *value = NULL; - nsCOMPtr prefService; - - prefService = do_GetService (NS_PREFSERVICE_CONTRACTID); - g_return_val_if_fail (prefService != NULL, G_FAILED); - - nsCOMPtr pref; - prefService->GetBranch ("", getter_AddRefs(pref)); - g_return_val_if_fail (pref != NULL, G_FAILED); - - sprintf (key, "font.name.%s.%s", fontType, langGroup); - - pref->GetCharPref (key, &value); - *default_font = g_strdup (value); - nsMemory::Free (value); + *default_font = g_strdup (fontType); } return G_OK; -- cgit v1.2.3