1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 /* The eps_dump_truetype_body function and much inspiration for font dumping
20 * came from ttfps, which bears the following license notice:
22 Copyright (c) 1997 by Juliusz Chroboczek
27 This software is provided with no guarantee, not even of any kind.
29 Feel free to do whatever you wish with it as long as you don't ask me
34 /* The Document Structure Definitions used for the output is available at
35 * http://www-cdf.fnal.gov/offline/PostScript/psstruct.ps
36 * (Appendix G of the Red and White Book)
39 /* Note: There is a use of setmatrix in ellipse, which is supposed to be
40 * avoided. Could it be?
43 /* Note that the EPS renderer now has two phases: One to collect font
44 * info (and conceivably more, like color defs), and one to actually render.
59 #include "render_eps.h"
61 #include "diagramdata.h"
63 #include "diapsrenderer.h"
66 #include "diapsft2renderer.h"
69 static void export_eps(DiagramData
*data
, const gchar
*filename
,
70 const gchar
*diafilename
, void* user_data
);
71 static void export_render_eps(DiaPsRenderer
*renderer
,
72 DiagramData
*data
, const gchar
*filename
,
73 const gchar
*diafilename
, void* user_data
);
76 static void export_ft2_eps(DiagramData
*data
, const gchar
*filename
,
77 const gchar
*diafilename
, void* user_data
);
79 export_ft2_eps(DiagramData
*data
, const gchar
*filename
,
80 const gchar
*diafilename
, void* user_data
) {
81 export_render_eps(g_object_new (DIA_TYPE_PS_FT2_RENDERER
, NULL
),
82 data
, filename
, diafilename
, user_data
);
87 export_eps(DiagramData
*data
, const gchar
*filename
,
88 const gchar
*diafilename
, void* user_data
)
90 export_render_eps(g_object_new (DIA_TYPE_PS_RENDERER
, NULL
),
91 data
, filename
, diafilename
, user_data
);
95 export_render_eps(DiaPsRenderer
*renderer
,
96 DiagramData
*data
, const gchar
*filename
,
97 const gchar
*diafilename
, void* user_data
)
101 outfile
= fopen(filename
, "w");
102 if (outfile
== NULL
) {
103 message_error(_("Can't open output file %s: %s\n"),
104 dia_message_filename(filename
), strerror(errno
));
105 g_object_unref(renderer
);
108 renderer
->file
= outfile
;
109 renderer
->scale
= 28.346 * data
->paper
.scaling
;
110 renderer
->extent
= data
->extents
;
111 renderer
->pstype
= (guint
)user_data
;
112 if (renderer
->pstype
& PSTYPE_EPSI
) {
113 /* Must store the diagram for making a preview */
114 renderer
->diagram
= data
;
117 if (renderer
->file
) {
118 renderer
->title
= g_strdup (diafilename
);
120 data_render(data
, DIA_RENDERER(renderer
), NULL
, NULL
, NULL
);
122 g_object_unref (renderer
);
127 new_psprint_renderer(Diagram
*dia
, FILE *file
)
129 DiaPsRenderer
*renderer
;
132 renderer
= g_object_new (DIA_TYPE_PS_FT2_RENDERER
, NULL
);
134 renderer
= g_object_new (DIA_TYPE_PS_RENDERER
, NULL
);
136 renderer
->file
= file
;
137 renderer
->pstype
= PSTYPE_PS
;;
139 return DIA_RENDERER(renderer
);
142 static const gchar
*eps_extensions
[] = { "eps", NULL
};
144 static const gchar
*epsi_extensions
[] = { "epsi", NULL
};
147 DiaExportFilter eps_ft2_export_filter
= {
148 N_("Encapsulated Postscript (using Pango fonts)"),
151 GINT_TO_POINTER(PSTYPE_EPS
), /* user_data */
154 /* Disabled until we can actually make the preview. */
156 DiaExportFilter epsi_ft2_export_filter
= {
157 N_("Encapsulated Postscript with preview (using Pango fonts)"),
160 GINT_TO_POINTER(PSTYPE_EPSI
), /* user_data */
166 DiaExportFilter eps_export_filter
= {
167 N_("Encapsulated Postscript (using PostScript Latin-1 fonts)"),
170 GINT_TO_POINTER(PSTYPE_EPS
), /* user_data */
173 /* Commented out until we can actually make the preview.
174 DiaExportFilter epsi_export_filter = {
175 N_("Encapsulated Postscript with preview (using PostScript Latin-1 fonts)"),