3 * Copyright (C) 2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
23 #include "font-util.h"
25 #include <pango/pango.h>
26 #include <pango/pangocairo.h>
27 #include <glib/gstrfuncs.h>
28 #include <libglabels/str.h>
31 /****************************************************************************/
32 /* Get list of all available font families. */
33 /****************************************************************************/
35 gl_font_util_get_all_families (void)
37 static GList *list = NULL;
38 PangoFontMap *fontmap;
39 PangoContext *context;
40 PangoFontFamily **families;
47 fontmap = pango_cairo_font_map_new ();
48 context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
50 pango_context_list_families (context, &families, &n);
54 name = g_strdup (pango_font_family_get_name (families[i]));
55 list = g_list_insert_sorted (list, name,
56 (GCompareFunc)lgl_str_utf8_casecmp);
61 g_object_unref (context);
62 g_object_unref (fontmap);
69 /****************************************************************************/
70 /* Get list of all available proportional font families. */
71 /****************************************************************************/
73 gl_font_util_get_proportional_families (void)
75 static GList *list = NULL;
76 PangoFontMap *fontmap;
77 PangoContext *context;
78 PangoFontFamily **families;
85 fontmap = pango_cairo_font_map_new ();
86 context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
88 pango_context_list_families (context, &families, &n);
92 if ( !pango_font_family_is_monospace (families[i]) )
94 name = g_strdup (pango_font_family_get_name (families[i]));
95 list = g_list_insert_sorted (list, name,
96 (GCompareFunc)lgl_str_utf8_casecmp);
102 g_object_unref (context);
103 g_object_unref (fontmap);
110 /****************************************************************************/
111 /* Get list of all available fixed-width font families. */
112 /****************************************************************************/
114 gl_font_util_get_fixed_width_families (void)
116 static GList *list = NULL;
117 PangoFontMap *fontmap;
118 PangoContext *context;
119 PangoFontFamily **families;
126 fontmap = pango_cairo_font_map_new ();
127 context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
129 pango_context_list_families (context, &families, &n);
131 for ( i=0; i<n; i++ )
133 if ( pango_font_family_is_monospace (families[i]) )
135 name = g_strdup (pango_font_family_get_name (families[i]));
136 list = g_list_insert_sorted (list, name,
137 (GCompareFunc)lgl_str_utf8_casecmp);
143 g_object_unref (context);
144 g_object_unref (fontmap);
153 * Local Variables: -- emacs
155 * c-basic-offset: 8 -- emacs
156 * tab-width: 8 -- emacs
157 * indent-tabs-mode: nil -- emacs