re: enumerating available fonts
- From: "Garth's KidStuff" <garthskidstuff gmail com>
- To: gtk-app-devel-list gnome org
- Subject: re: enumerating available fonts
- Date: Wed, 18 Mar 2009 14:33:05 -0700
How do I enumerate the fonts available on a system?
Here's a little function using Gtkmm that I use...
vector<string>* LXUtils::GetAllFontNames()
{ // RETURN a pointer to a static string vector that contains the font names
static vector<string> vsFonts;
    if (vsFonts.empty())
    { // Only bother to do this the first time through
        LXMainWindow* pWind = LXMainWindow::GetAppMainWindow(); // Get
Gtk::Window*
        Glib::RefPtr<Pango::Context> rPC = pWind->get_pango_context();
        Glib::ArrayHandle< Glib::RefPtr<Pango::FontFamily> > fonts =
rPC->list_families();
Glib::Container_Helpers::ArrayHandleIterator<Glib::Container_Helpers::TypeTraits<Glib::RefPtr<Pango::FontFamily>
iFont = fonts.begin();
        for (; iFont != fonts.end(); iFont++)
        {
            vsFonts.push_back((*iFont)->get_name());
        }
    }
    return &vsFonts;
}
-- 
Garth Upshaw
Garth's KidStuff
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]