1 /* viewer-pangox.c: PangoX viewer backend.
3 * Copyright (C) 1999,2004,2005 Red Hat, Inc.
4 * Copyright (C) 2001 Sun Microsystems
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #include "viewer-render.h"
26 #include <pango/pangox.h>
29 pangox_view_destroy (gpointer instance)
31 XViewer *x = (XViewer *)instance;
33 pango_x_shutdown_display (x->display);
35 x_view_destroy (instance);
39 pangox_view_get_context (gpointer instance)
41 XViewer *x = (XViewer *) instance;
42 PangoContext *context;
43 PangoMatrix matrix = {0., 0., 0., 0., 0., 0.};
45 context = pango_font_map_create_context (pango_x_font_map_for_display (x->display));
47 /* We set an all-zero matrix on the context, to negotiate that
48 * this backend doesn't support transformations.
50 pango_context_set_matrix (context, &matrix);
63 render_callback (PangoLayout *layout,
67 gpointer state G_GNUC_UNUSED)
69 MyXContext *x_context = (MyXContext *) context;
71 pango_x_render_layout (x_context->x->display,
79 pangox_view_render (gpointer instance,
81 PangoContext *context,
86 XViewer *x = (XViewer *) instance;
87 Pixmap pixmap = (Pixmap) surface;
91 gc = XCreateGC (x->display, pixmap, 0, NULL);
93 XSetForeground(x->display, gc, WhitePixel(x->display, x->screen));
94 XFillRectangle (x->display, pixmap, gc, 0, 0, *width, *height);
97 x_context.drawable = pixmap;
100 XSetForeground(x->display, gc, BlackPixel(x->display, x->screen));
101 do_output (context, render_callback, NULL, &x_context, state, width, height);
105 XFreeGC (x->display, gc);
108 const PangoViewer pangox_viewer = {
114 pangox_view_get_context,
115 x_view_create_surface,
116 x_view_destroy_surface,
119 x_view_create_window,
120 x_view_destroy_window,