source: trunk/third/libgnomeprintui/examples/example_04.c @ 18338

Revision 18338, 3.0 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18337, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 *  example_04.c: sample gnome-print code
4 *
5 *  This program is free software; you can redistribute it and/or
6 *  modify it under the terms of the GNU Library General Public License
7 *  as published by the Free Software Foundation; either version 2 of
8 *  the License, or (at your option) any later version.
9 *
10 *  This program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU Library General Public License for more details.
14 *
15 *  You should have received a copy of the GNU Library General Public
16 *  License along with this program; if not, write to the Free Software
17 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 *  Authors:
20 *    Chema Celorio <chema@ximian.com>
21 *
22 *  Copyright (C) 2002 Ximian Inc. and authors
23 *
24 */
25
26/*
27 * See README
28 */
29
30#include <libgnomeprint/gnome-print.h>
31#include <libgnomeprint/gnome-print-master.h>
32#include <libgnomeprintui/gnome-print-dialog.h>
33#include <gtk/gtkwidget.h>
34#include <gtk/gtkdialog.h>
35#include <gtk/gtkmain.h>
36#include <string.h>
37
38static void
39my_draw (GnomePrintContext *gpc)
40{
41        GnomeFont *font;
42        const guchar *font_name;
43        /* Make some UTF-8 strings */
44        const guchar acented [] = {0xC3, 0xA0, 0xC3, 0xA8, 0xC3, 0xAC,
45                                   0xC3, 0xB2, 0xC3, 0xB9, 0x20, 0xC3,
46                                   0xB1, 0xC3, 0x91, 0x20, 0xC3, 0xBB,
47                                   0xC3, 0xB4, 0x20, 0x0A, 0x00};
48        const guchar cyrillic[] = {0xD0, 0xA1, 0xD0, 0xBE, 0xD0, 0xBC, 0xD0, 0xB5,
49                                   0x20, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xBD,
50                                   0xD0, 0xB4, 0xD0, 0xBE, 0xD0, 0xBC, 0x20, 0xD1,
51                                   0x86, 0xD1, 0x8B, 0xD1, 0x80, 0xD1, 0x83,
52                                   0xD0, 0xBB, 0xD0, 0xBB, 0xD0, 0xB8, 0xD1, 0x86,
53                                   0x20, 0xD1, 0x87, 0xD0, 0xB0, 0xD1, 0x80,
54                                   0xD1, 0x81, 0x00};
55
56        /* Get this font from:
57         *   http://bibliofile.mc.duke.edu/gww/fonts/Unicode.html
58         * I used the TTF Caslon Roman.
59         */
60        font = gnome_font_find_closest ("Caslon Roman", 12);
61        font_name = gnome_font_get_name (font);
62        g_print ("Found: %s\n", font_name);
63        if (strcmp (font_name, "Caslon Roman") != 0) {
64                g_print ("You might not see cyrillic characters because Caslon Roman was not found.\n");
65        }
66       
67        gnome_print_beginpage (gpc, "1");
68
69        gnome_print_setfont (gpc, font);
70       
71        gnome_print_moveto (gpc, 100, 700);
72        gnome_print_show (gpc, "Some acented characters:");
73        gnome_print_moveto (gpc, 100, 680);
74        gnome_print_show (gpc, acented);
75
76        gnome_print_moveto (gpc, 100, 650);
77        gnome_print_show (gpc, "Some cyrillic:");
78        gnome_print_moveto (gpc, 100, 630);
79        gnome_print_show (gpc, cyrillic);
80
81        gnome_print_showpage (gpc);
82}
83
84static void
85my_print (void)
86{
87        GnomePrintMaster *gpm;
88        GnomePrintContext *gpc;
89
90        gpm = gnome_print_master_new ();
91        gpc = gnome_print_master_get_context (gpm);
92
93        my_draw (gpc);
94
95        gnome_print_master_close (gpm);
96        gnome_print_master_print (gpm);
97}
98
99int
100main (int argc, char * argv[])
101{
102        gtk_init (&argc, &argv);
103       
104        my_print ();
105
106        g_print ("Done...\n");
107
108        return 0;
109}
Note: See TracBrowser for help on using the repository browser.