Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 580 lines (479 sloc) 22.533 kb
91f837e @mgdm Add some functions, start on layouts
authored
1 /*
c132525 @mgdm Minor spacing fix before applying patch
authored
2 +----------------------------------------------------------------------+
3 | PHP Version 5 |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1997-2008 The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Author: Michael Maclean <mgdm@php.net> |
16 +----------------------------------------------------------------------+
17 */
91f837e @mgdm Add some functions, start on layouts
authored
18
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23 #include "php.h"
24 #include "php_pango.h"
25
2accdcb Fix various compiler warnings
Michael Maclean authored
26 #include "zend_exceptions.h"
27
8fa8b81 @mgdm Add more font handling and layout methods
authored
28 zend_class_entry *pango_ce_pangofontdescription;
91f837e @mgdm Add some functions, start on layouts
authored
29 zend_class_entry *pango_ce_pangostyle;
30 zend_class_entry *pango_ce_pangoweight;
31 zend_class_entry *pango_ce_pangovariant;
32 zend_class_entry *pango_ce_pangostretch;
33 zend_class_entry *pango_ce_pangofontmask;
34
8fa8b81 @mgdm Add more font handling and layout methods
authored
35 /* {{{ proto PangoFontDescription::__construct(string description)
a593859 @davefx Add new PangoFontDescription methods from David Marín
davefx authored
36 Creates a new font description object. This merges pango_font_description_new
8fa8b81 @mgdm Add more font handling and layout methods
authored
37 and pango_font_description_from_string. */
38 PHP_METHOD(PangoFontDescription, __construct)
39 {
40 pango_fontdesc_object *fontdesc_object = NULL;
41 const char *text;
42 long text_len = -1;
43
44 PHP_PANGO_ERROR_HANDLING(TRUE)
45 if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &text, &text_len) == FAILURE)
46 {
47 PHP_PANGO_RESTORE_ERRORS(TRUE)
48 return;
49 }
0e42a88 @mgdm Restore error handling every time it is reset
authored
50 PHP_PANGO_RESTORE_ERRORS(TRUE)
8fa8b81 @mgdm Add more font handling and layout methods
authored
51
52 if(text_len) {
53 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
54 fontdesc_object->fontdesc = pango_font_description_from_string(text);
55 } else {
56 fontdesc_object->fontdesc = pango_font_description_new();
57 }
58
59 if(!fontdesc_object->fontdesc) {
60 zend_throw_exception(pango_ce_pangoexception, "Could not create the Pango font description", 0 TSRMLS_CC);
61 return;
62 }
63 }
64 /* }}} */
65
a593859 @davefx Add new PangoFontDescription methods from David Marín
davefx authored
66 /* {{{ proto PangoFontDescription pango_font_description_new(string description)
67 Creates a new font description object. This merges pango_font_description_new
ece2d92 @mgdm Add font description and alignment functions
authored
68 and pango_font_description_from_string. */
69 PHP_FUNCTION(pango_font_description_new)
70 {
71 pango_fontdesc_object *fontdesc_object = NULL;
72 const char *text;
73 long text_len = -1;
74
75 PHP_PANGO_ERROR_HANDLING(TRUE)
76 if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &text, &text_len) == FAILURE)
77 {
78 PHP_PANGO_RESTORE_ERRORS(TRUE)
79 return;
80 }
0e42a88 @mgdm Restore error handling every time it is reset
authored
81 PHP_PANGO_RESTORE_ERRORS(TRUE)
ece2d92 @mgdm Add font description and alignment functions
authored
82
83 object_init_ex(return_value, pango_ce_pangofontdescription);
84 if(text_len) {
85 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(return_value TSRMLS_CC);
86 fontdesc_object->fontdesc = pango_font_description_from_string(text);
87 } else {
88 fontdesc_object->fontdesc = pango_font_description_new();
89 }
90
91 if(fontdesc_object->fontdesc == NULL) {
92 }
93 }
94 /* }}} */
95
a593859 @davefx Add new PangoFontDescription methods from David Marín
davefx authored
96 /* {{{ proto long pango_font_description_get_variant(PangoFontDescription fontdesc)
97 proto long PangoFontDescription::getVariant()
ece2d92 @mgdm Add font description and alignment functions
authored
98 Sets the variant of the font description. */
99 PHP_FUNCTION(pango_font_description_get_variant)
100 {
101 zval *fontdesc_zval = NULL;
102 pango_fontdesc_object *fontdesc_object;
103
104 PHP_PANGO_ERROR_HANDLING(FALSE)
105 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &fontdesc_zval, pango_ce_pangofontdescription) == FAILURE)
106 {
107 PHP_PANGO_RESTORE_ERRORS(FALSE)
108 return;
109 }
110 PHP_PANGO_RESTORE_ERRORS(FALSE)
111
112 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
113 RETURN_LONG(pango_font_description_get_variant(fontdesc_object->fontdesc));
114 }
115
116 /* }}} */
117
a593859 @davefx Add new PangoFontDescription methods from David Marín
davefx authored
118 /* {{{ proto void pango_font_description_set_variant (PangoFontDescription fontdesc, long variant)
119 proto void PangoFontDescription::setVariant(long variant)
ece2d92 @mgdm Add font description and alignment functions
authored
120 Sets the variant of the layout. */
121 PHP_FUNCTION(pango_font_description_set_variant)
122 {
123 zval *fontdesc_zval = NULL;
124 pango_fontdesc_object *fontdesc_object;
125 long variant;
126
127 PHP_PANGO_ERROR_HANDLING(FALSE)
128 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &fontdesc_zval, pango_ce_pangofontdescription, &variant) == FAILURE) {
129 PHP_PANGO_RESTORE_ERRORS(FALSE)
130 return;
131 }
132 PHP_PANGO_RESTORE_ERRORS(FALSE)
133
134 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
135 pango_font_description_set_variant(fontdesc_object->fontdesc, variant);
136 }
137
138 /* }}} */
139
a593859 @davefx Add new PangoFontDescription methods from David Marín
davefx authored
140 /* {{{ proto boolean pango_font_description_equal(PangoFontDescription fontdesc1, PangoFontDescription fontdesc2)
141 proto boolean PangoFontDescription::equal(PangoFontDescription fontdesc2)
142 Compares two font description objects for equality.
143 */
144 PHP_FUNCTION(pango_font_description_equal)
145 {
146 zval *fontdesc_zval = NULL, *fontdesc2_zval = NULL;
147 pango_fontdesc_object *fontdesc_object, *fontdesc2_object;
148
149 PHP_PANGO_ERROR_HANDLING(FALSE)
150 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO",
151 &fontdesc_zval, pango_ce_pangofontdescription, &fontdesc2_zval, pango_ce_pangofontdescription) == FAILURE) {
152 PHP_PANGO_RESTORE_ERRORS(FALSE)
153 return;
154 }
155 PHP_PANGO_RESTORE_ERRORS(FALSE)
156
157 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
158 fontdesc2_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc2_zval TSRMLS_CC);
159 RETURN_BOOL(pango_font_description_equal(fontdesc_object->fontdesc, fontdesc2_object->fontdesc));
160 }
161
162 /* }}} */
163
164 /* {{{ proto void pango_font_description_set_family (PangoFontDescription fontdesc, string family)
165 proto void PangoFontDescription::setFamily(string family)
166 Sets the family name field of a font description. */
167 PHP_FUNCTION(pango_font_description_set_family)
168 {
169 zval *fontdesc_zval = NULL;
170 pango_fontdesc_object *fontdesc_object;
171 const char *family;
172 long family_len;
173
174 PHP_PANGO_ERROR_HANDLING(FALSE)
175 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &fontdesc_zval, pango_ce_pangofontdescription, &family, &family_len) == FAILURE) {
176 PHP_PANGO_RESTORE_ERRORS(FALSE)
177 return;
178 }
179 PHP_PANGO_RESTORE_ERRORS(FALSE)
180
181 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
182 pango_font_description_set_family(fontdesc_object->fontdesc, family);
183 }
184
185 /* }}} */
186
187 /* {{{ proto string pango_font_description_get_family (PangoFontDescription fontdesc)
188 proto string PangoFontDescription::getFamily()
189 Sets the family name field of a font description. */
190 PHP_FUNCTION(pango_font_description_get_family)
191 {
192 zval *fontdesc_zval = NULL;
193 pango_fontdesc_object *fontdesc_object;
194 const char *family;
195
196 PHP_PANGO_ERROR_HANDLING(FALSE)
197 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &fontdesc_zval, pango_ce_pangofontdescription) == FAILURE) {
198 PHP_PANGO_RESTORE_ERRORS(FALSE)
199 return;
200 }
201 PHP_PANGO_RESTORE_ERRORS(FALSE)
202
203 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
204 if ((family = pango_font_description_get_family(fontdesc_object->fontdesc))) {
205 RETURN_STRING((char *)family, 1);
206 }
207 RETURN_FALSE;
208 }
209
210 /* }}} */
211
212 /* {{{ proto void pango_font_description_set_size (PangoFontDescription fontdesc, long size)
213 proto void PangoFontDescription::setSize(long size)
214 Sets the size field of a font description. */
215 PHP_FUNCTION(pango_font_description_set_size)
216 {
217 zval *fontdesc_zval = NULL;
218 pango_fontdesc_object *fontdesc_object;
219 long size;
220
221 PHP_PANGO_ERROR_HANDLING(FALSE)
222 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &fontdesc_zval, pango_ce_pangofontdescription, &size) == FAILURE) {
223 PHP_PANGO_RESTORE_ERRORS(FALSE)
224 return;
225 }
226 PHP_PANGO_RESTORE_ERRORS(FALSE)
227
228 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
229 pango_font_description_set_size(fontdesc_object->fontdesc, size);
230 }
231
232 /* }}} */
233
234 /* {{{ proto long pango_font_description_get_size (PangoFontDescription fontdesc)
235 proto long PangoFontDescription::getSize()
236 Gets the size field of a font description. */
237 PHP_FUNCTION(pango_font_description_get_size)
238 {
239 zval *fontdesc_zval = NULL;
240 pango_fontdesc_object *fontdesc_object;
241 long size;
242
243 PHP_PANGO_ERROR_HANDLING(FALSE)
244 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &fontdesc_zval, pango_ce_pangofontdescription) == FAILURE) {
245 PHP_PANGO_RESTORE_ERRORS(FALSE)
246 return;
247 }
248 PHP_PANGO_RESTORE_ERRORS(FALSE)
249
250 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
251 RETURN_LONG (pango_font_description_get_size(fontdesc_object->fontdesc));
252 }
253
254 /* }}} */
255
256 /* {{{ proto long pango_font_description_get_style(PangoFontDescription fontdesc)
257 proto long PangoFontDescription::getStyle()
258 Gets the style of the font description. */
259 PHP_FUNCTION(pango_font_description_get_style)
260 {
261 zval *fontdesc_zval = NULL;
262 pango_fontdesc_object *fontdesc_object;
263
264 PHP_PANGO_ERROR_HANDLING(FALSE)
265 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &fontdesc_zval, pango_ce_pangofontdescription) == FAILURE)
266 {
267 PHP_PANGO_RESTORE_ERRORS(FALSE)
268 return;
269 }
270 PHP_PANGO_RESTORE_ERRORS(FALSE)
271
272 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
273 RETURN_LONG(pango_font_description_get_style(fontdesc_object->fontdesc));
274 }
275
276 /* }}} */
277
278 /* {{{ proto void pango_font_description_set_style (PangoFontDescription fontdesc, long style)
279 proto void PangoFontDescription::setVariant(long style)
280 Sets the style of the layout. */
281 PHP_FUNCTION(pango_font_description_set_style)
282 {
283 zval *fontdesc_zval = NULL;
284 pango_fontdesc_object *fontdesc_object;
285 long style;
286
287 PHP_PANGO_ERROR_HANDLING(FALSE)
288 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &fontdesc_zval, pango_ce_pangofontdescription, &style) == FAILURE) {
289 PHP_PANGO_RESTORE_ERRORS(FALSE)
290 return;
291 }
292 PHP_PANGO_RESTORE_ERRORS(FALSE)
293
294 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
295 pango_font_description_set_style(fontdesc_object->fontdesc, style);
296 }
297
298 /* }}} */
299
300
301 /* {{{ proto long pango_font_description_get_weight(PangoFontDescription fontdesc)
302 proto long PangoFontDescription::getWeight()
303 Sets the weight of the font description. */
304 PHP_FUNCTION(pango_font_description_get_weight)
305 {
306 zval *fontdesc_zval = NULL;
307 pango_fontdesc_object *fontdesc_object;
308
309 PHP_PANGO_ERROR_HANDLING(FALSE)
310 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &fontdesc_zval, pango_ce_pangofontdescription) == FAILURE)
311 {
312 PHP_PANGO_RESTORE_ERRORS(FALSE)
313 return;
314 }
315 PHP_PANGO_RESTORE_ERRORS(FALSE)
316
317 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
318 RETURN_LONG(pango_font_description_get_weight(fontdesc_object->fontdesc));
319 }
320
321 /* }}} */
322
323 /* {{{ proto void pango_font_description_set_weight (PangoFontDescription fontdesc, long weight)
324 proto void PangoFontDescription::setWeight(long weight)
325 Sets the weight of the layout. */
326 PHP_FUNCTION(pango_font_description_set_weight)
327 {
328 zval *fontdesc_zval = NULL;
329 pango_fontdesc_object *fontdesc_object;
330 long weight;
331
332 PHP_PANGO_ERROR_HANDLING(FALSE)
333 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &fontdesc_zval, pango_ce_pangofontdescription, &weight) == FAILURE) {
334 PHP_PANGO_RESTORE_ERRORS(FALSE)
335 return;
336 }
337 PHP_PANGO_RESTORE_ERRORS(FALSE)
338
339 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
340 pango_font_description_set_weight(fontdesc_object->fontdesc, weight);
341 }
342
343 /* }}} */
344
345
346 /* {{{ proto long pango_font_description_get_stretch(PangoFontDescription fontdesc)
347 proto long PangoFontDescription::getStretch()
348 Sets the stretch of the font description. */
349 PHP_FUNCTION(pango_font_description_get_stretch)
350 {
351 zval *fontdesc_zval = NULL;
352 pango_fontdesc_object *fontdesc_object;
353
354 PHP_PANGO_ERROR_HANDLING(FALSE)
355 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &fontdesc_zval, pango_ce_pangofontdescription) == FAILURE)
356 {
357 PHP_PANGO_RESTORE_ERRORS(FALSE)
358 return;
359 }
360 PHP_PANGO_RESTORE_ERRORS(FALSE)
361
362 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
363 RETURN_LONG(pango_font_description_get_stretch(fontdesc_object->fontdesc));
364 }
365
366 /* }}} */
367
368 /* {{{ proto void pango_font_description_set_stretch (PangoFontDescription fontdesc, long stretch)
369 proto void PangoFontDescription::setStretch(long stretch)
370 Sets the stretch of the layout. */
371 PHP_FUNCTION(pango_font_description_set_stretch)
372 {
373 zval *fontdesc_zval = NULL;
374 pango_fontdesc_object *fontdesc_object;
375 long stretch;
376
377 PHP_PANGO_ERROR_HANDLING(FALSE)
378 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &fontdesc_zval, pango_ce_pangofontdescription, &stretch) == FAILURE) {
379 PHP_PANGO_RESTORE_ERRORS(FALSE)
380 return;
381 }
382 PHP_PANGO_RESTORE_ERRORS(FALSE)
383
384 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
385 pango_font_description_set_stretch(fontdesc_object->fontdesc, stretch);
386 }
387
388 /* }}} */
389
390 /* {{{ proto string pango_font_description_to_string (PangoFontDescription fontdesc)
391 proto string PangoFontDescription::toString()
392 Creates a string representation of a font description. */
393 PHP_FUNCTION(pango_font_description_to_string)
394 {
395 zval *fontdesc_zval = NULL;
396 pango_fontdesc_object *fontdesc_object;
397 const char *result;
398
399 PHP_PANGO_ERROR_HANDLING(FALSE)
400 if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &fontdesc_zval, pango_ce_pangofontdescription) == FAILURE) {
401 PHP_PANGO_RESTORE_ERRORS(FALSE)
402 return;
403 }
404 PHP_PANGO_RESTORE_ERRORS(FALSE)
405
406 fontdesc_object = (pango_fontdesc_object *)zend_object_store_get_object(fontdesc_zval TSRMLS_CC);
407 if ((result = pango_font_description_to_string(fontdesc_object->fontdesc))) {
408 RETURN_STRING((char *)result, 1);
409 }
410 RETURN_FALSE;
411 }
412
413 /* }}} */
414
415
416
417
8fa8b81 @mgdm Add more font handling and layout methods
authored
418 /* {{{ Object creation/destruction functions */
419 static void pango_fontdesc_object_destroy(void *object TSRMLS_DC)
420 {
421 pango_fontdesc_object *fontdesc = (pango_fontdesc_object *)object;
422 zend_hash_destroy(fontdesc->std.properties);
423 FREE_HASHTABLE(fontdesc->std.properties);
424
ece2d92 @mgdm Add font description and alignment functions
authored
425 if(fontdesc->fontdesc) {
8fa8b81 @mgdm Add more font handling and layout methods
authored
426 pango_font_description_free(fontdesc->fontdesc);
a593859 @davefx Add new PangoFontDescription methods from David Marín
davefx authored
427 }
8fa8b81 @mgdm Add more font handling and layout methods
authored
428 efree(object);
429 }
430
431 static zend_object_value pango_fontdesc_object_new(zend_class_entry *ce TSRMLS_DC)
432 {
433 zend_object_value retval;
434 pango_fontdesc_object *fontdesc;
435 zval *temp;
436
437 fontdesc = ecalloc(1, sizeof(pango_fontdesc_object));
438
439 fontdesc->std.ce = ce;
440 fontdesc->fontdesc = NULL;
441
442 ALLOC_HASHTABLE(fontdesc->std.properties);
443 zend_hash_init(fontdesc->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
a593859 @davefx Add new PangoFontDescription methods from David Marín
davefx authored
444 zend_hash_copy(fontdesc->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &temp, sizeof(zval *));
8fa8b81 @mgdm Add more font handling and layout methods
authored
445 retval.handle = zend_objects_store_put(fontdesc, NULL, (zend_objects_free_object_storage_t)pango_fontdesc_object_destroy, NULL TSRMLS_CC);
446 retval.handlers = &pango_std_object_handlers;
447 return retval;
448 }
449 /* }}} */
450
451 /* {{{ pango fontdescription class functions */
452 const zend_function_entry pango_fontdesc_methods[] = {
453 PHP_ME(PangoFontDescription, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
ece2d92 @mgdm Add font description and alignment functions
authored
454 PHP_ME_MAPPING(getVariant, pango_font_description_get_variant, NULL, ZEND_ACC_PUBLIC)
455 PHP_ME_MAPPING(setVariant, pango_font_description_set_variant, NULL, ZEND_ACC_PUBLIC)
a593859 @davefx Add new PangoFontDescription methods from David Marín
davefx authored
456 PHP_ME_MAPPING(equal, pango_font_description_equal, NULL, ZEND_ACC_PUBLIC)
457 PHP_ME_MAPPING(setFamily, pango_font_description_set_family, NULL, ZEND_ACC_PUBLIC)
458 PHP_ME_MAPPING(getFamily, pango_font_description_get_family, NULL, ZEND_ACC_PUBLIC)
459 PHP_ME_MAPPING(setSize, pango_font_description_set_size, NULL, ZEND_ACC_PUBLIC)
460 PHP_ME_MAPPING(getSize, pango_font_description_get_size, NULL, ZEND_ACC_PUBLIC)
461 PHP_ME_MAPPING(getStyle, pango_font_description_get_style, NULL, ZEND_ACC_PUBLIC)
462 PHP_ME_MAPPING(setStyle, pango_font_description_set_style, NULL, ZEND_ACC_PUBLIC)
463 PHP_ME_MAPPING(getWeight, pango_font_description_get_weight, NULL, ZEND_ACC_PUBLIC)
464 PHP_ME_MAPPING(setWeight, pango_font_description_set_weight, NULL, ZEND_ACC_PUBLIC)
465 PHP_ME_MAPPING(getStretch, pango_font_description_get_stretch, NULL, ZEND_ACC_PUBLIC)
466 PHP_ME_MAPPING(setStretch, pango_font_description_set_stretch, NULL, ZEND_ACC_PUBLIC)
467 PHP_ME_MAPPING(toString, pango_font_description_to_string, NULL, ZEND_ACC_PUBLIC)
8fa8b81 @mgdm Add more font handling and layout methods
authored
468 { NULL, NULL, NULL }
469 };
470
91f837e @mgdm Add some functions, start on layouts
authored
471 /* {{{ PHP_MINIT_FUNCTION */
472 PHP_MINIT_FUNCTION(pango_font)
473 {
8fa8b81 @mgdm Add more font handling and layout methods
authored
474 zend_class_entry fontdescription_ce;
91f837e @mgdm Add some functions, start on layouts
authored
475 zend_class_entry style_ce;
476 zend_class_entry weight_ce;
477 zend_class_entry variant_ce;
478 zend_class_entry stretch_ce;
479 zend_class_entry fontmask_ce;
480
8fa8b81 @mgdm Add more font handling and layout methods
authored
481 INIT_CLASS_ENTRY(fontdescription_ce, "PangoFontDescription", pango_fontdesc_methods);
482 pango_ce_pangofontdescription = zend_register_internal_class(&fontdescription_ce TSRMLS_CC);
483 pango_ce_pangofontdescription->create_object = pango_fontdesc_object_new;
484
91f837e @mgdm Add some functions, start on layouts
authored
485 INIT_CLASS_ENTRY(style_ce, "PangoStyle", NULL);
486 pango_ce_pangostyle = zend_register_internal_class(&style_ce TSRMLS_CC);
487 pango_ce_pangostyle->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_FINAL_CLASS;
488
489 #define REGISTER_PANGO_STYLE_LONG_CONST(const_name, value) \
490 zend_declare_class_constant_long(pango_ce_pangostyle, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); \
491 REGISTER_LONG_CONSTANT(#value, value, CONST_CS | CONST_PERSISTENT);
492
493 REGISTER_PANGO_STYLE_LONG_CONST("NORMAL", PANGO_STYLE_NORMAL);
494 REGISTER_PANGO_STYLE_LONG_CONST("OBLIQUE", PANGO_STYLE_OBLIQUE);
495 REGISTER_PANGO_STYLE_LONG_CONST("ITALIC", PANGO_STYLE_ITALIC);
496
497 INIT_CLASS_ENTRY(weight_ce, "PangoWeight", NULL);
498 pango_ce_pangoweight = zend_register_internal_class(&weight_ce TSRMLS_CC);
499 pango_ce_pangoweight->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_FINAL_CLASS;
500
501 #define REGISTER_PANGO_WEIGHT_LONG_CONST(const_name, value) \
502 zend_declare_class_constant_long(pango_ce_pangoweight, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); \
503 REGISTER_LONG_CONSTANT(#value, value, CONST_CS | CONST_PERSISTENT);
504
505 REGISTER_PANGO_WEIGHT_LONG_CONST("ULTRALIGHT", PANGO_WEIGHT_ULTRALIGHT);
506 REGISTER_PANGO_WEIGHT_LONG_CONST("LIGHT", PANGO_WEIGHT_LIGHT);
507 REGISTER_PANGO_WEIGHT_LONG_CONST("NORMAL", PANGO_WEIGHT_NORMAL);
508 REGISTER_PANGO_WEIGHT_LONG_CONST("SEMIBOLD", PANGO_WEIGHT_SEMIBOLD);
509 REGISTER_PANGO_WEIGHT_LONG_CONST("BOLD", PANGO_WEIGHT_BOLD);
510 REGISTER_PANGO_WEIGHT_LONG_CONST("ULTRABOLD", PANGO_WEIGHT_ULTRABOLD);
511 REGISTER_PANGO_WEIGHT_LONG_CONST("HEAVY", PANGO_WEIGHT_HEAVY);
2c10235 @mgdm Ensure 1.24 constants aren't added for Pango < 1.24
authored
512
1aa3c4f @mgdm Make extension compatible with Pango 1.14, for RHEL 5.x
authored
513 #ifdef PANGO_VERSION
2c10235 @mgdm Ensure 1.24 constants aren't added for Pango < 1.24
authored
514 #if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 24, 0)
515 REGISTER_PANGO_WEIGHT_LONG_CONST("THIN", PANGO_WEIGHT_THIN);
516 REGISTER_PANGO_WEIGHT_LONG_CONST("BOOK", PANGO_WEIGHT_BOOK);
517 REGISTER_PANGO_WEIGHT_LONG_CONST("MEDIUM", PANGO_WEIGHT_MEDIUM);
91f837e @mgdm Add some functions, start on layouts
authored
518 REGISTER_PANGO_WEIGHT_LONG_CONST("ULTRAHEAVY", PANGO_WEIGHT_ULTRAHEAVY);
2c10235 @mgdm Ensure 1.24 constants aren't added for Pango < 1.24
authored
519 #endif
1aa3c4f @mgdm Make extension compatible with Pango 1.14, for RHEL 5.x
authored
520 #endif
91f837e @mgdm Add some functions, start on layouts
authored
521
522 INIT_CLASS_ENTRY(variant_ce, "PangoVariant", NULL);
523 pango_ce_pangovariant = zend_register_internal_class(&variant_ce TSRMLS_CC);
524 pango_ce_pangovariant->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_FINAL_CLASS;
525
526 #define REGISTER_PANGO_VARIANT_LONG_CONST(const_name, value) \
527 zend_declare_class_constant_long(pango_ce_pangovariant, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); \
528 REGISTER_LONG_CONSTANT(#value, value, CONST_CS | CONST_PERSISTENT);
529
530 REGISTER_PANGO_VARIANT_LONG_CONST("NORMAL", PANGO_VARIANT_NORMAL);
531 REGISTER_PANGO_VARIANT_LONG_CONST("SMALL_CAPS", PANGO_VARIANT_SMALL_CAPS);
532
533 INIT_CLASS_ENTRY(stretch_ce, "PangoStretch", NULL);
534 pango_ce_pangostretch = zend_register_internal_class(&stretch_ce TSRMLS_CC);
535 pango_ce_pangostretch->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_FINAL_CLASS;
536
537 #define REGISTER_PANGO_STRETCH_LONG_CONST(const_name, value) \
538 zend_declare_class_constant_long(pango_ce_pangostretch, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); \
539 REGISTER_LONG_CONSTANT(#value, value, CONST_CS | CONST_PERSISTENT);
540
541 REGISTER_PANGO_STRETCH_LONG_CONST("ULTRA_CONDENSED", PANGO_STRETCH_ULTRA_CONDENSED);
542 REGISTER_PANGO_STRETCH_LONG_CONST("EXTRA_CONDENSED", PANGO_STRETCH_EXTRA_CONDENSED);
543 REGISTER_PANGO_STRETCH_LONG_CONST("CONDENSED", PANGO_STRETCH_CONDENSED);
544 REGISTER_PANGO_STRETCH_LONG_CONST("SEMI_CONDENSED", PANGO_STRETCH_SEMI_CONDENSED);
545 REGISTER_PANGO_STRETCH_LONG_CONST("NORMAL", PANGO_STRETCH_NORMAL);
546 REGISTER_PANGO_STRETCH_LONG_CONST("SEMI_EXPANDED", PANGO_STRETCH_SEMI_EXPANDED);
547 REGISTER_PANGO_STRETCH_LONG_CONST("EXPANDED", PANGO_STRETCH_EXPANDED);
548 REGISTER_PANGO_STRETCH_LONG_CONST("EXTRA_EXPANDED", PANGO_STRETCH_EXTRA_EXPANDED);
549 REGISTER_PANGO_STRETCH_LONG_CONST("ULTRA_EXPANDED", PANGO_STRETCH_ULTRA_EXPANDED);
550
551 INIT_CLASS_ENTRY(fontmask_ce, "PangoFontMask", NULL);
552 pango_ce_pangofontmask = zend_register_internal_class(&fontmask_ce TSRMLS_CC);
553 pango_ce_pangofontmask->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_FINAL_CLASS;
554
555 #define REGISTER_PANGO_FONT_MASK_LONG_CONST(const_name, value) \
556 zend_declare_class_constant_long(pango_ce_pangofontmask, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); \
557 REGISTER_LONG_CONSTANT(#value, value, CONST_CS | CONST_PERSISTENT);
558
559 REGISTER_PANGO_FONT_MASK_LONG_CONST("FAMILY", PANGO_FONT_MASK_FAMILY);
560 REGISTER_PANGO_FONT_MASK_LONG_CONST("STYLE", PANGO_FONT_MASK_STYLE);
561 REGISTER_PANGO_FONT_MASK_LONG_CONST("VARIANT", PANGO_FONT_MASK_VARIANT);
562 REGISTER_PANGO_FONT_MASK_LONG_CONST("WEIGHT", PANGO_FONT_MASK_WEIGHT);
563 REGISTER_PANGO_FONT_MASK_LONG_CONST("STRETCH", PANGO_FONT_MASK_STRETCH);
564 REGISTER_PANGO_FONT_MASK_LONG_CONST("SIZE", PANGO_FONT_MASK_SIZE);
1aa3c4f @mgdm Make extension compatible with Pango 1.14, for RHEL 5.x
authored
565 #ifdef PANGO_FONT_MASK_GRAVITY
91f837e @mgdm Add some functions, start on layouts
authored
566 REGISTER_PANGO_FONT_MASK_LONG_CONST("GRAVITY", PANGO_FONT_MASK_GRAVITY);
1aa3c4f @mgdm Make extension compatible with Pango 1.14, for RHEL 5.x
authored
567 #endif
91f837e @mgdm Add some functions, start on layouts
authored
568
569 return SUCCESS;
570 }
571
572 /*
573 * Local variables:
574 * tab-width: 4
575 * c-basic-offset: 4
576 * End:
577 * vim600: noet sw=4 ts=4 fdm=marker
578 * vim<600: noet sw=4 ts=4
579 */
Something went wrong with that request. Please try again.