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"), filename
, strerror(errno
));
104 g_object_unref(renderer
);
107 renderer
->file
= outfile
;
108 renderer
->scale
= 28.346 * data
->paper
.scaling
;
109 renderer
->extent
= data
->extents
;
110 renderer
->is_eps
= TRUE
;
112 if (renderer
->file
) {
113 renderer
->title
= g_strdup (diafilename
);
115 data_render(data
, DIA_RENDERER(renderer
), NULL
, NULL
, NULL
);
117 g_object_unref (renderer
);
122 new_psprint_renderer(Diagram
*dia
, FILE *file
)
124 DiaPsRenderer
*renderer
;
127 renderer
= g_object_new (DIA_TYPE_PS_FT2_RENDERER
, NULL
);
129 renderer
= g_object_new (DIA_TYPE_PS_RENDERER
, NULL
);
131 renderer
->file
= file
;
132 renderer
->is_eps
= FALSE
;
134 return DIA_RENDERER(renderer
);
137 static const gchar
*extensions
[] = { "eps", "epsi", NULL
};
139 DiaExportFilter eps_ft2_export_filter
= {
140 N_("Encapsulated Postscript (using Pango fonts)"),
148 DiaExportFilter eps_export_filter
= {
149 N_("Encapsulated Postscript (using PostScript Latin-1 fonts)"),