1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2000 Red Hat, Inc.
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.
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
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 #include "gdkdisplay-x11.h"
26 #include <pango/pangox.h>
28 #include <pango/pangoxft.h>
32 * gdk_pango_context_get_for_screen:
33 * @screen: the #GdkScreen for which the context is to be created.
35 * Creates a #PangoContext for @screen.
37 * The context must be freed when you're finished with it.
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.
43 * Return value: a new #PangoContext for @screen
46 gdk_pango_context_get_for_screen (GdkScreen *screen)
48 PangoContext *context;
49 GdkDisplayX11 *display_x11;
51 g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
56 display_x11 = GDK_DISPLAY_X11 (GDK_SCREEN_DISPLAY (screen));
59 if (display_x11->use_xft == -1)
61 const char *val = g_getenv ("GDK_USE_XFT");
63 /* Version 2 of Xft supports rendering FreeType fonts via
64 * the core X protocol, so we default to it everywhere.
66 * For Xft1, we only enable Xft if the user explicitely
67 * specifies it, and we have the RENDER extension
70 display_x11->use_xft = !val || (atoi (val) != 0);
72 display_x11->use_xft = val && (atoi (val) != 0) &&
73 _gdk_x11_have_render (GDK_SCREEN_DISPLAY (screen));
74 # endif /* HAVE_XFT2 */
77 if (display_x11->use_xft)
78 context = pango_xft_get_context (GDK_SCREEN_XDISPLAY (screen),
79 GDK_SCREEN_X11 (screen)->screen_num);
82 context = pango_x_get_context (GDK_SCREEN_XDISPLAY (screen));
84 g_object_set_data (G_OBJECT (context), "gdk-pango-screen", screen);