1
/* GdkGLExt - OpenGL Extension to GDK
2
* Copyright (C) 2002-2004 Naofumi Yasufuku
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21
#include <pango/pangox.h>
24
#include "gdkglprivate-x11.h"
25
#include "gdkglfont.h"
27
#ifdef GDKGLEXT_MULTIHEAD_SUPPORT
28
#include <gdk/gdkdisplay.h>
29
#endif /* GDKGLEXT_MULTIHEAD_SUPPORT */
32
* This code is ripped from gdk/x11/gdkfont-x11.c in GTK+.
35
gdk_gl_font_charset_for_locale (void)
37
static char *charset_map[][2] = {
38
{ "ANSI_X3.4-1968", "iso8859-1" },
39
{ "US-ASCII", "iso8859-1" },
40
{ "ISO-8859-1", "iso8859-1" },
41
{ "ISO-8859-2", "iso8859-2" },
42
{ "ISO-8859-3", "iso8859-3" },
43
{ "ISO-8859-4", "iso8859-4" },
44
{ "ISO-8859-5", "iso8859-5" },
45
{ "ISO-8859-6", "iso8859-6" },
46
{ "ISO-8859-7", "iso8859-7" },
47
{ "ISO-8859-8", "iso8859-8" },
48
{ "ISO-8859-9", "iso8859-9" },
49
{ "UTF-8", "iso8859-1" }
56
g_get_charset (&codeset);
58
for (i = 0; i < G_N_ELEMENTS (charset_map); i++)
59
if (strcmp (charset_map[i][0], codeset) == 0)
61
result = charset_map[i][1];
66
return g_strdup (result);
68
return g_strdup ("iso8859-1");
72
gdk_gl_font_use_pango_font_common (PangoFontMap *font_map,
73
const PangoFontDescription *font_desc,
78
PangoFont *font = NULL;
79
gchar *charset = NULL;
80
PangoXSubfont subfont_id;
82
PangoXFontCache *font_cache;
85
GDK_GL_NOTE_FUNC_PRIVATE ();
87
font = pango_font_map_load_font (font_map, NULL, font_desc);
90
g_warning ("cannot load PangoFont");
94
charset = gdk_gl_font_charset_for_locale ();
95
if (!pango_x_find_first_subfont (font, &charset, 1, &subfont_id))
97
g_warning ("cannot find PangoXSubfont");
102
xlfd = pango_x_font_subfont_xlfd (font, subfont_id);
105
g_warning ("cannot get XLFD");
110
font_cache = pango_x_font_map_get_font_cache (font_map);
112
fs = pango_x_font_cache_load (font_cache, xlfd);
114
glXUseXFont (fs->fid, first, count, list_base);
116
pango_x_font_cache_unload (font_cache, fs);
130
* gdk_gl_font_use_pango_font:
131
* @font_desc: a #PangoFontDescription describing the font to use.
132
* @first: the index of the first glyph to be taken.
133
* @count: the number of glyphs to be taken.
134
* @list_base: the index of the first display list to be generated.
136
* Creates bitmap display lists from a #PangoFont.
138
* Return value: the #PangoFont used, or NULL if no font matched.
141
gdk_gl_font_use_pango_font (const PangoFontDescription *font_desc,
146
PangoFontMap *font_map;
148
g_return_val_if_fail (font_desc != NULL, NULL);
152
#ifdef GDKGLEXT_MULTIHEAD_SUPPORT
153
font_map = pango_x_font_map_for_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
154
#else /* GDKGLEXT_MULTIHEAD_SUPPORT */
155
font_map = pango_x_font_map_for_display (gdk_x11_get_default_xdisplay ());
156
#endif /* GDKGLEXT_MULTIHEAD_SUPPORT */
158
return gdk_gl_font_use_pango_font_common (font_map, font_desc,
159
first, count, list_base);
162
#ifdef GDKGLEXT_MULTIHEAD_SUPPORT
165
* gdk_gl_font_use_pango_font_for_display:
166
* @display: a #GdkDisplay.
167
* @font_desc: a #PangoFontDescription describing the font to use.
168
* @first: the index of the first glyph to be taken.
169
* @count: the number of glyphs to be taken.
170
* @list_base: the index of the first display list to be generated.
172
* Creates bitmap display lists from a #PangoFont.
174
* Return value: the #PangoFont used, or NULL if no font matched.
177
gdk_gl_font_use_pango_font_for_display (GdkDisplay *display,
178
const PangoFontDescription *font_desc,
183
PangoFontMap *font_map;
185
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
186
g_return_val_if_fail (font_desc != NULL, NULL);
190
font_map = pango_x_font_map_for_display (GDK_DISPLAY_XDISPLAY (display));
192
return gdk_gl_font_use_pango_font_common (font_map, font_desc,
193
first, count, list_base);
196
#endif /* GDKGLEXT_MULTIHEAD_SUPPORT */