tioga 1.7 → 1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Tioga_README +45 -29
- data/split/Dvector/dvector.c +1 -1
- data/split/Tioga/{shared/axes.c → axes.c} +360 -36
- data/split/Tioga/figures.c +2 -1
- data/split/Tioga/figures.h +6 -2
- data/split/Tioga/generic.h +0 -1
- data/split/Tioga/lib/FigMkr.rb +3 -1
- data/split/Tioga/lib/X_and_Y_Axes.rb +74 -4
- data/split/Tioga/makers.c +1303 -0
- data/split/Tioga/{shared/pdf_font_dicts.c → pdf_font_dicts.c} +0 -0
- data/split/Tioga/{shared/pdfcolor.c → pdfcolor.c} +304 -145
- data/split/Tioga/pdfcoords.c +534 -0
- data/split/Tioga/{shared/pdffile.c → pdffile.c} +161 -56
- data/split/Tioga/{shared/pdfimage.c → pdfimage.c} +171 -74
- data/split/Tioga/{shared/pdfpath.c → pdfpath.c} +0 -0
- data/split/Tioga/{shared/pdftext.c → pdftext.c} +245 -138
- data/split/Tioga/{shared/texout.c → texout.c} +18 -9
- data/split/Tioga/wrappers.c +23 -7
- data/split/Tioga/wrappers.h +5 -3
- data/split/extconf.rb +1 -1
- metadata +25 -25
- data/split/Tioga/shared/makers.c +0 -1220
- data/split/Tioga/shared/pdfcoords.c +0 -443
File without changes
|
@@ -22,11 +22,14 @@
|
|
22
22
|
#include "figures.h"
|
23
23
|
#include "pdfs.h"
|
24
24
|
|
25
|
-
|
25
|
+
|
26
|
+
void
|
27
|
+
Init_Font_Dictionary(void)
|
28
|
+
{
|
26
29
|
int i, num_fonts = num_pdf_standard_fonts;
|
27
30
|
Font_Dictionary *font_info;
|
28
31
|
for (i = 0; i < num_fonts; i++) {
|
29
|
-
font_info = (Font_Dictionary *)calloc(1,sizeof(Font_Dictionary));
|
32
|
+
font_info = (Font_Dictionary *)calloc(1, sizeof(Font_Dictionary));
|
30
33
|
font_info->afm = &afm_array[i];
|
31
34
|
font_info->font_num = font_info->afm->font_num;
|
32
35
|
font_info->in_use = false;
|
@@ -35,34 +38,38 @@ void Init_Font_Dictionary(void) {
|
|
35
38
|
}
|
36
39
|
}
|
37
40
|
|
38
|
-
|
41
|
+
|
42
|
+
static void
|
43
|
+
Write_Font_Dictionary(FILE *file, Old_Font_Dictionary *fi)
|
44
|
+
{
|
39
45
|
int i;
|
40
46
|
fprintf(file, "{\n");
|
41
47
|
fprintf(file, "\t%i, // font_num\n", fi->font_num);
|
42
48
|
fprintf(file, "\t\"%s\", // font_name\n", fi->font_name);
|
43
49
|
fprintf(file, "\t%4i, // firstChar\n", fi->firstChar);
|
44
50
|
fprintf(file, "\t%4i, // lastChar\n", fi->lastChar);
|
45
|
-
|
51
|
+
|
46
52
|
fprintf(file, "\t{ // char_width\n");
|
47
|
-
for (i=0; i<255; i++)
|
53
|
+
for (i=0; i<255; i++)
|
54
|
+
fprintf(file, "\t\t%4i, // %i\n", fi->char_width[i], i);
|
48
55
|
fprintf(file, "\t\t%4i }, // char_width\n", fi->char_width[255]);
|
49
|
-
|
56
|
+
|
50
57
|
fprintf(file, "\t{ // char_llx\n");
|
51
58
|
for (i=0; i<255; i++) fprintf(file, "\t\t%4i, // %i\n", fi->char_llx[i], i);
|
52
59
|
fprintf(file, "\t\t%4i }, // char_llx\n", fi->char_llx[255]);
|
53
|
-
|
60
|
+
|
54
61
|
fprintf(file, "\t{ // char_lly\n");
|
55
62
|
for (i=0; i<255; i++) fprintf(file, "\t\t%4i, // %i\n", fi->char_lly[i], i);
|
56
63
|
fprintf(file, "\t\t4%i }, // char_lly\n", fi->char_lly[255]);
|
57
|
-
|
64
|
+
|
58
65
|
fprintf(file, "\t{ // char_urx\n");
|
59
66
|
for (i=0; i<255; i++) fprintf(file, "\t\t%4i, // %i\n", fi->char_urx[i], i);
|
60
67
|
fprintf(file, "\t\t%4i }, // char_urx\n", fi->char_urx[255]);
|
61
|
-
|
68
|
+
|
62
69
|
fprintf(file, "\t{ // char_ury\n");
|
63
70
|
for (i=0; i<255; i++) fprintf(file, "\t\t%4i, // %i\n", fi->char_ury[i], i);
|
64
71
|
fprintf(file, "\t\t%4i }, // char_ury\n", fi->char_ury[255]);
|
65
|
-
|
72
|
+
|
66
73
|
fprintf(file, "\t%i, // flags\n", fi->flags);
|
67
74
|
fprintf(file, "\t%i, // fnt_llx\n", fi->fnt_llx);
|
68
75
|
fprintf(file, "\t%i, // fnt_lly\n", fi->fnt_lly);
|
@@ -77,12 +84,17 @@ static void Write_Font_Dictionary(FILE *file, Old_Font_Dictionary *fi) {
|
|
77
84
|
fprintf(file, "} // %s\n", fi->font_name);
|
78
85
|
}
|
79
86
|
|
80
|
-
|
87
|
+
|
88
|
+
static void
|
89
|
+
WriteFontDictsToFile(void)
|
90
|
+
{
|
81
91
|
Old_Font_Dictionary *font_info;
|
82
92
|
FILE *file;
|
83
93
|
file = fopen("pdf_font_dicts.c", "w");
|
84
|
-
fprintf(file, "Font_Dict_Array font_dictionaries[]
|
85
|
-
|
94
|
+
fprintf(file, "Font_Dict_Array font_dictionaries[]"
|
95
|
+
" = { // afm info for PDF fonts \n");
|
96
|
+
for (font_info = old_font_dictionaries; font_info != NULL;
|
97
|
+
font_info = font_info->next) {
|
86
98
|
Write_Font_Dictionary(file, font_info);
|
87
99
|
if (font_info->next != NULL) fprintf(file, ",\n");
|
88
100
|
}
|
@@ -90,7 +102,9 @@ static void WriteFontDictsToFile(void) {
|
|
90
102
|
fclose(file);
|
91
103
|
}
|
92
104
|
|
93
|
-
|
105
|
+
|
106
|
+
static void
|
107
|
+
Record_Font_In_Use(Font_Dictionary *font_info, int font_number)
|
94
108
|
{
|
95
109
|
if (font_info->in_use) return;
|
96
110
|
font_info->afm->font_num = font_number;
|
@@ -102,11 +116,16 @@ static void Record_Font_In_Use(Font_Dictionary *font_info, int font_number)
|
|
102
116
|
}
|
103
117
|
}
|
104
118
|
|
119
|
+
|
105
120
|
#define DEBUG 0
|
106
121
|
#define MAXSTR 100
|
107
|
-
|
122
|
+
|
123
|
+
static Font_Dictionary *
|
124
|
+
GetFontDict(char *font_name, int font_number, int *ierr)
|
125
|
+
{
|
108
126
|
Font_Dictionary *font_info;
|
109
|
-
for (font_info = font_dictionaries; font_info != NULL;
|
127
|
+
for (font_info = font_dictionaries; font_info != NULL;
|
128
|
+
font_info = font_info->next) {
|
110
129
|
if (strcmp(font_name, font_info->afm->font_name) == 0) {
|
111
130
|
Record_Font_In_Use(font_info, font_number);
|
112
131
|
return font_info;
|
@@ -116,38 +135,51 @@ static Font_Dictionary *GetFontDict(char *font_name, int font_number, int *ierr)
|
|
116
135
|
return NULL;
|
117
136
|
}
|
118
137
|
|
119
|
-
|
138
|
+
|
139
|
+
static Font_Dictionary *
|
140
|
+
GetFontInfo(int font_number, int *ierr)
|
120
141
|
{
|
121
142
|
Font_Dictionary *f;
|
122
143
|
for (f = font_dictionaries; f != NULL; f = f->next) {
|
123
|
-
if (f->font_num == font_number) {
|
144
|
+
if (f->font_num == font_number) {
|
145
|
+
Record_Font_In_Use(f, font_number);
|
146
|
+
return f;
|
147
|
+
}
|
124
148
|
}
|
125
149
|
if (font_number > 0 && font_number <= num_predefined_fonts)
|
126
150
|
return GetFontDict(predefined_Fonts[font_number], font_number, ierr);
|
127
151
|
return NULL;
|
128
152
|
}
|
129
153
|
|
130
|
-
|
154
|
+
|
155
|
+
OBJ_PTR
|
156
|
+
c_register_font(OBJ_PTR fmkr, FM *p, char *font_name, int *ierr)
|
157
|
+
{
|
131
158
|
Font_Dictionary *f;
|
132
159
|
int i;
|
133
160
|
for (f = font_dictionaries; f != NULL; f = f->next) {
|
134
|
-
if (strcmp(f->afm->font_name, font_name)==0)
|
161
|
+
if (strcmp(f->afm->font_name, font_name) == 0)
|
162
|
+
return Integer_New(f->afm->font_num);
|
135
163
|
}
|
136
164
|
for (i = 1; i <= num_predefined_fonts; i++) {
|
137
165
|
if (strcmp(predefined_Fonts[i], font_name)==0) {
|
138
166
|
f = GetFontDict(font_name, i, ierr);
|
139
|
-
if (f == NULL)
|
140
|
-
|
167
|
+
if (f == NULL)
|
168
|
+
RAISE_ERROR_s("Error in reading font metrics for %s", font_name,
|
169
|
+
ierr);
|
170
|
+
return Integer_New(i);
|
141
171
|
}
|
142
172
|
}
|
143
173
|
f = GetFontDict(font_name, next_available_font_number, ierr);
|
144
|
-
if (f == NULL) RAISE_ERROR_s("Error in reading font metrics for %s",
|
174
|
+
if (f == NULL) RAISE_ERROR_s("Error in reading font metrics for %s",
|
175
|
+
font_name, ierr);
|
145
176
|
next_available_font_number++;
|
146
177
|
return Integer_New(next_available_font_number);
|
147
178
|
}
|
148
179
|
|
149
180
|
|
150
|
-
bool
|
181
|
+
bool
|
182
|
+
Used_Any_Fonts(void)
|
151
183
|
{
|
152
184
|
Font_Dictionary *f;
|
153
185
|
for (f = font_dictionaries; f != NULL; f = f->next) {
|
@@ -156,7 +188,9 @@ bool Used_Any_Fonts(void)
|
|
156
188
|
return false;
|
157
189
|
}
|
158
190
|
|
159
|
-
|
191
|
+
|
192
|
+
void
|
193
|
+
Clear_Fonts_In_Use_Flags(void)
|
160
194
|
{
|
161
195
|
Font_Dictionary *f;
|
162
196
|
for (f = font_dictionaries; f != NULL; f = f->next) {
|
@@ -164,22 +198,29 @@ void Clear_Fonts_In_Use_Flags(void)
|
|
164
198
|
}
|
165
199
|
}
|
166
200
|
|
167
|
-
|
201
|
+
|
202
|
+
void
|
203
|
+
Write_Font_Descriptors(void)
|
168
204
|
{
|
169
205
|
Font_Dictionary *f;
|
170
206
|
for (f = font_dictionaries; f != NULL; f = f->next) {
|
171
207
|
if (!f->in_use || f->font_num <= num_pdf_standard_fonts) continue;
|
172
208
|
Record_Object_Offset(f->descriptor_obj_num);
|
173
|
-
fprintf(OF, "%i 0 obj << /Type /FontDescriptor /FontName /%s\n",
|
209
|
+
fprintf(OF, "%i 0 obj << /Type /FontDescriptor /FontName /%s\n",
|
210
|
+
f->descriptor_obj_num, f->afm->font_name);
|
174
211
|
fprintf(OF, " /Flags %i /FontBBox [ %i %i %i %i ]\n",
|
175
|
-
|
176
|
-
|
177
|
-
|
212
|
+
f->afm->flags, f->afm->fnt_llx, f->afm->fnt_lly, f->afm->fnt_urx,
|
213
|
+
f->afm->fnt_ury);
|
214
|
+
fprintf(OF, " /ItalicAngle %i /Ascent %i /Descent %i "
|
215
|
+
"/CapHeight %i /StemV %i\n", f->afm->italicAngle, f->afm->ascent,
|
216
|
+
f->afm->descent, f->afm->capHeight, f->afm->stemV);
|
178
217
|
fprintf(OF, ">> endobj\n");
|
179
218
|
}
|
180
219
|
}
|
181
220
|
|
182
|
-
|
221
|
+
|
222
|
+
void
|
223
|
+
Write_Font_Widths(void)
|
183
224
|
{
|
184
225
|
Font_Dictionary *f;
|
185
226
|
int i, cnt = 0;
|
@@ -189,37 +230,49 @@ void Write_Font_Widths(void)
|
|
189
230
|
fprintf(OF, "%i 0 obj [\n ", f->widths_obj_num);
|
190
231
|
for (i = f->afm->firstChar; i <= f->afm->lastChar; i++) {
|
191
232
|
fprintf(OF, "%i ", f->afm->char_width[i]);
|
192
|
-
if (++cnt % 16 == 0)
|
233
|
+
if (++cnt % 16 == 0) fprintf(OF, "\n ");
|
193
234
|
}
|
194
235
|
fprintf(OF, "\n] endobj\n");
|
195
236
|
}
|
196
237
|
}
|
197
238
|
|
198
|
-
|
239
|
+
|
240
|
+
void
|
241
|
+
Write_Font_Dictionaries(void)
|
199
242
|
{
|
200
|
-
if (0) WriteFontDictsToFile();
|
243
|
+
if (0) WriteFontDictsToFile(); // creates pdf_font_dicts.c
|
201
244
|
Font_Dictionary *f;
|
202
245
|
for (f = font_dictionaries; f != NULL; f = f->next) {
|
203
246
|
if (!f->in_use) continue;
|
204
247
|
Record_Object_Offset(f->obj_num);
|
205
|
-
fprintf(OF, "%i 0 obj << /Type /Font /Subtype /Type1 /BaseFont /%s",
|
206
|
-
|
248
|
+
fprintf(OF, "%i 0 obj << /Type /Font /Subtype /Type1 /BaseFont /%s",
|
249
|
+
f->obj_num, f->afm->font_name);
|
250
|
+
if (strcmp(f->afm->font_name,"Symbol") != 0
|
251
|
+
&& strcmp(f->afm->font_name,"ZapfDingbats") != 0)
|
207
252
|
fprintf(OF, " /Encoding /MacRomanEncoding\n");
|
208
253
|
else
|
209
254
|
fprintf(OF, "\n");
|
210
255
|
if (f->font_num > num_pdf_standard_fonts)
|
211
|
-
fprintf(OF, " /FirstChar %i /LastChar %i /Widths %i 0 R
|
212
|
-
|
256
|
+
fprintf(OF, " /FirstChar %i /LastChar %i /Widths %i 0 R "
|
257
|
+
"/FontDescriptor %i 0 R\n", f->afm->firstChar,
|
258
|
+
f->afm->lastChar, f->widths_obj_num, f->descriptor_obj_num);
|
213
259
|
fprintf(OF, ">> endobj\n");
|
214
260
|
}
|
215
261
|
}
|
216
262
|
|
217
|
-
|
218
|
-
|
263
|
+
|
264
|
+
static void
|
265
|
+
GetStringInfo(FM *p, int font_number, unsigned char *text, double ft_ht,
|
266
|
+
double *llx_ptr, double *lly_ptr, double *urx_ptr,
|
267
|
+
double *ury_ptr, double *width_ptr, int *ierr)
|
268
|
+
{
|
219
269
|
Font_Dictionary *fontinfo = GetFontInfo(font_number, ierr);
|
220
270
|
if (*ierr != 0) return;
|
221
271
|
if (fontinfo == NULL) {
|
222
|
-
RAISE_ERROR_i("Sorry: invalid font number (%i):
|
272
|
+
RAISE_ERROR_i("Sorry: invalid font number (%i): "
|
273
|
+
"must register font before use it.", font_number, ierr);
|
274
|
+
return;
|
275
|
+
}
|
223
276
|
unsigned char *c_ptr = text, c;
|
224
277
|
double width = 0, llx, lly, urx, ury;
|
225
278
|
if (fontinfo == NULL || text == NULL || text[0] == '\0') {
|
@@ -240,89 +293,123 @@ static void GetStringInfo(FM *p, int font_number, unsigned char *text, double ft
|
|
240
293
|
*llx_ptr = ft_ht * 1e-3 * llx;
|
241
294
|
*lly_ptr = ft_ht * 1e-3 * lly;
|
242
295
|
*ury_ptr = ft_ht * 1e-3 * ury;
|
243
|
-
*urx_ptr = ft_ht * 1e-3 * (urx-70.0); // adjust for extra white
|
296
|
+
*urx_ptr = ft_ht * 1e-3 * (urx - 70.0); // adjust for extra white
|
297
|
+
// space on right
|
244
298
|
}
|
245
299
|
|
246
|
-
|
247
|
-
|
300
|
+
|
301
|
+
OBJ_PTR
|
302
|
+
c_marker_string_info(OBJ_PTR fmkr, FM *p, int fnt, unsigned char *text,
|
303
|
+
double scale, int *ierr)
|
304
|
+
{
|
305
|
+
double ft_ht = (p->default_text_scale * scale * p->default_font_size
|
306
|
+
* ENLARGE);
|
248
307
|
int ft_height = ROUND(ft_ht);
|
249
308
|
ft_ht = ft_height;
|
250
309
|
double llx, lly, urx, ury, width;
|
251
310
|
GetStringInfo(p, fnt, text, ft_ht, &llx, &lly, &urx, &ury, &width, ierr);
|
252
311
|
if (*ierr != 0) RETURN_NIL;
|
253
312
|
OBJ_PTR result = Array_New(5);
|
254
|
-
width = convert_output_to_figure_dx(p,width);
|
255
|
-
llx = convert_output_to_figure_dx(p,llx);
|
256
|
-
urx = convert_output_to_figure_dx(p,urx);
|
257
|
-
lly = convert_output_to_figure_dy(p,lly);
|
258
|
-
ury = convert_output_to_figure_dy(p,ury);
|
313
|
+
width = convert_output_to_figure_dx(p, width);
|
314
|
+
llx = convert_output_to_figure_dx(p, llx);
|
315
|
+
urx = convert_output_to_figure_dx(p, urx);
|
316
|
+
lly = convert_output_to_figure_dy(p, lly);
|
317
|
+
ury = convert_output_to_figure_dy(p, ury);
|
259
318
|
Array_Store(result, 0, Float_New(width), ierr);
|
260
319
|
Array_Store(result, 1, Float_New(llx), ierr);
|
261
320
|
Array_Store(result, 2, Float_New(lly), ierr);
|
262
321
|
Array_Store(result, 3, Float_New(urx), ierr);
|
263
322
|
Array_Store(result, 4, Float_New(ury), ierr);
|
264
|
-
|
265
|
-
return result;
|
323
|
+
return result;
|
266
324
|
}
|
267
325
|
|
326
|
+
|
268
327
|
#define TRANSFORM_VEC(dx,dy) tmp = dx; dx = (dx) * a + (dy) * c; dy = tmp * b + (dy) * d;
|
269
328
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
329
|
+
|
330
|
+
static void
|
331
|
+
c_rotated_string_at_points(OBJ_PTR fmkr, FM *p, double rotation,
|
332
|
+
int font_number, unsigned char *text, double scale,
|
333
|
+
int n, double *xs, double *ys, int alignment,
|
334
|
+
int just, double horizontal_scaling,
|
335
|
+
double vertical_scaling, double italic_angle,
|
336
|
+
double ascent_angle, int *ierr)
|
275
337
|
{
|
276
|
-
double ft_ht = p->default_text_scale * scale * p->default_font_size
|
277
|
-
|
338
|
+
double ft_ht = (p->default_text_scale * scale * p->default_font_size
|
339
|
+
* ENLARGE);
|
340
|
+
int i, ft_height = ROUND(ft_ht), justification = just - 1;
|
278
341
|
ft_ht = ft_height;
|
279
|
-
if (constructing_path) {
|
342
|
+
if (constructing_path) {
|
343
|
+
RAISE_ERROR("Sorry: must not be constructing a path when show marker",
|
344
|
+
ierr);
|
345
|
+
return;
|
346
|
+
}
|
280
347
|
double llx, lly, urx, ury, width, shiftx, shifty, tmp;
|
281
|
-
|
282
|
-
|
348
|
+
// the initial transform
|
349
|
+
double a = horizontal_scaling, b = 0.0, c = 0.0, d = vertical_scaling;
|
350
|
+
GetStringInfo(p, font_number, text, ft_ht, &llx, &lly, &urx, &ury, &width,
|
351
|
+
ierr);
|
283
352
|
if (*ierr != 0) return;
|
284
353
|
// translate according to justification and alignment
|
285
|
-
// note that we use the bbox to calculate shifts so 'center' means
|
354
|
+
// note that we use the bbox to calculate shifts so 'center' means
|
355
|
+
// center of bbox
|
286
356
|
if (italic_angle != 0) {
|
287
357
|
double skew = sin(italic_angle / RADIANS_TO_DEGREES);
|
288
|
-
c -= skew*a;
|
358
|
+
c -= skew * a;
|
359
|
+
d -= skew * b;
|
289
360
|
}
|
290
361
|
if (ascent_angle != 0) {
|
291
362
|
double skew = sin(ascent_angle / RADIANS_TO_DEGREES);
|
292
|
-
a += skew*c;
|
363
|
+
a += skew * c;
|
364
|
+
b += skew * d;
|
293
365
|
}
|
294
366
|
if (rotation != 0) {
|
295
367
|
double xa, xb, xc, xd; // new transform
|
296
|
-
double cs = cos(rotation / RADIANS_TO_DEGREES)
|
297
|
-
|
298
|
-
|
368
|
+
double cs = cos(rotation / RADIANS_TO_DEGREES);
|
369
|
+
double sn = sin(rotation / RADIANS_TO_DEGREES);
|
370
|
+
xa = cs * a + sn * c;
|
371
|
+
xb = cs * b + sn * d;
|
372
|
+
xc = -sn * a + cs * c;
|
373
|
+
xd = -sn * b + cs * d;
|
374
|
+
a = xa;
|
375
|
+
b = xb;
|
376
|
+
c = xc;
|
377
|
+
d = xd;
|
299
378
|
}
|
300
379
|
switch (justification) {
|
301
|
-
case LEFT_JUSTIFIED:
|
302
|
-
|
380
|
+
case LEFT_JUSTIFIED:
|
381
|
+
shiftx = 0; break;
|
382
|
+
case CENTERED: // CENTERED for marker means centered on BBOX
|
383
|
+
shiftx = -(urx + llx) / 2;
|
384
|
+
break;
|
303
385
|
case RIGHT_JUSTIFIED:
|
304
386
|
shiftx = -width;
|
305
|
-
// the following hack compensates for Arrowhead bbox in
|
306
|
-
// needed to make tip of arrowhead fall on the
|
307
|
-
|
387
|
+
// the following hack compensates for Arrowhead bbox in
|
388
|
+
// ZaphDingbats needed to make tip of arrowhead fall on the
|
389
|
+
// reference point correctly
|
390
|
+
if (font_number == 14 && strlen((char *)text) == 1
|
391
|
+
&& text[0] == 0344) {
|
308
392
|
shiftx *= 0.9;
|
309
393
|
}
|
310
394
|
break;
|
311
395
|
default:
|
312
|
-
RAISE_ERROR_i("Sorry: invalid setting for marker justification (%i)",
|
396
|
+
RAISE_ERROR_i("Sorry: invalid setting for marker justification (%i)",
|
397
|
+
justification, ierr);
|
313
398
|
return;
|
314
399
|
}
|
315
400
|
switch (alignment) {
|
316
401
|
case ALIGNED_AT_TOP: shifty = -ury; break;
|
317
|
-
case ALIGNED_AT_MIDHEIGHT: shifty = -(ury+lly)/2; break;
|
402
|
+
case ALIGNED_AT_MIDHEIGHT: shifty = -(ury + lly)/2; break;
|
318
403
|
case ALIGNED_AT_BASELINE: shifty = 0; break;
|
319
404
|
case ALIGNED_AT_BOTTOM: shifty = -lly; break;
|
320
405
|
default:
|
321
|
-
RAISE_ERROR_i("Sorry: invalid setting for marker alignment (%i)",
|
406
|
+
RAISE_ERROR_i("Sorry: invalid setting for marker alignment (%i)",
|
407
|
+
alignment, ierr);
|
322
408
|
return;
|
323
409
|
}
|
324
410
|
// transform the bbox
|
325
|
-
|
411
|
+
// if we're rotated we'll need all 4 corners of bbox
|
412
|
+
double llx2 = llx, lly2 = lly, urx2 = urx, ury2 = ury;
|
326
413
|
TRANSFORM_VEC(llx, lly)
|
327
414
|
TRANSFORM_VEC(urx, ury)
|
328
415
|
TRANSFORM_VEC(llx2, ury2)
|
@@ -330,22 +417,21 @@ static void c_rotated_string_at_points(
|
|
330
417
|
TRANSFORM_VEC(shiftx, shifty)
|
331
418
|
fprintf(TF, "BT /F%i %i Tf\n", font_number, ft_height);
|
332
419
|
if (0 && horizontal_scaling != 1.0) {
|
333
|
-
fprintf(TF, "%d Tz\n", ROUND(100*ABS(horizontal_scaling)));
|
420
|
+
fprintf(TF, "%d Tz\n", ROUND(100 * ABS(horizontal_scaling)));
|
334
421
|
}
|
335
|
-
double x, y, prev_x=0, prev_y=0, dx, dy;
|
336
|
-
int idx, idy;
|
422
|
+
double x, y, prev_x = 0, prev_y = 0, dx, dy;
|
423
|
+
//int idx, idy;
|
337
424
|
for (i = 0; i < n; i++) {
|
338
425
|
unsigned char *cp = text, char_code;
|
339
|
-
x = convert_figure_to_output_x(p,xs[i]) + shiftx;
|
340
|
-
y = convert_figure_to_output_y(p,ys[i]) + shifty;
|
341
|
-
if(!is_okay_number(x) || !
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
update_bbox(p,x+
|
346
|
-
update_bbox(p,x+
|
347
|
-
update_bbox(p,x+
|
348
|
-
update_bbox(p,x+urx2, y+lly2);
|
426
|
+
x = convert_figure_to_output_x(p, xs[i]) + shiftx;
|
427
|
+
y = convert_figure_to_output_y(p, ys[i]) + shifty;
|
428
|
+
if(!is_okay_number(x) || !is_okay_number(y))
|
429
|
+
continue; // we forget this point if at least one coordinate
|
430
|
+
// is not 'real'
|
431
|
+
update_bbox(p, x + llx, y + lly);
|
432
|
+
update_bbox(p, x + urx, y + ury);
|
433
|
+
update_bbox(p, x + llx2, y + ury2);
|
434
|
+
update_bbox(p, x + urx2, y + lly2);
|
349
435
|
dx = x - prev_x; dy = y - prev_y;
|
350
436
|
//idx = ROUND(dx); idy = ROUND(dy);
|
351
437
|
//prev_x = prev_x + idx; prev_y = prev_y + idy;
|
@@ -353,8 +439,10 @@ static void c_rotated_string_at_points(
|
|
353
439
|
if (b == 0 && c == 0 && a == 1 && d == 1) {
|
354
440
|
//fprintf(TF, "%i %i Td (", idx, idy);
|
355
441
|
fprintf(TF, "%0.6f %0.6f Td (", dx, dy);
|
356
|
-
}
|
357
|
-
|
442
|
+
}
|
443
|
+
else { // need high precision when doing rotations
|
444
|
+
fprintf(TF, "%0.6f %0.6f %0.6f %0.6f %0.6f %0.6f Tm (",
|
445
|
+
a, b, c, d, x, y);
|
358
446
|
}
|
359
447
|
while ((char_code = *cp++) != '\0') {
|
360
448
|
if (char_code == '\\')
|
@@ -369,19 +457,25 @@ static void c_rotated_string_at_points(
|
|
369
457
|
fprintf(TF, "ET\n");
|
370
458
|
}
|
371
459
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
460
|
+
|
461
|
+
void
|
462
|
+
c_private_show_marker(OBJ_PTR fmkr, FM *p, int int_args,
|
463
|
+
OBJ_PTR stroke_width, OBJ_PTR string,
|
464
|
+
OBJ_PTR x, OBJ_PTR y, OBJ_PTR x_vec, OBJ_PTR y_vec,
|
465
|
+
double h_scale, double v_scale, double scale,
|
466
|
+
double it_angle, double ascent_angle, double angle,
|
467
|
+
OBJ_PTR fill_color, OBJ_PTR stroke_color, int *ierr)
|
468
|
+
{
|
377
469
|
int c, alignment, justification, fnt_num, n, mode;
|
378
470
|
unsigned char *text = NULL, buff[2];
|
379
471
|
double *xs, *ys, xloc, yloc, prev_line_width = -1;
|
380
472
|
bool restore_fill_color = false, restore_stroke_color = false;
|
381
|
-
double stroke_color_R=0.0, stroke_color_G=0.0, stroke_color_B=0.0;
|
382
|
-
double prev_stroke_color_R, prev_stroke_color_G,
|
383
|
-
|
384
|
-
double
|
473
|
+
double stroke_color_R = 0.0, stroke_color_G = 0.0, stroke_color_B = 0.0;
|
474
|
+
double prev_stroke_color_R = 0.0, prev_stroke_color_G = 0.0,
|
475
|
+
prev_stroke_color_B = 0.0;
|
476
|
+
double fill_color_R = 0.0, fill_color_G = 0.0, fill_color_B = 0.0;
|
477
|
+
double prev_fill_color_R = 0.0, prev_fill_color_G = 0.0,
|
478
|
+
prev_fill_color_B = 0.0;
|
385
479
|
c = int_args / 100000; int_args -= c * 100000;
|
386
480
|
fnt_num = int_args / 1000; int_args -= fnt_num * 1000;
|
387
481
|
mode = int_args / 100; int_args -= mode * 100;
|
@@ -389,52 +483,58 @@ void c_private_show_marker(
|
|
389
483
|
justification = int_args;
|
390
484
|
if (string == OBJ_NIL) {
|
391
485
|
if (c < 0 || c > 255) {
|
392
|
-
RAISE_ERROR_i("Sorry: invalid character code (%i) :
|
486
|
+
RAISE_ERROR_i("Sorry: invalid character code (%i) : "
|
487
|
+
"must be between 0 and 255", c, ierr);
|
393
488
|
return;
|
394
489
|
}
|
395
|
-
text = buff; text[0] = c;
|
490
|
+
text = buff; text[0] = c; text[1] = '\0';
|
396
491
|
if (stroke_width != OBJ_NIL) {
|
397
492
|
double width = Number_to_double(stroke_width, ierr);
|
398
493
|
if (*ierr != 0) return;
|
399
494
|
prev_line_width = p->line_width; // restore it later
|
400
495
|
fprintf(TF, "%0.6f w\n", width * ENLARGE);
|
401
496
|
}
|
402
|
-
}
|
403
|
-
|
497
|
+
}
|
498
|
+
else {
|
499
|
+
text = (unsigned char *)(String_Ptr(string, ierr));
|
404
500
|
if (*ierr != 0) return;
|
405
501
|
}
|
406
502
|
fprintf(TF, "%d Tr\n", mode);
|
407
503
|
if (stroke_color != OBJ_NIL &&
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
504
|
+
(mode == STROKE || mode == FILL_AND_STROKE
|
505
|
+
|| mode == STROKE_AND_CLIP || mode == FILL_STROKE_AND_CLIP)) {
|
506
|
+
Unpack_RGB(stroke_color, &stroke_color_R, &stroke_color_G,
|
507
|
+
&stroke_color_B, ierr);
|
508
|
+
if (*ierr != 0) return;
|
509
|
+
if (stroke_color_R != p->stroke_color_R
|
510
|
+
|| stroke_color_G != p->stroke_color_G
|
511
|
+
|| stroke_color_B != p->stroke_color_B) {
|
512
|
+
prev_stroke_color_R = p->stroke_color_R;
|
513
|
+
prev_stroke_color_G = p->stroke_color_G;
|
514
|
+
prev_stroke_color_B = p->stroke_color_B;
|
515
|
+
restore_stroke_color = true;
|
516
|
+
c_stroke_color_set_RGB(fmkr, p, stroke_color_R, stroke_color_G,
|
517
|
+
stroke_color_B, ierr);
|
518
|
+
if (*ierr != 0) return;
|
519
|
+
}
|
422
520
|
}
|
423
521
|
if (fill_color != OBJ_NIL &&
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
522
|
+
(mode == FILL || mode == FILL_AND_STROKE
|
523
|
+
|| mode == FILL_AND_CLIP || mode == FILL_STROKE_AND_CLIP)) {
|
524
|
+
Unpack_RGB(fill_color, &fill_color_R, &fill_color_G, &fill_color_B,
|
525
|
+
ierr);
|
526
|
+
if (*ierr != 0) return;
|
527
|
+
if (fill_color_R != p->fill_color_R
|
528
|
+
|| fill_color_G != p->fill_color_G
|
529
|
+
|| fill_color_B != p->fill_color_B) {
|
530
|
+
prev_fill_color_R = p->fill_color_R;
|
531
|
+
prev_fill_color_G = p->fill_color_G;
|
532
|
+
prev_fill_color_B = p->fill_color_B;
|
533
|
+
restore_fill_color = true;
|
534
|
+
c_fill_color_set_RGB(fmkr, p, fill_color_R, fill_color_G,
|
535
|
+
fill_color_B, ierr);
|
536
|
+
if (*ierr != 0) return;
|
537
|
+
}
|
438
538
|
}
|
439
539
|
if (x == OBJ_NIL) {
|
440
540
|
long xlen, ylen;
|
@@ -443,20 +543,27 @@ void c_private_show_marker(
|
|
443
543
|
ys = Vector_Data_for_Read(y_vec, &ylen, ierr);
|
444
544
|
if (*ierr != 0) return;
|
445
545
|
if (xlen != ylen) {
|
446
|
-
RAISE_ERROR("Sorry: must have same number xs and ys
|
546
|
+
RAISE_ERROR("Sorry: must have same number xs and ys "
|
547
|
+
"for showing markers", ierr);
|
548
|
+
return;
|
549
|
+
}
|
447
550
|
if (xlen <= 0) return;
|
448
551
|
n = xlen;
|
449
|
-
}
|
552
|
+
}
|
553
|
+
else {
|
450
554
|
xloc = Number_to_double(x, ierr); xs = &xloc;
|
451
555
|
yloc = Number_to_double(y, ierr); ys = &yloc;
|
452
556
|
if (*ierr != 0) return;
|
453
557
|
n = 1;
|
454
558
|
}
|
455
559
|
c_rotated_string_at_points(fmkr, p, angle, fnt_num, text, scale, n, xs, ys,
|
456
|
-
|
560
|
+
alignment, justification, h_scale, v_scale,
|
561
|
+
it_angle, ascent_angle, ierr);
|
457
562
|
if (prev_line_width >= 0) c_line_width_set(fmkr, p, prev_line_width, ierr);
|
458
563
|
if (restore_fill_color)
|
459
|
-
|
460
|
-
|
461
|
-
|
564
|
+
c_fill_color_set_RGB(fmkr, p, prev_fill_color_R, prev_fill_color_G,
|
565
|
+
prev_fill_color_B, ierr);
|
566
|
+
if (restore_stroke_color)
|
567
|
+
c_stroke_color_set_RGB(fmkr, p, prev_stroke_color_R, prev_stroke_color_G,
|
568
|
+
prev_stroke_color_B, ierr);
|
462
569
|
}
|