]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/gtkutil/glfont.cpp
fixed compile errors
[xonotic/netradiant.git] / libs / gtkutil / glfont.cpp
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant 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 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant 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.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 #include "glfont.h"
23
24 #include "igl.h"
25 //#include <gtk/gtkglwidget.h>
26
27 GLFont glfont_create(const char* font_string)
28 {
29   GLuint font_list_base = glGenLists (256);
30   gint font_height = 0;
31
32   PangoFontDescription* font_desc = pango_font_description_from_string (font_string);
33
34   PangoFont* font = gdk_gl_font_use_pango_font (font_desc, 0, 256, font_list_base);
35
36   if(font != 0)
37   {
38     PangoFontMetrics* font_metrics = pango_font_get_metrics (font, 0);
39
40     font_height = pango_font_metrics_get_ascent (font_metrics) +
41                   pango_font_metrics_get_descent (font_metrics);
42     font_height = PANGO_PIXELS (font_height);
43
44     pango_font_metrics_unref (font_metrics);
45   }
46
47   pango_font_description_free (font_desc);
48
49   return GLFont(font_list_base, font_height);
50 }
51
52 void glfont_release(GLFont& font)
53 {
54   glDeleteLists(font.getDisplayList(), 256);
55   font = GLFont(0, 0);
56 }