1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
/* Dia -- an diagram creation/manipulation program
* Copyright (C) 1998 Alexander Larsson
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* The eps_dump_truetype_body function and much inspiration for font dumping
* came from ttfps, which bears the following license notice:
Copyright (c) 1997 by Juliusz Chroboczek
Copying
*******
This software is provided with no guarantee, not even of any kind.
Feel free to do whatever you wish with it as long as you don't ask me
to maintain it.
*/
/* The Document Structure Definitions used for the output is available at
* http://www-cdf.fnal.gov/offline/PostScript/psstruct.ps
* (Appendix G of the Red and White Book)
*/
/* Note: There is a use of setmatrix in ellipse, which is supposed to be
* avoided. Could it be?
*/
/* Note that the EPS renderer now has two phases: One to collect font
* info (and conceivably more, like color defs), and one to actually render.
*/
#include <config.h>
#include <string.h>
#include <time.h>
#include <math.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <locale.h>
#include <errno.h>
#include "intl.h"
#include "render_eps.h"
#include "message.h"
#include "diagramdata.h"
#include "font.h"
#include "diapsrenderer.h"
#ifdef HAVE_FREETYPE
#include "diapsft2renderer.h"
#endif
static void export_eps(DiagramData *data, const gchar *filename,
const gchar *diafilename, void* user_data);
static void export_render_eps(DiaPsRenderer *renderer,
DiagramData *data, const gchar *filename,
const gchar *diafilename, void* user_data);
#ifdef HAVE_FREETYPE
static void export_ft2_eps(DiagramData *data, const gchar *filename,
const gchar *diafilename, void* user_data);
static void
export_ft2_eps(DiagramData *data, const gchar *filename,
const gchar *diafilename, void* user_data) {
export_render_eps(g_object_new (DIA_TYPE_PS_FT2_RENDERER, NULL),
data, filename, diafilename, user_data);
}
#endif
static void
export_eps(DiagramData *data, const gchar *filename,
const gchar *diafilename, void* user_data)
{
export_render_eps(g_object_new (DIA_TYPE_PS_RENDERER, NULL),
data, filename, diafilename, user_data);
}
static void
export_render_eps(DiaPsRenderer *renderer,
DiagramData *data, const gchar *filename,
const gchar *diafilename, void* user_data)
{
FILE *outfile;
outfile = fopen(filename, "w");
if (outfile == NULL) {
message_error(_("Can't open output file %s: %s\n"), filename, strerror(errno));
g_object_unref(renderer);
return;
}
renderer->file = outfile;
renderer->scale = 28.346 * data->paper.scaling;
renderer->extent = data->extents;
renderer->pstype = (guint)user_data;
if (renderer->pstype & PSTYPE_EPSI) {
/* Must store the diagram for making a preview */
renderer->diagram = data;
}
if (renderer->file) {
renderer->title = g_strdup (diafilename);
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
}
g_object_unref (renderer);
fclose(outfile);
}
DiaRenderer *
new_psprint_renderer(Diagram *dia, FILE *file)
{
DiaPsRenderer *renderer;
#ifdef HAVE_FREETYPE
renderer = g_object_new (DIA_TYPE_PS_FT2_RENDERER, NULL);
#else
renderer = g_object_new (DIA_TYPE_PS_RENDERER, NULL);
#endif
renderer->file = file;
renderer->pstype = PSTYPE_PS;;
return DIA_RENDERER(renderer);
}
static const gchar *eps_extensions[] = { "eps", NULL };
static const gchar *epsi_extensions[] = { "epsi", NULL };
#ifdef HAVE_FREETYPE
DiaExportFilter eps_ft2_export_filter = {
N_("Encapsulated Postscript (using Pango fonts)"),
eps_extensions,
export_ft2_eps,
GINT_TO_POINTER(PSTYPE_EPS), /* user_data */
"eps-pango"
};
/* Disabled until we can actually make the preview. */
# if 0
DiaExportFilter epsi_ft2_export_filter = {
N_("Encapsulated Postscript with preview (using Pango fonts)"),
epsi_extensions,
export_ft2_eps,
GINT_TO_POINTER(PSTYPE_EPSI), /* user_data */
"epsi-pango"
};
# endif
#endif
DiaExportFilter eps_export_filter = {
N_("Encapsulated Postscript (using PostScript Latin-1 fonts)"),
eps_extensions,
export_eps,
GINT_TO_POINTER(PSTYPE_EPS), /* user_data */
"eps-builtin"
};
/* Commented out until we can actually make the preview.
DiaExportFilter epsi_export_filter = {
N_("Encapsulated Postscript with preview (using PostScript Latin-1 fonts)"),
epsi_extensions,
export_eps,
PSTYPE_EPSI,
"epsi-builtin"
};
*/
|