summaryrefslogtreecommitdiff
path: root/support/dktools/fig2lat.h
blob: 7a0ecd9113be68736c84ce1faa329e54c737079f (plain)
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
	WARNING: This file was generated by dkct.
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: fig2lat.ctr
*/

/*
Copyright (C) 2012-2017, Dirk Krause

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above opyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used
  to endorse or promote products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**	@file fig2lat.h Header file for the fig2lat module.
*/

#ifndef FIG2LAT_H_INCLUDED
/** Avoid multiple inclusions. */
#define FIG2LAT_H_INCLUDED 1


#line 10 "fig2lat.ctr"

#include "dk3fig.h"
#include "dk3figrd.h"
#include "dk3figpr.h"


/**	To draw a quadrant of a circle we do not use 1/3 of the
	derivative, we use another factor instead.
*/
#define	FIG2LAT_CIRCLE_QUADRANT_BEZIER	0.5522847498307932



/**	Conversion configuration.
*/
typedef struct {
  double	nts;	/**< Normal text size (scale factor or -1.0). */
  int		ntf;	/**< Normal text font (0=similar, 1=fig). */
} fig2lat_config_t;



/**	How to handle a text.
*/
typedef struct {
  double	fontSize;	/**< Font size in pt. */
  unsigned long	fontNumber;	/**< Unique font number for LaTeX output. */
  int		psFontNo;	/**< PS font number. */
} f2l_text_handling_t;



/**	Image structure.
*/
typedef struct {
  dk3_ufi_t	 	 ufi;		/**< Unique file identifier image. */
  char const		*filename;	/**< Image file name. */
  dk3_pdf_xobject_t	*xo;		/**< PDF X object. */
  dk3_bif_coord_t	 width;		/**< Image width. */
  dk3_bif_coord_t	 height;	/**< Image height. */
  double		 xres;		/**< X resolution. */
  double		 yres;		/**< Y resolution. */
  unsigned long		 imageNumber;	/**< Unique number of image. */
  unsigned long		 lineno;	/**< Line number of object. */
} f2l_image_t;



/**	Fig2lat job structure.
*/
typedef struct {
  /*	@DRIVER@
  	You can add driver-specific configuration compomenents here.
	For alignment reasons the order of elements is in decreasing
	type size.
	Remember to re-compile all modules after changing data types.
	Initialize the new components in fig2lat_job_init(),
	release allocated resources in fig2lat_job_end().
  */
  dk3_graphics_state_t	 gs;		/**< Graphics state. */
  dk3_ct_2d_t		 ct2d;		/**< Coordinates transformation data. */
  dk3_fig_drawing_t	*drw;		/**< Fig drawing to convert. */
  dk3_app_t		*app;		/**< Application structure. */
  dk3_option_set_t	*opt;		/**< Options and cmd arguments. */
  FILE			*of1;		/**< Output file 1. */
  FILE			*of2;		/**< Output file 2. */
  dkChar const		*on1;		/**< Output file name 1. */
  dkChar const		*on2;		/**< Output file name 2. */
  dkChar const * const	*msg;		/**< Localized text messages. */
  dkChar const * const	*figmsg;	/**< Localized messages dk3fig mod. */
  double		 width;		/**< Width (typically in bp). */
  double		 height;	/**< Height (typically in bp). */
  double		 w2;		/**< Secondary width information. */
  double		 h2;		/**< Secondary height information. */
  double		 nts;		/**< Normal text size. */
  double		 tts;		/**< TeX text size. */
  double		 arcspp;	/**< Spline points per arc. */
  double		 splspp;	/**< Spline points per interval. */
  double		 xsprec;	/**< Iteration precision. */
  double		 lwbp;		/**< Line width in bp. */
  long			 lwidth;	/**< Width in bp. */
  long			 lheight;	/**< Height in bp. */
  size_t		 xssbs;		/**< X-spline segement Bezier segs. */
  size_t		 minspp;	/**< Minimum spline points. */
  size_t		 qbs;		/**< Quadrant Bezier segments. */
  size_t		 codi;		/**< Color digits. */
  int			 ntf;		/**< Text font (0=similar, 1=fig). */
  int			 dr;		/**< Driver, see @ref fig2latdrivers. */
  int			 exval;		/**< Exit, see @ref fig2latexitcodes. */
  int			 mm;		/**< Flag: Make mode. */
  int			 cmd;		/**< Command to execute. */
  int			 cosp;		/**< Flag: Spline compatibility. */
  int			 coah;		/**< Flag: Arrowhead compatibility. */
  int			 xsah;		/**< Flag: X-spline arrowhead. */
  int			 debug;		/**< Flag: Write debug information. */
  int			 showpage;	/**< Flag: Write showpage operator. */
  int			 pslevel;	/**< PS language level. */
  int			 dsc;		/**< Flag: Write PS DSC. */
  int			 srctype;	/**< Source file type. */
  int			 smash;		/**< Flag: Use smash instruction. */
  int			 mbox;		/**< Flag: Use mbox instruction. */
  int			 resfont;	/**< Flag: Use reset@font. */
  int			 css;		/**< Flag: CSS-styled SVG. */
  int			 fragment;	/**< Flag: Write SVG fragment only. */
  int			 svgfontbase;	/**< SVG font base: 0=none, 1=local, 2=web. */
  int			 group;		/**< Flag: Group SVG object with ahs. */
  int			 miterlim;	/**< Flag: Write miterlimit. */
  int			 cols;		/**< Flag: Compatible line styles. */
  int			 otherfonts;	/**< Flag: Use additional fonts SVG. */
  int			 bbts;		/**< Flag: Use text size for bb. */
  int			 stu8;		/**< Flag: Special text uses UTF-8. */
  int			 cofop;		/**< Flag: Compat fill open paths. */
  int			 lwauto;	/**< Flag: Automatic line width. */
} f2l_job_t;



