Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mgdm/php-pango
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdm committed Aug 14, 2011
2 parents ef3fd95 + f8b81b9 commit 327354e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 7 deletions.
3 changes: 1 addition & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
This is the start of a Pango binding for PHP. Current requirements are:

* PHP 5.2+
* Pango 1.20+ though this will likely change to a lower version when I've done
some research on it
* Pango 1.14+
* pecl/cairo. Currently the only functionality I'm wrapping are those required
to make Cairo rendering work which will suit my own purposes - however, once
that works I intend to remove the hard dependency here if I can.
Expand Down
2 changes: 1 addition & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if test "$PHP_PANGO" != "no"; then
AC_MSG_CHECKING(for pango)

if $PKG_CONFIG --exists pango; then
if $PKG_CONFIG --atleast-version=1.20 pango; then
if $PKG_CONFIG --atleast-version=1.14 pango; then
pango_version_full=`$PKG_CONFIG --modversion pango`
AC_MSG_RESULT([found $pango_version_full])
PANGO_LIBS="$LDFLAGS `$PKG_CONFIG --libs pango`"
Expand Down
30 changes: 29 additions & 1 deletion pango.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ ZEND_DECLARE_MODULE_GLOBALS(pango)
zend_class_entry *pango_ce_pango;
zend_object_handlers pango_std_object_handlers;

#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 16, 0)
/* proto int pango_version(void) {{{
returns the Pango version */
PHP_FUNCTION(pango_version)
Expand All @@ -57,14 +59,20 @@ PHP_FUNCTION(pango_version_string)
RETURN_STRING((char *)pango_version_string(), 1);
}
/* }}} */
#endif
#endif

