CVS update: php3/functions
| From: | jah | Date: | Sat, 29 May 1999 12:02:27 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6243@lists.php.net to get a copy of this message | ||
Date: Saturday May 29, 1999 @ 8:02
Author: jah
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv17737/functions
Modified Files:
gd.c php3_gd.h
Log Message:
esac -> fi in configure.in
further fixes in gd & postscript
Index: php3/functions/gd.c
diff -u php3/functions/gd.c:1.118 php3/functions/gd.c:1.119
--- php3/functions/gd.c:1.118 Fri May 28 15:18:45 1999
+++ php3/functions/gd.c Sat May 29 08:02:27 1999
@@ -29,7 +29,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.118 1999/05/28 19:18:45 jah Exp $ */
+/* $Id: gd.c,v 1.119 1999/05/29 12:02:27 jah Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -1831,9 +1831,9 @@
#if HAVE_LIBT1
-void _php3_free_ps_font(int *f_ind)
+void _php3_free_ps_font(gd_ps_font *f_ind)
{
- T1_DeleteFont(*f_ind);
+ T1_DeleteFont(f_ind->font_id);
efree(f_ind);
}
@@ -1841,7 +1841,8 @@
Load a new font from specified file */
void php3_imagepsloadfont(INTERNAL_FUNCTION_PARAMETERS) {
pval *file;
- int *f_ind, l_ind;
+ int l_ind;
+ gd_ps_font *f_ind;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -1849,11 +1850,11 @@
convert_to_string(file);
- f_ind = emalloc(sizeof(int));
- *f_ind = T1_AddFont(file->value.str.val);
+ f_ind = emalloc(sizeof(gd_ps_font));
+ f_ind->font_id = T1_AddFont(file->value.str.val);
- if (*f_ind < 0) {
- switch (*f_ind) {
+ if (f_ind->font_id < 0) {
+ switch (f_ind->font_id) {
case -1:
php3_error(E_WARNING, "Couldn't find the font file");
RETURN_FALSE;
@@ -1870,7 +1871,8 @@
}
}
- T1_LoadFont(*f_ind);
+ T1_LoadFont(f_ind->font_id);
+ f_ind->extend = 1;
l_ind = php3_list_insert(f_ind, GD_GLOBAL(le_ps_font));
RETURN_LONG(l_ind);
}
@@ -1880,7 +1882,8 @@
Make a copy of a font for purposes like extending or reenconding */
void php3_imagepscopyfont(INTERNAL_FUNCTION_PARAMETERS) {
pval *fnt;
- int *nf_ind, *of_ind, l_ind, type;
+ int l_ind, type;
+ gd_ps_font *nf_ind, *of_ind;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &fnt) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -1895,13 +1898,13 @@
RETURN_FALSE;
}
- nf_ind = emalloc(sizeof(int));
- *nf_ind = T1_CopyFont(*of_ind);
+ nf_ind = emalloc(sizeof(gd_ps_font));
+ nf_ind->font_id = T1_CopyFont(of_ind->font_id);
- if (*nf_ind < 0) {
- switch (*nf_ind) {
+ if (nf_ind->font_id < 0) {
+ switch (nf_ind->font_id) {
case -1:
- php3_error(E_WARNING, "FontID %d is not loaded in memory", *of_ind);
+ php3_error(E_WARNING, "FontID %d is not loaded in memory", of_ind->font_id);
RETURN_FALSE;
break;
case -2:
@@ -1919,6 +1922,7 @@
}
}
+ nf_ind->extend = 1;
l_ind = php3_list_insert(nf_ind, GD_GLOBAL(le_ps_font));
RETURN_LONG(l_ind);
}
@@ -1953,7 +1957,8 @@
void php3_imagepsencodefont(INTERNAL_FUNCTION_PARAMETERS) {
pval *fnt, *enc;
char **enc_vector;
- int type, *f_ind;
+ int type;
+ gd_ps_font *f_ind;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &fnt, &enc) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -1974,8 +1979,8 @@
RETURN_FALSE;
}
- T1_DeleteAllSizes(*f_ind);
- if (T1_ReencodeFont(*f_ind, enc_vector)) {
+ T1_DeleteAllSizes(f_ind->font_id);
+ if (T1_ReencodeFont(f_ind->font_id, enc_vector)) {
T1_DeleteEncoding(enc_vector);
php3_error(E_WARNING, "Couldn't reencode font");
RETURN_FALSE;
@@ -1988,7 +1993,8 @@
Extend or or condense (if extend < 1) a font */
void php3_imagepsextendfont(INTERNAL_FUNCTION_PARAMETERS) {
pval *fnt, *ext;
- int type, *f_ind;
+ int type;
+ gd_ps_font *f_ind;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &fnt, &ext) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -2004,7 +2010,8 @@
RETURN_FALSE;
}
- if (T1_ExtendFont(*f_ind, ext->value.dval) != 0) RETURN_FALSE;
+ if (T1_ExtendFont(f_ind->font_id, ext->value.dval) != 0) RETURN_FALSE;
+ f_ind->extend = ext->value.dval;
RETURN_TRUE;
}
/* }}} */
@@ -2013,7 +2020,8 @@
Slant a font */
void php3_imagepsslantfont(INTERNAL_FUNCTION_PARAMETERS) {
pval *fnt, *slt;
- int type, *f_ind;
+ int type;
+ gd_ps_font*f_ind;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &fnt, &slt) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -2029,7 +2037,7 @@
RETURN_FALSE;
}
- if (T1_SlantFont(*f_ind, slt->value.dval) != 0) RETURN_FALSE;
+ if (T1_SlantFont(f_ind->font_id, slt->value.dval) != 0) RETURN_FALSE;
RETURN_TRUE;
}
/* }}} */
@@ -2039,7 +2047,8 @@
void php3_imagepstext(INTERNAL_FUNCTION_PARAMETERS) {
pval *img, *str, *fnt, *sz, *fg, *bg, *sp, *px, *py, *aas, *wd, *ang;
int i, j, x, y;
- int space, type, *f_ind;
+ int space, type;
+ gd_ps_font *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;
@@ -2148,22 +2157,22 @@
if (make_path) {
#ifdef HAVE_LIBT1_OUTLINE
dy = 0;
- dx = width;
+ dx = (int) width/f_ind->extend;
/*
if (angle) {
transform = T1_RotateMatrix(NULL, angle);
}
*/
- str_path = T1_GetCharOutline(*f_ind, str->value.str.val[0], sz->value.lval, transform);
+ str_path = T1_GetCharOutline(f_ind->font_id, str->value.str.val[0], sz->value.lval,
transform);
for (i = 1; i < str->value.str.len; i++) {
- amount_kern = T1_GetKerning(*f_ind, str->value.str.val[i-1], str->value.str.val[i]);
+ amount_kern = (int) T1_GetKerning(f_ind->font_id, str->value.str.val[i-1],
str->value.str.val[i])/f_ind->extend;
amount_kern += str->value.str.val[i-1] == ' ' ? space : 0;
- char_path = T1_GetMoveOutline(*f_ind, amount_kern, dy, 0, sz->value.lval, transform);
+ char_path = T1_GetMoveOutline(f_ind->font_id, amount_kern, dy, 0, sz->value.lval,
transform);
str_path = T1_ConcatOutlines(str_path, char_path);
/* Should scale according to the extend? And how to get it? */
- char_path = T1_GetMoveOutline(*f_ind, width, dy, 0, sz->value.lval, transform);
+ char_path = T1_GetMoveOutline(f_ind->font_id, dx, dy, 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);
+ char_path = T1_GetCharOutline(f_ind->font_id, str->value.str.val[i], sz->value.lval,
transform);
str_path = T1_ConcatOutlines(str_path, char_path);
}
str_img = T1_AAFillOutline(str_path, 0);
@@ -2174,10 +2183,10 @@
#endif
} else {
#ifdef HAVE_LIBT1_OUTLINE
- str_img = T1_AASetString(*f_ind, str->value.str.val, str->value.str.len,
+ str_img = T1_AASetString(f_ind->font_id, str->value.str.val, str->value.str.len,
space, T1_KERNING, sz->value.lval, NULL);
#else
- str_img = T1_AASetString(*f_ind, str->value.str.val, str->value.str.len,
+ str_img = T1_AASetString(f_ind->font_id, str->value.str.val, str->value.str.len,
space, T1_KERNING, sz->value.lval, 0);
#endif
}
@@ -2214,7 +2223,8 @@
Return the bounding box needed by a string if rasterized */
void php3_imagepsbbox(INTERNAL_FUNCTION_PARAMETERS) {
pval *str, *fnt, *sz, *sp, *wd, *ang;
- int i, space, width, amount_kern, type, *f_ind;
+ int i, space, width, amount_kern, type;
+ gd_ps_font *f_ind;
int per_char = 0;
double angle;
BBox char_bbox, str_bbox = {0, 0, 0, 0};
@@ -2256,7 +2266,7 @@
}
if (per_char) {
- space += T1_GetCharWidth(*f_ind, ' ');
+ space += T1_GetCharWidth(f_ind->font_id, ' ');
for (i = 0; i < str->value.str.len; i++) {
if (str->value.str.val[i] == ' ') {
@@ -2264,14 +2274,14 @@
char_bbox.urx = space;
str_bbox.urx += space;
} else {
- char_bbox = T1_GetCharBBox(*f_ind, str->value.str.val[i]);
- str_bbox.urx += i != str->value.str.len-1 ? T1_GetCharWidth(*f_ind,
str->value.str.val[i]) : char_bbox.urx;
+ char_bbox = T1_GetCharBBox(f_ind->font_id, str->value.str.val[i]);
+ str_bbox.urx += i != str->value.str.len-1 ? T1_GetCharWidth(f_ind->font_id,
str->value.str.val[i]) : char_bbox.urx;
}
str_bbox.urx += i != str->value.str.len-1 ? width : 0;
if (!i) {
str_bbox.llx = char_bbox.llx;
} else {
- amount_kern = T1_GetKerning(*f_ind, str->value.str.val[i-1], str->value.str.val[i]);
+ amount_kern = T1_GetKerning(f_ind->font_id, str->value.str.val[i-1],
str->value.str.val[i]);
str_bbox.urx += amount_kern;
}
str_bbox.lly = str_bbox.lly > char_bbox.lly ? char_bbox.lly : str_bbox.lly;
@@ -2282,7 +2292,7 @@
}
} else {
- str_bbox = T1_GetStringBBox(*f_ind, str->value.str.val, str->value.str.len, space,
T1_KERNING);
+ str_bbox = T1_GetStringBBox(f_ind->font_id, str->value.str.val, str->value.str.len,
space, T1_KERNING);
}
if (T1_errno) RETURN_FALSE;
Index: php3/functions/php3_gd.h
diff -u php3/functions/php3_gd.h:1.30 php3/functions/php3_gd.h:1.31
--- php3/functions/php3_gd.h:1.30 Fri May 28 03:22:02 1999
+++ php3/functions/php3_gd.h Sat May 29 08:02:27 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: php3_gd.h,v 1.30 1999/05/28 07:22:02 jah Exp $ */
+/* $Id: php3_gd.h,v 1.31 1999/05/29 12:02:27 jah Exp $ */
#ifndef _PHP3_GD_H
#define _PHP3_GD_H
@@ -96,7 +96,6 @@
#if HAVE_LIBT1
extern void php3_imagepsloadfont(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagepsfreefont(INTERNAL_FUNCTION_PARAMETERS);
-extern void _php3_free_ps_font(int *);
extern void php3_imagepscopyfont(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagepsencodefont(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagepsextendfont(INTERNAL_FUNCTION_PARAMETERS);
@@ -108,6 +107,12 @@
char *default_encoding;
} gd_module;
+typedef struct {
+ int font_id;
+ float extend;
+} gd_ps_font;
+
+extern void _php3_free_ps_font(gd_ps_font *);
extern gd_module php3_gd_module;
#endif
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net