]> Pileus Git - ~andy/gtk/blob - gdk/x11/gdkpango-x11.c
Start of integration of Erwann Chenede's multihead work from the
[~andy/gtk] / gdk / x11 / gdkpango-x11.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 2000 Red Hat, Inc. 
3  *
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 of the License, or (at your option) any later version.
8  *
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.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <config.h>
21 #include <stdlib.h>
22
23 #include "gdkx.h"
24 #include "gdkdisplay-x11.h"
25 #include "gdkpango.h"
26 #include <pango/pangox.h>
27 #ifdef HAVE_XFT
28 #include <pango/pangoxft.h>
29 #endif
30
31 /**
32  * gdk_pango_context_get_for_screen:
33  * @screen: the #GdkScreen for which the context is to be created.
34  * 
35  * Creates a #PangoContext for @screen.
36  *
37  * The context must be freed when you're finished with it.
38  * 
39  * When using GTK+, normally you should use gtk_widget_get_pango_context()
40  * instead of this function, to get the appropriate context for
41  * the widget you intend to render text onto.
42  * 
43  * Return value: a new #PangoContext for @screen
44  **/
45 PangoContext *
46 gdk_pango_context_get_for_screen (GdkScreen *screen)
47 {
48   PangoContext *context;
49   GdkDisplayX11 *display_x11;
50   
51   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
52   
53   display_x11 = GDK_DISPLAY_X11 (GDK_SCREEN_DISPLAY (screen));
54   
55 #ifdef HAVE_XFT
56   if (display_x11->use_xft == -1)
57     {
58       const char *val = g_getenv ("GDK_USE_XFT");
59
60       display_x11->use_xft = val && (atoi (val) != 0) && 
61         _gdk_x11_have_render (GDK_SCREEN_DISPLAY (screen));
62     }
63   
64   if (display_x11->use_xft)
65     context = pango_xft_get_context (GDK_SCREEN_XDISPLAY (screen),
66                                      GDK_SCREEN_X11 (screen)->screen_num);
67   else
68 #endif /* HAVE_XFT */
69     context = pango_x_get_context (GDK_SCREEN_XDISPLAY (screen));
70   
71   g_object_set_data (G_OBJECT (context), "gdk-pango-screen", screen);
72   
73   return context;
74 }
75
76 /**
77  * gdk_pango_context_get:
78  * 
79  * Creates a #PangoContext for the default GDK screen.
80  *
81  * The context must be freed when you're finished with it.
82  * 
83  * When using GTK+, normally you should use gtk_widget_get_pango_context()
84  * instead of this function, to get the appropriate context for
85  * the widget you intend to render text onto.
86  * 
87  * Return value: a new #PangoContext for the default display
88  **/
89 PangoContext *
90 gdk_pango_context_get (void)
91 {
92   return gdk_pango_context_get_for_screen (gdk_get_default_screen ());
93 }