re: enumerating available fonts



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]