#ifdef ENABLE_GD_TTF
# include "gdttf.h"
#endif
+/*
+#if HAVE_LIBT1
+#include "gdt1.h"
+#endif
+*/
#ifndef M_PI
#define M_PI 3.14159265358979323846
typedef struct gdlib_global_struct{
int le_gd;
int le_gd_font;
+#if HAVE_LIBT1
+ int le_ps_font;
+ int le_ps_enc;
+#endif
} gdlib_global_struct;
# define GD_GLOBAL(a) gdlib_globals->a
# define GD_TLS_VARS
int le_gd;
int le_gd_font;
+#if HAVE_LIBT1
+int le_ps_font;
+int le_ps_enc;
+#endif
#endif
function_entry gd_functions[] = {
#ifdef ENABLE_GD_TTF
PHP_FE(imagettfbbox, NULL)
PHP_FE(imagettftext, NULL)
+#endif
+#if HAVE_LIBT1
+ PHP_FE(imagepsloadfont, NULL)
+ /*
+ PHP_FE(imagepscopyfont, NULL)
+ */
+ PHP_FE(imagepsfreefont, NULL)
+ PHP_FE(imagepsencodefont, NULL)
+ PHP_FE(imagepsextendfont, NULL)
+ PHP_FE(imagepsslantfont, NULL)
+ PHP_FE(imagepstext, NULL)
+ PHP_FE(imagepsbbox, NULL)
#endif
{NULL, NULL, NULL}
};
#endif
GD_GLOBAL(le_gd) = register_list_destructors(gdImageDestroy, NULL);
GD_GLOBAL(le_gd_font) = register_list_destructors(php_free_gd_font, NULL);
+#if HAVE_LIBT1
+ T1_SetBitmapPad(8);
+ T1_InitLib(NO_LOGFILE|IGNORE_CONFIGFILE|IGNORE_FONTDATABASE);
+ T1_SetLogLevel(T1LOG_DEBUG);
+ GD_GLOBAL(le_ps_font) = register_list_destructors(php_free_ps_font, NULL);
+ GD_GLOBAL(le_ps_enc) = register_list_destructors(php_free_ps_enc, NULL);
+#endif
return SUCCESS;
}
add_next_index_long(return_value, brect[i]);
}
}
-#endif
-#endif
+#endif /* ENABLE_GD_TTF */
+
+#if HAVE_LIBT1
+
+void php_free_ps_font(int *font)
+{
+ T1_DeleteFont(*font);
+ efree(font);
+}
+
+void php_free_ps_enc(char **enc)
+{
+ T1_DeleteEncoding(enc);
+}
+
+/* {{{ proto int imagepsloadfont(string pathname)
+ Load a new font from specified file */
+PHP_FUNCTION(imagepsloadfont)
+{
+ zval **file;
+ int f_ind, l_ind;
+ int *font;
+
+ if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string_ex(file);
+
+ f_ind = T1_AddFont((*file)->value.str.val);
+
+ if (f_ind < 0) {
+ switch (f_ind) {
+ case -1:
+ php_error(E_WARNING, "Couldn't find the font file");
+ RETURN_FALSE;
+ break;
+ case -2:
+ case -3:
+ php_error(E_WARNING, "Memory allocation fault in t1lib");
+ RETURN_FALSE;
+ break;
+ default:
+ php_error(E_WARNING, "An unknown error occurred in t1lib");
+ RETURN_FALSE;
+ break;
+ }
+ }
+
+ T1_LoadFont(f_ind);
+
+ font = (int *) emalloc(sizeof(int));
+ *font = f_ind;
+ ZEND_REGISTER_RESOURCE(return_value, font, GD_GLOBAL(le_ps_font));
+}
+/* }}} */
+
+/* {{{ The function in t1lib which this function uses seem to be buggy...
+proto int imagepscopyfont(int font_index)
+Make a copy of a font for purposes like extending or reenconding */
+/*
+PHP_FUNCTION(imagepscopyfont)
+{
+ pval *fnt;
+ int l_ind, type;
+ gd_ps_font *nf_ind, *of_ind;
+
+ if (ARG_COUNT(ht) != 1 || zend_get_parameters(ht, 1, &fnt) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(fnt);
+
+ of_ind = zend_list_find(fnt->value.lval, &type);
+
+ if (type != GD_GLOBAL(le_ps_font)) {
+ php_error(E_WARNING, "%d is not a Type 1 font index", fnt->value.lval);
+ RETURN_FALSE;
+ }
+
+ nf_ind = emalloc(sizeof(gd_ps_font));
+ nf_ind->font_id = T1_CopyFont(of_ind->font_id);
+
+ if (nf_ind->font_id < 0) {
+ l_ind = nf_ind->font_id;
+ efree(nf_ind);
+ switch (l_ind) {
+ case -1:
+ php_error(E_WARNING, "FontID %d is not loaded in memory", l_ind);
+ RETURN_FALSE;
+ break;
+ case -2:
+ php_error(E_WARNING, "Tried to copy a logical font");
+ RETURN_FALSE;
+ break;
+ case -3:
+ php_error(E_WARNING, "Memory allocation fault in t1lib");
+ RETURN_FALSE;
+ break;
+ default:
+ php_error(E_WARNING, "An unknown error occurred in t1lib");
+ RETURN_FALSE;
+ break;
+ }
+ }
+
+ nf_ind->extend = 1;
+ l_ind = zend_list_insert(nf_ind, GD_GLOBAL(le_ps_font));
+ RETURN_LONG(l_ind);
+}
+*/
+/* }}} */
+
+/* {{{ proto bool imagepsfreefont(int font_index)
+ Free memory used by a font */
+PHP_FUNCTION(imagepsfreefont)
+{
+ zval **fnt;
+ int *f_ind;
+
+ if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &fnt) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GD_GLOBAL(le_ps_font));
+
+ zend_list_delete((*fnt)->value.lval);
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool imagepsencodefont(int font_index, string filename)
+ To change a fonts character encoding vector */
+PHP_FUNCTION(imagepsencodefont)
+{
+ zval **fnt, **enc;
+ char **enc_vector;
+ int type;
+ int *f_ind;
+
+ if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &fnt, &enc) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string_ex(enc);
+
+ ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GD_GLOBAL(le_ps_font));
+
+ if ((enc_vector = T1_LoadEncoding((*enc)->value.str.val)) == NULL) {
+ php_error(E_WARNING, "Couldn't load encoding vector from %s", (*enc)->value.str.val);
+ RETURN_FALSE;
+ }
+
+ T1_DeleteAllSizes(*f_ind);
+ if (T1_ReencodeFont(*f_ind, enc_vector)) {
+ T1_DeleteEncoding(enc_vector);
+ php_error(E_WARNING, "Couldn't reencode font");
+ RETURN_FALSE;
+ }
+ zend_list_insert(enc_vector, GD_GLOBAL(le_ps_enc));
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool imagepsextendfont(int font_index, double extend)
+ Extend or or condense (if extend < 1) a font */
+PHP_FUNCTION(imagepsextendfont)
+{
+ zval **fnt, **ext;
+ int type;
+ int *f_ind;
+
+ if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &fnt, &ext) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_double_ex(ext);
+
+ ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GD_GLOBAL(le_ps_font));
+
+ if (T1_ExtendFont(*f_ind, (*ext)->value.dval) != 0) RETURN_FALSE;
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool imagepsslantfont(int font_index, double slant)
+ Slant a font */
+PHP_FUNCTION(imagepsslantfont)
+{
+ zval **fnt, **slt;
+ int type;
+ int *f_ind;
+
+ if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &fnt, &slt) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_double_ex(slt);
+
+ ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GD_GLOBAL(le_ps_font));
+
+ if (T1_SlantFont(*f_ind, (*slt)->value.dval) != 0) RETURN_FALSE;
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array imagepstext(int image, string text, int font, int size, int xcoord, int ycoord [, int space, int tightness, double angle, int antialias])
+ Rasterize a string over an image */
+PHP_FUNCTION(imagepstext)
+{
+ zval **img, **str, **fnt, **sz, **fg, **bg, **sp, **px, **py, **aas, **wd, **ang;
+ int i, j, x, y;
+ int space, type;
+ int *f_ind;
+ int h_lines, v_lines, c_ind;
+ int rd, gr, bl, fg_rd, fg_gr, fg_bl, bg_rd, bg_gr, bg_bl;
+ int aa[16], aa_steps;
+ int width, amount_kern, add_width;
+ double angle, extend;
+ unsigned long aa_greys[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
+ gdImagePtr bg_img;
+ GLYPH *str_img;
+ T1_OUTLINE *char_path, *str_path;
+ T1_TMATRIX *transform = NULL;
+
+ switch(ARG_COUNT(ht)) {
+ case 8:
+ if (zend_get_parameters_ex(8, &img, &str, &fnt, &sz, &fg, &bg, &px, &py) == FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string_ex(str);
+ convert_to_long_ex(sz);
+ convert_to_long_ex(fg);
+ convert_to_long_ex(bg);
+ convert_to_long_ex(px);
+ convert_to_long_ex(py);
+ x = (*px)->value.lval;
+ y = (*py)->value.lval;
+ space = 0;
+ aa_steps = 4;
+ width = 0;
+ angle = 0;
+ break;
+ case 12:
+ if (zend_get_parameters_ex(12, &img, &str, &fnt, &sz, &fg, &bg, &px, &py, &sp, &wd, &ang, &aas) == FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string_ex(str);
+ convert_to_long_ex(sz);
+ convert_to_long_ex(sp);
+ convert_to_long_ex(fg);
+ convert_to_long_ex(bg);
+ convert_to_long_ex(px);
+ convert_to_long_ex(py);
+ x = (*px)->value.lval;
+ y = (*py)->value.lval;
+ convert_to_long_ex(sp);
+ space = (*sp)->value.lval;
+ convert_to_long_ex(aas);
+ aa_steps = (*aas)->value.lval;
+ convert_to_long_ex(wd);
+ width = (*wd)->value.lval;
+ convert_to_double_ex(ang);
+ angle = (*ang)->value.dval;
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ }
+
+ bg_img = zend_list_find((*img)->value.lval, &type);
+
+ if (!bg_img || type != GD_GLOBAL(le_gd)) {
+ php_error(E_WARNING, "Unable to find image pointer");
+ RETURN_FALSE;
+ }
+
+ ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GD_GLOBAL(le_ps_font));
+
+ fg_rd = gdImageRed(bg_img, (*fg)->value.lval);
+ fg_gr = gdImageGreen(bg_img, (*fg)->value.lval);
+ fg_bl = gdImageBlue(bg_img, (*fg)->value.lval);
+ bg_rd = gdImageRed(bg_img, (*bg)->value.lval);
+ bg_gr = gdImageGreen(bg_img, (*bg)->value.lval);
+ bg_bl = gdImageBlue(bg_img, (*bg)->value.lval);
+
+ for (i = 0; i < aa_steps; i++) {
+ rd = bg_rd+(double)(fg_rd-bg_rd)/aa_steps*(i+1);
+ gr = bg_gr+(double)(fg_gr-bg_gr)/aa_steps*(i+1);
+ bl = bg_bl+(double)(fg_bl-bg_bl)/aa_steps*(i+1);
+ aa[i] = gdImageColorResolve(bg_img, rd, gr, bl);
+ }
+
+ T1_AASetBitsPerPixel(8);
+
+ switch (aa_steps) {
+ case 4:
+ T1_AASetGrayValues(0, 1, 2, 3, 4);
+ T1_AASetLevel(T1_AA_LOW);
+ break;
+ case 16:
+ T1_AAHSetGrayValues(aa_greys);
+ T1_AASetLevel(T1_AA_HIGH);
+ break;
+ default:
+ php_error(E_WARNING, "Invalid value %d as number of steps for antialiasing", aa_steps);
+ RETURN_FALSE;
+ }
+
+ if (angle) {
+ transform = T1_RotateMatrix(NULL, angle);
+ }
+
+ if (width) {
+ extend = T1_GetExtend(*f_ind);
+ str_path = T1_GetCharOutline(*f_ind, (*str)->value.str.val[0], (*sz)->value.lval, transform);
+
+ for (i = 1; i < (*str)->value.str.len; i++) {
+ amount_kern = (int) T1_GetKerning(*f_ind, (*str)->value.str.val[i-1], (*str)->value.str.val[i]);
+ amount_kern += (*str)->value.str.val[i-1] == ' ' ? space : 0;
+ add_width = (int) (amount_kern+width)/extend;
+
+ char_path = T1_GetMoveOutline(*f_ind, add_width, 0, 0, (*sz)->value.lval, transform);
+ str_path = T1_ConcatOutlines(str_path, char_path);
+
+ char_path = T1_GetCharOutline(*f_ind, (*str)->value.str.val[i], (*sz)->value.lval, transform);
+ str_path = T1_ConcatOutlines(str_path, char_path);
+ }
+ str_img = T1_AAFillOutline(str_path, 0);
+ } else {
+ str_img = T1_AASetString(*f_ind, (*str)->value.str.val, (*str)->value.str.len,
+ space, T1_KERNING, (*sz)->value.lval, transform);
+ }
+
+ if (T1_errno) RETURN_FALSE;
+
+ h_lines = str_img->metrics.ascent - str_img->metrics.descent;
+ v_lines = str_img->metrics.rightSideBearing - str_img->metrics.leftSideBearing;
+
+ for (i = 0; i < v_lines; i++) {
+ for (j = 0; j < h_lines; j++) {
+ switch (str_img->bits[j*v_lines+i]) {
+ case 0:
+ break;
+ default:
+ c_ind = aa[str_img->bits[j*v_lines+i]-1];
+ gdImageSetPixel(bg_img, x+str_img->metrics.leftSideBearing+i, y-str_img->metrics.ascent+j, c_ind);
+ }
+ }
+ }
+
+ if (array_init(return_value) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ add_next_index_long(return_value, str_img->metrics.leftSideBearing);
+ add_next_index_long(return_value, str_img->metrics.descent);
+ add_next_index_long(return_value, str_img->metrics.rightSideBearing);
+ add_next_index_long(return_value, str_img->metrics.ascent);
+
+}
+/* }}} */
+
+/* {{{ proto array imagepsbbox(string text, int font, int size [, int space, int tightness, int angle])
+ Return the bounding box needed by a string if rasterized */
+PHP_FUNCTION(imagepsbbox)
+{
+ zval **str, **fnt, **sz, **sp, **wd, **ang;
+ int i, space, add_width, char_width, amount_kern, type;
+ int cur_x, cur_y, dx, dy;
+ int x1, y1, x2, y2, x3, y3, x4, y4;
+ int *f_ind;
+ int per_char = 0;
+ double angle, sin_a, cos_a;
+ BBox char_bbox, str_bbox = {0, 0, 0, 0};
+
+ switch(ARG_COUNT(ht)) {
+ case 3:
+ if (zend_get_parameters_ex(3, &str, &fnt, &sz) == FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string_ex(str);
+ convert_to_long_ex(sz);
+ space = 0;
+ break;
+ case 6:
+ if (zend_get_parameters_ex(6, &str, &fnt, &sz, &sp, &wd, &ang) == FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string_ex(str);
+ convert_to_long_ex(sz);
+ convert_to_long_ex(sp);
+ space = (*sp)->value.lval;
+ convert_to_long_ex(wd);
+ add_width = (*wd)->value.lval;
+ convert_to_double_ex(ang);
+ angle = (*ang)->value.dval * M_PI / 180;
+ sin_a = sin(angle);
+ cos_a = cos(angle);
+ per_char = add_width || angle ? 1 : 0;
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ }
+
+ ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GD_GLOBAL(le_ps_font));
+
+#define max(a, b) (a > b ? a : b)
+#define min(a, b) (a < b ? a : b)
+#define new_x(a, b) (int) ((a) * cos_a - (b) * sin_a)
+#define new_y(a, b) (int) ((a) * sin_a + (b) * cos_a)
+
+ if (per_char) {
+ space += T1_GetCharWidth(*f_ind, ' ');
+ cur_x = cur_y = 0;
+
+ for (i = 0; i < (*str)->value.str.len; i++) {
+ if ((*str)->value.str.val[i] == ' ') {
+ char_bbox.llx = char_bbox.lly = char_bbox.ury = 0;
+ char_bbox.urx = char_width = space;
+ } else {
+ char_bbox = T1_GetCharBBox(*f_ind, (*str)->value.str.val[i]);
+ char_width = T1_GetCharWidth(*f_ind, (*str)->value.str.val[i]);
+ }
+ amount_kern = i ? T1_GetKerning(*f_ind, (*str)->value.str.val[i-1], (*str)->value.str.val[i]) : 0;
+
+ /* Transfer character bounding box to right place */
+ x1 = new_x(char_bbox.llx, char_bbox.lly) + cur_x;
+ y1 = new_y(char_bbox.llx, char_bbox.lly) + cur_y;
+ x2 = new_x(char_bbox.llx, char_bbox.ury) + cur_x;
+ y2 = new_y(char_bbox.llx, char_bbox.ury) + cur_y;
+ x3 = new_x(char_bbox.urx, char_bbox.ury) + cur_x;
+ y3 = new_y(char_bbox.urx, char_bbox.ury) + cur_y;
+ x4 = new_x(char_bbox.urx, char_bbox.lly) + cur_x;
+ y4 = new_y(char_bbox.urx, char_bbox.lly) + cur_y;
+
+ /* Find min & max values and compare them with current bounding box */
+ str_bbox.llx = min(str_bbox.llx, min(x1, min(x2, min(x3, x4))));
+ str_bbox.lly = min(str_bbox.lly, min(y1, min(y2, min(y3, y4))));
+ str_bbox.urx = max(str_bbox.urx, max(x1, max(x2, max(x3, x4))));
+ str_bbox.ury = max(str_bbox.ury, max(y1, max(y2, max(y3, y4))));
+
+ /* Move to the next base point */
+ dx = new_x(char_width + add_width + amount_kern, 0);
+ dy = new_y(char_width + add_width + amount_kern, 0);
+ cur_x += dx;
+ cur_y += dy;
+ /*
+ printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", x1, y1, x2, y2, x3, y3, x4, y4, char_bbox.llx, char_bbox.lly, char_bbox.urx, char_bbox.ury, char_width, amount_kern, cur_x, cur_y, dx, dy);
+ */
+ }
+
+ } else {
+ str_bbox = T1_GetStringBBox(*f_ind, (*str)->value.str.val, (*str)->value.str.len, space, T1_KERNING);
+ }
+ if (T1_errno) RETURN_FALSE;
+
+ if (array_init(return_value) == FAILURE) {
+ RETURN_FALSE;
+ }
+ /*
+ printf("%d %d %d %d\n", str_bbox.llx, str_bbox.lly, str_bbox.urx, str_bbox.ury);
+ */
+ add_next_index_long(return_value, (int) ceil(((double) str_bbox.llx)*(*sz)->value.lval/1000));
+ add_next_index_long(return_value, (int) ceil(((double) str_bbox.lly)*(*sz)->value.lval/1000));
+ add_next_index_long(return_value, (int) ceil(((double) str_bbox.urx)*(*sz)->value.lval/1000));
+ add_next_index_long(return_value, (int) ceil(((double) str_bbox.ury)*(*sz)->value.lval/1000));
+}
+/* }}} */
+
+#endif /* HAVE_LIBT1 */
+
+#endif /* HAVE_LIBGD */
/*
/* $Id$ */
-void php_free_ps_font(gd_ps_font *f_ind)
+#if 0 /* Moved currently back to gd.c */
+
+#include "php.h"
+#include "php_gd.h"
+
+#if HAVE_LIBT1
+
+void php_free_ps_font(int font_id)
{
- T1_DeleteFont(f_ind->font_id);
- efree(f_ind);
+ T1_DeleteFont(font_id);
}
void php_free_ps_enc(char **enc)
Load a new font from specified file */
PHP_FUNCTION(imagepsloadfont)
{
- pval *file;
- int l_ind;
- gd_ps_font *f_ind;
+ zval **file;
+ int f_ind, l_ind;
- if (ARG_COUNT(ht) != 1 || zend_get_parameters(ht, 1, &file) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(file);
+ convert_to_string_ex(file);
- f_ind = emalloc(sizeof(gd_ps_font));
- f_ind->font_id = T1_AddFont(file->value.str.val);
+ f_ind = T1_AddFont((*file)->value.str.val);
- if (f_ind->font_id < 0) {
- l_ind = f_ind->font_id;
- efree(f_ind);
- switch (l_ind) {
+ if (f_ind < 0) {
+ switch (f_ind) {
case -1:
php_error(E_WARNING, "Couldn't find the font file");
RETURN_FALSE;
}
}
- T1_LoadFont(f_ind->font_id);
- f_ind->extend = 1;
- l_ind = zend_list_insert(f_ind, GD_GLOBAL(le_ps_font));
+ T1_LoadFont(f_ind);
+ /*
+ l_ind = zend_list_insert(f_ind, T1_GLOBAL(le_ps_font));
RETURN_LONG(l_ind);
+ */
+ zend_list_addref(f_ind);
+ RETURN_LONG(f_ind);
}
/* }}} */
Free memory used by a font */
PHP_FUNCTION(imagepsfreefont)
{
- pval *fnt;
+ zval **fnt;
int type;
- if (ARG_COUNT(ht) != 1 || zend_get_parameters(ht, 1, &fnt) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &fnt) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(fnt);
+ convert_to_long_ex(fnt);
- zend_list_find(fnt->value.lval, &type);
+ zend_list_find((*fnt)->value.lval, &type);
- if (type != GD_GLOBAL(le_ps_font)) {
- php_error(E_WARNING, "%d is not a Type 1 font index", fnt->value.lval);
+ if (type != T1_GLOBAL(le_ps_font)) {
+ php_error(E_WARNING, "%d is not a Type 1 font index", (*fnt)->value.lval);
RETURN_FALSE;
}
- zend_list_delete(fnt->value.lval);
+ zend_list_delete((*fnt)->value.lval);
RETURN_TRUE;
}
/* }}} */
To change a fonts character encoding vector */
PHP_FUNCTION(imagepsencodefont)
{
- pval *fnt, *enc;
+ zval **fnt, **enc;
char **enc_vector;
int type;
- gd_ps_font *f_ind;
+ int f_ind;
- if (ARG_COUNT(ht) != 2 || zend_get_parameters(ht, 2, &fnt, &enc) == FAILURE) {
+ if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &fnt, &enc) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(fnt);
- convert_to_string(enc);
+ convert_to_long_ex(fnt);
+ convert_to_string_ex(enc);
- f_ind = zend_list_find(fnt->value.lval, &type);
+ f_ind = zend_list_find((*fnt)->value.lval, &type);
- if (type != GD_GLOBAL(le_ps_font)) {
- php_error(E_WARNING, "%d is not a Type 1 font index", fnt->value.lval);
+ if (type != T1_GLOBAL(le_ps_font)) {
+ php_error(E_WARNING, "%d is not a Type 1 font index", (*fnt)->value.lval);
RETURN_FALSE;
}
- if ((enc_vector = T1_LoadEncoding(enc->value.str.val)) == NULL) {
- php_error(E_WARNING, "Couldn't load encoding vector from %s", enc->value.str.val);
+ if ((enc_vector = T1_LoadEncoding((*enc)->value.str.val)) == NULL) {
+ php_error(E_WARNING, "Couldn't load encoding vector from %s", (*enc)->value.str.val);
RETURN_FALSE;
}
- T1_DeleteAllSizes(f_ind->font_id);
- if (T1_ReencodeFont(f_ind->font_id, enc_vector)) {
+ T1_DeleteAllSizes(f_ind);
+ if (T1_ReencodeFont(f_ind, enc_vector)) {
T1_DeleteEncoding(enc_vector);
php_error(E_WARNING, "Couldn't reencode font");
RETURN_FALSE;
}
- zend_list_insert(enc_vector, GD_GLOBAL(le_ps_enc));
+ zend_list_insert(enc_vector, T1_GLOBAL(le_ps_enc));
RETURN_TRUE;
}
/* }}} */
Extend or or condense (if extend < 1) a font */
PHP_FUNCTION(imagepsextendfont)
{
- pval *fnt, *ext;
+ zval **fnt, **ext;
int type;
- gd_ps_font *f_ind;
+ int f_ind;
- if (ARG_COUNT(ht) != 2 || zend_get_parameters(ht, 2, &fnt, &ext) == FAILURE) {
+ if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &fnt, &ext) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(fnt);
- convert_to_double(ext);
+ convert_to_long_ex(fnt);
+ convert_to_double_ex(ext);
- f_ind = zend_list_find(fnt->value.lval, &type);
+ f_ind = zend_list_find((*fnt)->value.lval, &type);
- if (type != GD_GLOBAL(le_ps_font)) {
- php_error(E_WARNING, "%d is not a Type 1 font index", fnt->value.lval);
+ if (type != T1_GLOBAL(le_ps_font)) {
+ php_error(E_WARNING, "%d is not a Type 1 font index", (*fnt)->value.lval);
RETURN_FALSE;
}
- if (T1_ExtendFont(f_ind->font_id, ext->value.dval) != 0) RETURN_FALSE;
+ if (T1_ExtendFont(f_ind, (*ext)->value.dval) != 0) RETURN_FALSE;
+ /*
f_ind->extend = ext->value.dval;
+ */
RETURN_TRUE;
}
/* }}} */
Slant a font */
PHP_FUNCTION(imagepsslantfont)
{
- pval *fnt, *slt;
+ zval **fnt, **slt;
int type;
- gd_ps_font*f_ind;
+ int f_ind;
- if (ARG_COUNT(ht) != 2 || zend_get_parameters(ht, 2, &fnt, &slt) == FAILURE) {
+ if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &fnt, &slt) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(fnt);
- convert_to_double(slt);
+ convert_to_long_ex(fnt);
+ convert_to_double_ex(slt);
- f_ind = zend_list_find(fnt->value.lval, &type);
+ f_ind = zend_list_find((*fnt)->value.lval, &type);
- if (type != GD_GLOBAL(le_ps_font)) {
- php_error(E_WARNING, "%d is not a Type 1 font index", fnt->value.lval);
+ if (type != T1_GLOBAL(le_ps_font)) {
+ php_error(E_WARNING, "%d is not a Type 1 font index", (*fnt)->value.lval);
RETURN_FALSE;
}
- if (T1_SlantFont(f_ind->font_id, slt->value.dval) != 0) RETURN_FALSE;
+ if (T1_SlantFont(f_ind, (*slt)->value.dval) != 0) RETURN_FALSE;
RETURN_TRUE;
}
/* }}} */
Rasterize a string over an image */
PHP_FUNCTION(imagepstext)
{
- pval *img, *str, *fnt, *sz, *fg, *bg, *sp, *px, *py, *aas, *wd, *ang;
+ zval **img, **str, **fnt, **sz, **fg, **bg, **sp, **px, **py, **aas, **wd, **ang;
int i, j, x, y;
int space, type;
- gd_ps_font *f_ind;
+ int f_ind;
int h_lines, v_lines, c_ind;
int rd, gr, bl, fg_rd, fg_gr, fg_bl, bg_rd, bg_gr, bg_bl;
int aa[16], aa_steps;
unsigned long aa_greys[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
gdImagePtr bg_img;
GLYPH *str_img;
-#ifdef HAVE_LIBT1_OUTLINE
T1_OUTLINE *char_path, *str_path;
T1_TMATRIX *transform = NULL;
-#endif
switch(ARG_COUNT(ht)) {
case 8:
- if (zend_get_parameters(ht, 8, &img, &str, &fnt, &sz, &fg, &bg, &px, &py) == FAILURE) {
+ if (zend_get_parameters_ex(8, &img, &str, &fnt, &sz, &fg, &bg, &px, &py) == FAILURE) {
RETURN_FALSE;
}
- convert_to_string(str);
- convert_to_long(fnt);
- convert_to_long(sz);
- convert_to_long(fg);
- convert_to_long(bg);
- convert_to_long(px);
- convert_to_long(py);
- x = px->value.lval;
- y = py->value.lval;
+ convert_to_string_ex(str);
+ convert_to_long_ex(fnt);
+ convert_to_long_ex(sz);
+ convert_to_long_ex(fg);
+ convert_to_long_ex(bg);
+ convert_to_long_ex(px);
+ convert_to_long_ex(py);
+ x = (*px)->value.lval;
+ y = (*py)->value.lval;
space = 0;
aa_steps = 4;
width = 0;
angle = 0;
break;
case 12:
- if (zend_get_parameters(ht, 12, &img, &str, &fnt, &sz, &fg, &bg, &px, &py, &sp, &wd, &ang, &aas) == FAILURE) {
+ if (zend_get_parameters_ex(12, &img, &str, &fnt, &sz, &fg, &bg, &px, &py, &sp, &wd, &ang, &aas) == FAILURE) {
RETURN_FALSE;
}
- convert_to_string(str);
- convert_to_long(fnt);
- convert_to_long(sz);
- convert_to_long(sp);
- convert_to_long(fg);
- convert_to_long(bg);
- convert_to_long(px);
- convert_to_long(py);
- x = px->value.lval;
- y = py->value.lval;
- convert_to_long(sp);
- space = sp->value.lval;
- convert_to_long(aas);
- aa_steps = aas->value.lval;
- convert_to_long(wd);
- width = wd->value.lval;
- convert_to_double(ang);
- angle = ang->value.dval;
+ convert_to_string_ex(str);
+ convert_to_long_ex(fnt);
+ convert_to_long_ex(sz);
+ convert_to_long_ex(sp);
+ convert_to_long_ex(fg);
+ convert_to_long_ex(bg);
+ convert_to_long_ex(px);
+ convert_to_long_ex(py);
+ x = (*px)->value.lval;
+ y = (*py)->value.lval;
+ convert_to_long_ex(sp);
+ space = (*sp)->value.lval;
+ convert_to_long_ex(aas);
+ aa_steps = (*aas)->value.lval;
+ convert_to_long_ex(wd);
+ width = (*wd)->value.lval;
+ convert_to_double_ex(ang);
+ angle = (*ang)->value.dval;
break;
default:
WRONG_PARAM_COUNT;
}
- bg_img = zend_list_find(img->value.lval, &type);
+ bg_img = zend_list_find((*img)->value.lval, &type);
if (!bg_img || type != GD_GLOBAL(le_gd)) {
php_error(E_WARNING, "Unable to find image pointer");
}
/* }}} */
+#endif /* HAVE_LIBT1 */
+
+#endif /* 0 */
+
/*
* Local variables:
* tab-width: 4