[rt #75878] pass --verbose through to Imager::Probe in sub-modules
[imager.git] / T1 / T1.xs
CommitLineData
a556912d
TC
1#define PERL_NO_GET_CONTEXT
2#ifdef __cplusplus
3extern "C" {
4#endif
5#include "EXTERN.h"
6#include "perl.h"
7#include "XSUB.h"
8#include "imext.h"
9#include "imperl.h"
10#include "imt1.h"
11
12DEFINE_IMAGER_CALLBACKS;
13
14MODULE = Imager::Font::T1 PACKAGE = Imager::Font::T1
15
16undef_int
17i_init_t1(t1log)
18 int t1log
19
d03fd5a4
TC
20void
21i_t1_set_aa(st)
22 int st
a556912d 23
d03fd5a4
TC
24int
25i_t1_new(pfb,afm)
a556912d
TC
26 char* pfb
27 char* afm
28
d03fd5a4
TC
29int
30i_t1_destroy(font_id)
31 int font_id
a556912d
TC
32
33
34undef_int
d03fd5a4 35i_t1_cp(im,xb,yb,channel,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
a556912d 36 Imager::ImgRaw im
8d14daab
TC
37 i_img_dim xb
38 i_img_dim yb
a556912d 39 int channel
d03fd5a4 40 int fontnum
8d14daab 41 double points
a556912d
TC
42 SV* str_sv
43 int align
44 int utf8
45 char* flags
46 PREINIT:
47 char *str;
48 STRLEN len;
49 CODE:
50#ifdef SvUTF8
51 if (SvUTF8(str_sv))
52 utf8 = 1;
53#endif
54 str = SvPV(str_sv, len);
d03fd5a4
TC
55 RETVAL = i_t1_cp(im, xb,yb,channel,fontnum,points,str,len,align,
56 utf8,flags);
a556912d
TC
57 OUTPUT:
58 RETVAL
59
60
61void
62i_t1_bbox(fontnum,point,str_sv,len_ignored,utf8=0,flags="")
d03fd5a4 63 int fontnum
8d14daab 64 double point
a556912d
TC
65 SV* str_sv
66 int utf8
67 char* flags
68 PREINIT:
69 char *str;
70 STRLEN len;
8d14daab 71 i_img_dim cords[BOUNDING_BOX_COUNT];
a556912d
TC
72 int i;
73 int rc;
74 PPCODE:
75#ifdef SvUTF8
76 if (SvUTF8(str_sv))
77 utf8 = 1;
78#endif
79 str = SvPV(str_sv, len);
80 rc = i_t1_bbox(fontnum,point,str,len,cords,utf8,flags);
81 if (rc > 0) {
82 EXTEND(SP, rc);
83 for (i = 0; i < rc; ++i)
84 PUSHs(sv_2mortal(newSViv(cords[i])));
85 }
86
87
88
89undef_int
d03fd5a4 90i_t1_text(im,xb,yb,cl,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
a556912d 91 Imager::ImgRaw im
8d14daab
TC
92 i_img_dim xb
93 i_img_dim yb
a556912d 94 Imager::Color cl
d03fd5a4 95 int fontnum
8d14daab 96 double points
a556912d
TC
97 SV* str_sv
98 int align
99 int utf8
d03fd5a4 100 char* flags
a556912d
TC
101 PREINIT:
102 char *str;
103 STRLEN len;
104 CODE:
105#ifdef SvUTF8
106 if (SvUTF8(str_sv))
107 utf8 = 1;
108#endif
109 str = SvPV(str_sv, len);
d03fd5a4
TC
110 RETVAL = i_t1_text(im, xb,yb,cl,fontnum,points,str,len,align,
111 utf8,flags);
a556912d
TC
112 OUTPUT:
113 RETVAL
114
115void
d03fd5a4
TC
116i_t1_has_chars(handle, text_sv, utf8 = 0)
117 int handle
a556912d
TC
118 SV *text_sv
119 int utf8
120 PREINIT:
121 char const *text;
122 STRLEN len;
123 char *work;
124 int count;
125 int i;
126 PPCODE:
127#ifdef SvUTF8
128 if (SvUTF8(text_sv))
129 utf8 = 1;
130#endif
131 text = SvPV(text_sv, len);
132 work = mymalloc(len);
d03fd5a4 133 count = i_t1_has_chars(handle, text, len, utf8, work);
a556912d
TC
134 if (GIMME_V == G_ARRAY) {
135 EXTEND(SP, count);
136 for (i = 0; i < count; ++i) {
6e938c74 137 PUSHs(boolSV(work[i]));
a556912d
TC
138 }
139 }
140 else {
141 EXTEND(SP, 1);
142 PUSHs(sv_2mortal(newSVpv(work, count)));
143 }
144 myfree(work);
145
146void
d03fd5a4
TC
147i_t1_face_name(handle)
148 int handle
a556912d
TC
149 PREINIT:
150 char name[255];
151 int len;
152 PPCODE:
d03fd5a4 153 len = i_t1_face_name(handle, name, sizeof(name));
a556912d
TC
154 if (len) {
155 EXTEND(SP, 1);
156 PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
157 }
158
159void
d03fd5a4
TC
160i_t1_glyph_name(handle, text_sv, utf8 = 0)
161 int handle
a556912d
TC
162 SV *text_sv
163 int utf8
164 PREINIT:
165 char const *text;
166 STRLEN work_len;
167 size_t len;
168 char name[255];
169 PPCODE:
170#ifdef SvUTF8
171 if (SvUTF8(text_sv))
172 utf8 = 1;
173#endif
174 text = SvPV(text_sv, work_len);
175 len = work_len;
176 while (len) {
177 unsigned long ch;
178 if (utf8) {
179 ch = i_utf8_advance(&text, &len);
180 if (ch == ~0UL) {
181 i_push_error(0, "invalid UTF8 character");
182 break;
183 }
184 }
185 else {
186 ch = *text++;
187 --len;
188 }
189 EXTEND(SP, 1);
d03fd5a4 190 if (i_t1_glyph_name(handle, ch, name, sizeof(name))) {
a556912d
TC
191 PUSHs(sv_2mortal(newSVpv(name, 0)));
192 }
193 else {
194 PUSHs(&PL_sv_undef);
195 }
196 }
197
198BOOT:
199 PERL_INITIALIZE_IMAGER_CALLBACKS;