/* {{{ pango_functions[]
*
* Every user visible function must have an entry in pango_functions[].
*/
const zend_function_entry pango_functions[] = {
#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 16, 0)
PHP_FE(pango_version, NULL)
PHP_FE(pango_version_string, NULL)
#endif
#endif
PHP_FE(pango_layout_new, NULL)
PHP_FE(pango_cairo_update_layout, NULL)
PHP_FE(pango_cairo_show_layout, NULL)
Expand All @@ -82,28 +90,40 @@ const zend_function_entry pango_functions[] = {
PHP_FE(pango_layout_get_text, NULL)
PHP_FE(pango_layout_set_markup, NULL)
PHP_FE(pango_layout_get_width, NULL)
PHP_FE(pango_layout_get_height, NULL)
PHP_FE(pango_layout_get_size, NULL)
PHP_FE(pango_layout_get_pixel_size, NULL)
PHP_FE(pango_layout_get_extents, NULL)
PHP_FE(pango_layout_get_pixel_extents, NULL)
PHP_FE(pango_layout_set_width, NULL)
#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 20, 0)
PHP_FE(pango_layout_set_height, NULL)
PHP_FE(pango_layout_get_height, NULL)
#endif
#endif
PHP_FE(pango_layout_set_font_description, NULL)
PHP_FE(pango_layout_set_alignment, NULL)
PHP_FE(pango_layout_get_alignment, NULL)
PHP_FE(pango_layout_set_justify, NULL)
PHP_FE(pango_layout_get_justify, NULL)
PHP_FE(pango_layout_set_wrap, NULL)
PHP_FE(pango_layout_get_wrap, NULL)
#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 16, 0)
PHP_FE(pango_layout_is_wrapped, NULL)
#endif
#endif
PHP_FE(pango_layout_set_indent, NULL)
PHP_FE(pango_layout_get_indent, NULL)
PHP_FE(pango_layout_set_spacing, NULL)
PHP_FE(pango_layout_get_spacing, NULL)
PHP_FE(pango_layout_set_ellipsize, NULL)
PHP_FE(pango_layout_get_ellipsize, NULL)
#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 16, 0)
PHP_FE(pango_layout_is_ellipsized, NULL)
#endif
#endif
PHP_FE(pango_layout_get_lines, NULL)
PHP_FE(pango_layout_get_line, NULL)
PHP_FE(pango_layout_get_line_count, NULL)
Expand All @@ -125,8 +145,12 @@ const zend_function_entry pango_functions[] = {
/* }}} */

const zend_function_entry pango_methods[] = {
#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 16, 0)
PHP_ME_MAPPING(version, pango_version, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME_MAPPING(versionString, pango_version_string, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
#endif
#endif
{NULL, NULL, NULL}
};

Expand Down Expand Up @@ -208,7 +232,11 @@ PHP_MINFO_FUNCTION(pango)
"compiled as static module"
#endif
);
#ifdef PANGO_VERSION_STRING
php_info_print_table_row(2, "Pango version", PANGO_VERSION_STRING);
#else
php_info_print_table_row(2, "Pango version", "Unknown");
#endif
php_info_print_table_row(2, "Extension version", PHP_PANGO_VERSION);
php_info_print_table_end();

Expand Down
4 changes: 4 additions & 0 deletions pango_font.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ PHP_MINIT_FUNCTION(pango_font)
REGISTER_PANGO_WEIGHT_LONG_CONST("ULTRABOLD", PANGO_WEIGHT_ULTRABOLD);
REGISTER_PANGO_WEIGHT_LONG_CONST("HEAVY", PANGO_WEIGHT_HEAVY);

#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 24, 0)
REGISTER_PANGO_WEIGHT_LONG_CONST("THIN", PANGO_WEIGHT_THIN);
REGISTER_PANGO_WEIGHT_LONG_CONST("BOOK", PANGO_WEIGHT_BOOK);
REGISTER_PANGO_WEIGHT_LONG_CONST("MEDIUM", PANGO_WEIGHT_MEDIUM);
REGISTER_PANGO_WEIGHT_LONG_CONST("ULTRAHEAVY", PANGO_WEIGHT_ULTRAHEAVY);
#endif
#endif

INIT_CLASS_ENTRY(variant_ce, "PangoVariant", NULL);
Expand Down Expand Up @@ -270,7 +272,9 @@ PHP_MINIT_FUNCTION(pango_font)
REGISTER_PANGO_FONT_MASK_LONG_CONST("WEIGHT", PANGO_FONT_MASK_WEIGHT);
REGISTER_PANGO_FONT_MASK_LONG_CONST("STRETCH", PANGO_FONT_MASK_STRETCH);
REGISTER_PANGO_FONT_MASK_LONG_CONST("SIZE", PANGO_FONT_MASK_SIZE);
#ifdef PANGO_FONT_MASK_GRAVITY
REGISTER_PANGO_FONT_MASK_LONG_CONST("GRAVITY", PANGO_FONT_MASK_GRAVITY);
#endif

return SUCCESS;
}
Expand Down
33 changes: 30 additions & 3 deletions pango_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ PHP_FUNCTION(pango_layout_get_width)

/* }}} */

#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 20, 0)
/* {{{ proto void pango_layout_get_height(PangoLayout layout, long height)
proto void PangoLayout::getHeight(long height)
Sets the height of the layout. */
Expand All @@ -425,8 +427,10 @@ PHP_FUNCTION(pango_layout_get_height)
}
RETURN_FALSE;
}

/* }}} */
#endif
#endif


/* {{{ proto void pango_layout_get_size(PangoLayout layout)
proto void PangoLayout::getHeight()
Expand Down Expand Up @@ -586,6 +590,8 @@ PHP_FUNCTION(pango_layout_set_width)

/* }}} */

#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 20, 0)
/* {{{ proto void pango_layout_set_height(PangoLayout layout, long height)
proto void PangoLayout::setHeight(long height)
Sets the height of the layout. */
Expand All @@ -605,8 +611,9 @@ PHP_FUNCTION(pango_layout_set_height)
layout_object = (pango_layout_object *)zend_object_store_get_object(layout_zval TSRMLS_CC);
pango_layout_set_height(layout_object->layout, height);
}

/* }}} */
#endif
#endif

