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
|
#include "fitz.h"
static void fz_tracematrix(fz_matrix *ctm)
{
printf("%g %g %g %g %g %g setmatrix\n",
ctm->a, ctm->b, ctm->c, ctm->d, ctm->e, ctm->f);
}
static void fz_tracecolor(fz_colorspace *colorspace, float *color, float alpha)
{
printf("... setcolor\n");
printf("%g setalpha\n", alpha);
}
void fz_tracefillpath(void *user, fz_path *path, fz_colorspace *colorspace, float *color, float alpha)
{
fz_tracematrix(&path->ctm);
fz_printpath(path, 0);
if (path->winding == FZ_EVENODD)
printf("eofill\n");
else
printf("fill\n");
}
void fz_tracestrokepath(void *user, fz_path *path, fz_colorspace *colorspace, float *color, float alpha)
{
int i;
fz_tracecolor(colorspace, color, alpha);
fz_tracematrix(&path->ctm);
printf("%g setlinewidth\n", path->linewidth);
printf("%g setmiterlimit\n", path->miterlimit);
printf("%d setlinecap\n", path->linecap);
printf("%d setlinejoin\n", path->linejoin);
if (path->dashlen)
{
printf("%g [ ", path->dashphase);
for (i = 0; i < path->dashlen; i++)
printf("%g ", path->dashlist[i]);
printf("] setdash\n");
}
fz_printpath(path, 0);
printf("stroke\n");
}
void fz_traceclippath(void *user, fz_path *path)
{
printf("gsave\n");
fz_tracematrix(&path->ctm);
fz_printpath(path, 0);
if (path->winding == FZ_EVENODD)
printf("eoclip\n");
else
printf("clip\n");
}
void fz_tracefilltext(void *user, fz_text *text, fz_colorspace *colorspace, float *color, float alpha)
{
printf("/%s setfont\n", text->font->name);
fz_tracematrix(&text->trm);
fz_debugtext(text, 0);
printf("show\n");
}
void fz_tracestroketext(void *user, fz_text *text, fz_colorspace *colorspace, float *color, float alpha)
{
printf("/%s setfont\n", text->font->name);
fz_tracematrix(&text->trm);
fz_debugtext(text, 0);
printf("charpath stroke\n");
}
void fz_tracecliptext(void *user, fz_text *text)
{
printf("gsave\n");
printf("/%s setfont\n", text->font->name);
fz_tracematrix(&text->trm);
fz_debugtext(text, 0);
printf("charpath clip\n");
}
void fz_traceignoretext(void *user, fz_text *text)
{
printf("/%s setfont\n", text->font->name);
fz_tracematrix(&text->trm);
fz_debugtext(text, 0);
printf("invisibletext\n");
}
void fz_tracedrawimage(void *user, fz_image *image, fz_matrix *ctm)
{
fz_tracematrix(ctm);
printf("drawimage\n");
}
void fz_tracedrawshade(void *user, fz_shade *shade, fz_matrix *ctm)
{
fz_tracematrix(ctm);
printf("drawshade\n");
}
void fz_tracepopclip(void *user)
{
printf("grestore\n");
}
fz_device *fz_newtracedevice(void)
{
fz_device *dev = fz_malloc(sizeof(fz_device));
dev->user = nil;
dev->fillpath = fz_tracefillpath;
dev->strokepath = fz_tracestrokepath;
dev->clippath = fz_traceclippath;
dev->filltext = fz_tracefilltext;
dev->stroketext = fz_tracestroketext;
dev->cliptext = fz_tracecliptext;
dev->ignoretext = fz_traceignoretext;
dev->drawimage = fz_tracedrawimage;
dev->drawshade = fz_tracedrawshade;
dev->popclip = fz_tracepopclip;
return dev;
}
|