/**	@defgroup	fig2latexitcodes	Exit codes for fig2lat.
*/
/**@{*/

/**	Program succeeded.
*/
#define	FIG2LAT_EXIT_SUCCESS		0

/**	Error occured, no detailed description.
*/
#define	FIG2LAT_EXIT_ERROR_UNKNOWN	1

/**	Error, no file found to convert.
*/
#define FIG2LAT_EXIT_ERROR_NO_SUCH_FILE	2

/**	File name is too long for processing.
*/
#define	FIG2LAT_EXIT_FILENAME_TOO_LONG	3

/**	Resources problem or system error.
*/
#define	FIG2LAT_EXIT_ERROR_SYSTEM	4

/**	Mathematical error.
*/
#define	FIG2LAT_EXIT_ERROR_MATH		5

/**	Syntax error in input file.
*/
#define	FIG2LAT_EXIT_ERROR_SYNTAX	6
/**@}*/



/**	@defgroup	fig2latdrivers		Fig2lat output drivers.
*/

/**@{*/

/**	Produce PGF output file (default driver).
*/
#define	FIG2LAT_DRIVER_PGF		0

/**	Produce full *.tex file, image as embedded PGF.
*/
#define	FIG2LAT_DRIVER_TEX_FULL_PGF	1

/**	Produce full *.tex file, image as included external PDF.
*/
#define	FIG2LAT_DRIVER_TEX_FULL_PDF	2

/**	Produce *.tex file including an external EPS.
*/
#define	FIG2LAT_DRIVER_EPS_WITH_TEX	3

/**	Produce *.tex file including an external PDF.
*/
#define	FIG2LAT_DRIVER_PDF_WITH_TEX	4

/**	Produce standalone EPS file.
*/
#define	FIG2LAT_DRIVER_EPS_STANDALONE	5

/**	Produce standalone SVG file.
*/
#define	FIG2LAT_DRIVER_SVG_STANDALONE	6

/*	@DRIVER@
	Add new driver numbers above this comment.
	The driver numbers must correspond to the order of
	driver names in f2lopt.ctr in the f2lopt_language_names array.
*/

/**@}*/



#include "f2lopt.h"
#include "f2lto.h"


#endif