Debian Codegraph @

contrib/perl/lib/Text/Gr2.xs

raw
1 /* SPDX-License-Identifier: Artistic-1.0-Perl
2 Copyright (C) 2011 Simon Cozens */
3 #include "EXTERN.h"
4 #include "perl.h"
5 #include "XSUB.h"
6
7 #include "ppport.h"
8
9 #include <graphite2/Font.h>
10 #include <graphite2/Segment.h>
11 #include <graphite2/Log.h>
12
13 typedef gr_face Text_Gr2_Face;
14 typedef gr_font Text_Gr2_Font;
15 typedef const gr_feature_ref Text_Gr2_FeatureRef;
16 typedef gr_feature_val Text_Gr2_FeatureVal;
17 typedef const gr_char_info Text_Gr2_CharInfo;
18 typedef gr_segment Text_Gr2_Segment;
19 typedef const gr_slot Text_Gr2_Slot;
20
21 #define gr_face_DESTROY gr_face_destroy
22 #define gr_font_DESTROY gr_font_destroy
23 #define gr_featureval_DESTROY gr_featureval_destroy
24 #define gr_seg_DESTROY gr_seg_destroy
25
26 #define gr_fref__id gr_fref_id
27
28 MODULE = Text::Gr2 PACKAGE = Text::Gr2 PREFIX = graphite_
29
30 bool gr_start_logging(SV* class, Text_Gr2_Face *face, char* logFile)
31 C_ARGS:
32 face, logFile
33
34 void gr_stop_logging(SV* class, Text_Gr2_Face *face)
35 C_ARGS:
36 face
37
38 MODULE = Text::Gr2 PACKAGE = Text::Gr2 PREFIX = gr_
39
40 gr_uint32 gr_str_to_tag(SV* class, const char *str)
41 C_ARGS:
42 str
43
44 char* gr_tag_to_str(SV* class, gr_uint32 tag)
45 PREINIT:
46 char str[5] = {0,0,0,0,0};
47 CODE:
48 gr_tag_to_str(tag,str);
49 RETVAL = str;
50 OUTPUT:
51 RETVAL
52
53 MODULE = Text::Gr2 PACKAGE = Text::Gr2::Face PREFIX = gr_
54
55 #ifndef GRAPHITE2_NFILEFACE
56 Text_Gr2_Face* gr_make_file_face(char* classname, char* filename, unsigned int options)
57 CODE:
58 RETVAL = gr_make_file_face(filename, options);
59 if (!RETVAL)
60 croak("Couldn't open file");
61 OUTPUT:
62 RETVAL
63
64 Text_Gr2_Face* gr_make_file_face_with_seg_cache(char* classname, char* filename, unsigned int segCacheMaxSize, unsigned int options)
65 CODE:
66 RETVAL = gr_make_file_face_with_seg_cache(filename, segCacheMaxSize, options);
67 if (!RETVAL)
68 croak("Couldn't open file");
69 OUTPUT:
70 RETVAL
71
72 #endif
73
74 Text_Gr2_Font* gr_make_font(Text_Gr2_Face* gr_face, float ppm)
75 C_ARGS:
76 ppm, gr_face
77
78 MODULE = Text::Gr2 PACKAGE = Text::Gr2::Face PREFIX = gr_face_
79
80 gr_uint16 gr_face_n_fref(Text_Gr2_Face* pFace)
81
82 unsigned short gr_face_n_languages(Text_Gr2_Face* pFace)
83
84 unsigned short gr_face_n_glyphs(Text_Gr2_Face* pFace)
85
86 Text_Gr2_FeatureRef* gr_face_find_fref(Text_Gr2_Face* pFace, gr_uint32 featId)
87
88 Text_Gr2_FeatureRef* gr_face_fref(Text_Gr2_Face* pFace, gr_uint32 i)
89
90 Text_Gr2_FeatureVal* gr_face_featureval_for_lang(Text_Gr2_Face* pFace, gr_uint32 langname)
91
92 gr_uint32 gr_face_lang_by_index(Text_Gr2_Face* pFace, gr_uint32 i)
93
94 void gr_face_DESTROY(Text_Gr2_Face* pFace)
95
96 MODULE = Text::Gr2 PACKAGE = Text::Gr2::Font PREFIX=gr_font_
97
98 void gr_font_DESTROY(Text_Gr2_Font* pFont)
99
100 MODULE = Text::Gr2 PACKAGE = Text::Gr2::FeatureRef PREFIX=gr_fref_
101
102 gr_uint16 gr_fref_feature_value(Text_Gr2_FeatureRef* pfeatureref, Text_Gr2_FeatureVal* feats)
103
104 int gr_fref_set_feature_value(Text_Gr2_FeatureRef* pfeatureref, Text_Gr2_FeatureVal* feats, gr_uint16 val)
105 C_ARGS:
106 pfeatureref, val, feats
107
108 gr_uint32 gr_fref__id(Text_Gr2_FeatureRef* pfeatureref)
109
110 gr_uint16 gr_fref_n_values(Text_Gr2_FeatureRef* pfeatureref)
111
112 gr_int16 gr_fref_value(Text_Gr2_FeatureRef* pfeatureref, gr_uint16 settingno)
113
114 char* gr_fref_value_label(Text_Gr2_FeatureRef* f, gr_int16 j, gr_uint16 langId, IV encoding)
115 PREINIT:
116 gr_uint32 length;
117 CODE:
118 RETVAL = gr_fref_value_label(f, j, &langId, encoding, &length);
119 OUTPUT:
120 RETVAL
121
122 char* gr_fref_label(Text_Gr2_FeatureRef* f, gr_uint16 langId, IV encoding)
123 PREINIT:
124 gr_uint32 length;
125 CODE:
126 RETVAL = gr_fref_label(f, &langId, encoding, &length);
127 OUTPUT:
128 RETVAL
129
130 MODULE = Text::Gr2 PACKAGE = Text::Gr2::FeatureVal PREFIX=gr_featureval_
131
132 Text_Gr2_FeatureVal* gr_featureval_clone(Text_Gr2_FeatureVal* pfeatures)
133
134 void gr_featureval_DESTROY(Text_Gr2_FeatureVal* pfeatures)
135
136 MODULE = Text::Gr2 PACKAGE = Text::Gr2::CharInfo PREFIX=gr_cinfo_
137
138 unsigned int gr_cinfo_unicode_char(Text_Gr2_CharInfo* p)
139
140 int gr_cinfo_break_weight(Text_Gr2_CharInfo* p)
141
142 MODULE = Text::Gr2 PACKAGE = Text::Gr2::Font PREFIX=gr_
143
144 Text_Gr2_Segment* gr_make_seg(font, face, script, pFeats, enc, string, nChars, dir)
145 Text_Gr2_Font* font
146 Text_Gr2_Face* face
147 gr_uint32 script
148 Text_Gr2_FeatureVal* pFeats
149 enum gr_encform enc
150 SV* string
151 size_t nChars
152 int dir
153 CODE:
154 RETVAL = gr_make_seg(font,face,script,pFeats,enc,(void*)SvPVX(string),nChars, dir);
155 OUTPUT:
156 RETVAL
157
158 MODULE = Text::Gr2 PACKAGE = Text::Gr2::Segment PREFIX=gr_seg_
159
160 void gr_seg_DESTROY(Text_Gr2_Segment* pSeg)
161
162 float gr_seg_advance_X(Text_Gr2_Segment* pSeg)
163
164 float gr_seg_advance_Y(Text_Gr2_Segment* pSeg)
165
166 unsigned int gr_seg_n_cinfo(Text_Gr2_Segment* pSeg)
167
168 Text_Gr2_CharInfo* gr_seg_cinfo(Text_Gr2_Segment* pSeg, unsigned int index)
169
170 Text_Gr2_Slot* gr_seg_first_slot(Text_Gr2_Segment* pSeg)
171
172 Text_Gr2_Slot* gr_seg_last_slot(Text_Gr2_Segment* pSeg)
173
174 # char_slots is tricky
175
176 MODULE = Text::Gr2 PACKAGE = Text::Gr2::Slot PREFIX=gr_slot_
177
178 Text_Gr2_Slot* gr_slot_next_in_segment(Text_Gr2_Slot* p)
179
180 Text_Gr2_Slot* gr_slot_prev_in_segment(Text_Gr2_Slot* p)
181
182 Text_Gr2_Slot* gr_slot_attached_to(Text_Gr2_Slot* p)
183
184 Text_Gr2_Slot* gr_slot_first_attachment(Text_Gr2_Slot* p)
185
186 Text_Gr2_Slot* gr_slot_next_sibling_attachment(Text_Gr2_Slot* p)
187
188 unsigned short gr_slot_gid(Text_Gr2_Slot* p)
189
190 float gr_slot_origin_X(Text_Gr2_Slot* p)
191
192 float gr_slot_origin_Y(Text_Gr2_Slot* p)
193
194 float gr_slot_advance_X(Text_Gr2_Slot* p, Text_Gr2_Face* face, Text_Gr2_Font* font)
195
196 float gr_slot_advance_Y(Text_Gr2_Slot* p, Text_Gr2_Face* face, Text_Gr2_Font* font)
197
198 int gr_slot_before(Text_Gr2_Slot* p)
199
200 int gr_slot_after(Text_Gr2_Slot* p)
201
202 int gr_slot_can_insert_before(Text_Gr2_Slot* p)
203
204 int gr_slot_original(Text_Gr2_Slot* p)
205
206 int gr_slot_attr(Text_Gr2_Slot* p, Text_Gr2_Segment* pSeg, enum gr_attrCode index, gr_uint8 subindex)