CVS update: php3/functions

From: Date: Fri, 28 May 1999 14:12:09 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-6162@lists.php.net to get a copy of this message
Date: Friday May 28, 1999 @ 10:12 Author: jah Update of /repository/php3/functions In directory php:/tmp/cvs-serv20445/functions Modified Files: gd.c Log Message: Almost getting this right... Index: php3/functions/gd.c diff -u php3/functions/gd.c:1.116 php3/functions/gd.c:1.117 --- php3/functions/gd.c:1.116 Fri May 28 05:44:42 1999 +++ php3/functions/gd.c Fri May 28 10:12:09 1999 @@ -29,7 +29,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.116 1999/05/28 09:44:42 jah Exp $ */ +/* $Id: gd.c,v 1.117 1999/05/28 14:12:09 jah Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -2124,9 +2124,6 @@ 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); - /* - printf("%d %d %d %d %d\n", rd, gr, bl, aa[i], aa_steps); - */ } T1_AASetBitsPerPixel(8); @@ -2183,16 +2180,10 @@ for (j = 0; j < h_lines; j++) { switch (str_img->bits[j*v_lines+i]) { case 0: - /* - printf("%d %d %d %d\n", x+str_img->metrics.leftSideBearing+i, y-str_img->metrics.ascent+j, 0, str_img->bits[j*v_lines+i]); - */ 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); - /* - printf("%d %d %d %d\n", x+str_img->metrics.leftSideBearing+i, y-str_img->metrics.ascent+j, c_ind, str_img->bits[j*v_lines+i]); - */ } } } @@ -2215,7 +2206,7 @@ int i, space, width, amount_kern, type, *f_ind; int per_char = 0; double angle; - BBox char_bbox, str_bbox; + BBox char_bbox, str_bbox = {0, 0, 0, 0}; switch(ARG_COUNT(ht)) { case 3: @@ -2254,31 +2245,32 @@ } if (per_char) { - if (str->value.str.val[0] != ' ') { - str_bbox = T1_GetCharBBox(*f_ind, str->value.str.val[0]); - } else { - str_bbox.llx = str_bbox.lly = str_bbox.ury = 0; - str_bbox.urx = T1_GetCharWidth(*f_ind, ' ') + space; - } - for (i = 1; i < str->value.str.len; i++) { + space += T1_GetCharWidth(*f_ind, ' '); + + 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 = T1_GetCharWidth(*f_ind, ' ') + space + width; + char_bbox.urx = space; } else { - amount_kern = 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; - str_bbox.urx += amount_kern; char_bbox = T1_GetCharBBox(*f_ind, str->value.str.val[i]); } + str_bbox.urx += T1_GetCharWidth(*f_ind, str->value.str.val[i]); str_bbox.urx += width; - str_bbox.urx += char_bbox.urx + char_bbox.llx; - str_bbox.lly = (char_bbox.lly < str_bbox.lly ? char_bbox.lly : str_bbox.lly); - str_bbox.ury = (char_bbox.ury > str_bbox.ury ? char_bbox.ury : str_bbox.ury); + if (!i) { + str_bbox.llx = char_bbox.llx; + } + if (i < str->value.str.len-1) { + amount_kern = T1_GetKerning(*f_ind, str->value.str.val[i], str->value.str.val[i+1]); + str_bbox.urx += amount_kern; + } + str_bbox.lly = str_bbox.lly > char_bbox.lly ? char_bbox.lly : str_bbox.lly; + str_bbox.ury = str_bbox.ury > char_bbox.ury ? str_bbox.ury : char_bbox.ury; /* - printf("%d %d %d %d : %d %d %d %d\n", char_bbox.llx, char_bbox.lly, char_bbox.urx, char_bbox.ury, - str_bbox.llx, str_bbox.lly, str_bbox.urx, str_bbox.ury); + printf("%d %d %d '%c'\n", char_bbox.llx, char_bbox.urx, str_bbox.urx, str->value.str.val[i]); */ } + str_bbox.urx += str_bbox.llx; + } else { str_bbox = T1_GetStringBBox(*f_ind, str->value.str.val, str->value.str.len, space, T1_KERNING); } @@ -2288,10 +2280,10 @@ RETURN_FALSE; } - add_next_index_long(return_value, (int) ceil(((double) str_bbox.llx)/1000*sz->value.lval)); - add_next_index_long(return_value, (int) ceil(((double) str_bbox.lly)/1000*sz->value.lval)); - add_next_index_long(return_value, (int) ceil(((double) str_bbox.urx)/1000*sz->value.lval)); - add_next_index_long(return_value, (int) ceil(((double) str_bbox.ury)/1000*sz->value.lval)); + 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)); } /* }}} */ -- 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

« previous php.dev (#6162) next »