/* {{{ proto void pango_layout_set_font_description(PangoLayout layout, long font_description)
proto void PangoLayout::setHeight(long font_description)
Expand Down Expand Up @@ -757,6 +764,8 @@ PHP_FUNCTION(pango_layout_get_wrap)
}
/* }}} */

#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 20, 0)
/* {{{ proto bool pango_layout_is_wrapped(PangoLayout layout)
proto bool PangoLayout::isWrapped(void)
Returns how text will be wrapped or not in the current layout */
Expand All @@ -776,6 +785,8 @@ PHP_FUNCTION(pango_layout_is_wrapped)
RETURN_BOOL(pango_layout_is_wrapped(layout_object->layout));
}
/* }}} */
#endif
#endif

/* {{{ proto void pango_layout_set_indent(PangoLayout layout, int indent)
proto void PangoLayout::setWrap(bool indent)
Expand Down Expand Up @@ -903,6 +914,8 @@ PHP_FUNCTION(pango_layout_get_ellipsize)
}
/* }}} */

#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 20, 0)
/* {{{ proto bool pango_layout_is_ellipsized(PangoLayout layout)
proto bool PangoLayout::isEllipsized(void)
Returns the ellipsize for the current layout */
Expand All @@ -922,6 +935,8 @@ PHP_FUNCTION(pango_layout_is_ellipsized)
RETURN_BOOL(pango_layout_is_ellipsized(layout_object->layout));
}
/* }}} */
#endif
#endif

/* {{{ proto array pango_layout_get_lines(PangoLayout layout)
proto array PangoLayout::getLines(void)
Expand Down Expand Up @@ -1049,13 +1064,17 @@ const zend_function_entry pango_layout_methods[] = {
PHP_ME_MAPPING(setText, pango_layout_set_text, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getText, pango_layout_get_text, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getWidth, pango_layout_get_width, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getHeight, pango_layout_get_height, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getSize, pango_layout_get_size, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getPixelSize, pango_layout_get_pixel_size, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getExtents, pango_layout_get_extents, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getPixelExtents, pango_layout_get_pixel_extents, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setWidth, pango_layout_set_width, NULL, ZEND_ACC_PUBLIC)
#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 20, 0)
PHP_ME_MAPPING(getHeight, pango_layout_get_height, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setHeight, pango_layout_set_height, NULL, ZEND_ACC_PUBLIC)
#endif
#endif
PHP_ME_MAPPING(setMarkup, pango_layout_set_markup, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(updateLayout, pango_cairo_update_layout, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(showLayout, pango_cairo_show_layout, NULL, ZEND_ACC_PUBLIC)
Expand All @@ -1067,14 +1086,22 @@ const zend_function_entry pango_layout_methods[] = {
PHP_ME_MAPPING(getJustify, pango_layout_get_justify, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setWrap, pango_layout_set_wrap, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getWrap, pango_layout_get_wrap, NULL, ZEND_ACC_PUBLIC)
#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 16, 0)
PHP_ME_MAPPING(isWrapped, pango_layout_is_wrapped, NULL, ZEND_ACC_PUBLIC)
#endif
#endif
PHP_ME_MAPPING(setIndent, pango_layout_set_indent, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getIndent, pango_layout_get_indent, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setSpacing, pango_layout_set_spacing, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getSpacing, pango_layout_get_spacing, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setEllipsize, pango_layout_set_ellipsize, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getEllipsize, pango_layout_get_ellipsize, NULL, ZEND_ACC_PUBLIC)
#ifdef PANGO_VERSION
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 20, 0)
PHP_ME_MAPPING(isEllipsized, pango_layout_is_ellipsized, NULL, ZEND_ACC_PUBLIC)
#endif
#endif
PHP_ME_MAPPING(contextChanged, pango_layout_context_changed, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getLines, pango_layout_get_lines, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getLine, pango_layout_get_line, NULL, ZEND_ACC_PUBLIC)
Expand Down

0 comments on commit 327354e

Please sign in to comment.