[PHP-DEV] CVS update: php3/functions From: jah (php-dev <email protected>)
Date: 06/01/99

Date: Tuesday June 1, 1999 @ 18:04
Author: jah

Update of /repository/php3/functions
In directory php:/tmp/cvs-serv25244/functions

Modified Files:
        gd.c php3_gd.h
Log Message:

Hopefully last fixes to t1lib support,

Index: php3/functions/gd.c
diff -u php3/functions/gd.c:1.122 php3/functions/gd.c:1.123
--- php3/functions/gd.c:1.122 Sun May 30 05:26:59 1999
+++ php3/functions/gd.c Tue Jun 1 18:04:25 1999
@@ -29,7 +29,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gd.c,v 1.122 1999/05/30 09:26:59 jah Exp $ */
+/* $Id: gd.c,v 1.123 1999/06/01 22:04:25 jah Exp $ */
 
 /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
    Cold Spring Harbor Labs. */
@@ -75,9 +75,6 @@
 # include "functions/gdttf.h"
 # endif
 #endif
-#if HAVE_LIBT1
-#include <t1lib.h>
-#endif
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
@@ -96,6 +93,7 @@
         int le_gd;
         int le_gd_font;
 #if HAVE_LIBT1
+ int le_ps_enc;
         int le_ps_font;
         gd_module php3_gd_module;
 #endif
@@ -110,6 +108,7 @@
 int le_gd;
 int le_gd_font;
 #if HAVE_LIBT1
+int le_ps_enc;
 int le_ps_font;
 gd_module php3_gd_module;
 #endif
@@ -215,13 +214,15 @@
         GD_GLOBAL(le_gd_font) = register_list_destructors(php3_free_gd_font, NULL);
 #if HAVE_LIBT1
         T1_SetBitmapPad(8);
+ GD_GLOBAL(le_ps_font) = register_list_destructors(_php3_free_ps_font, NULL);
+ GD_GLOBAL(le_ps_enc) = register_list_destructors(_php3_free_ps_enc, NULL);
         T1_InitLib(NO_LOGFILE|IGNORE_CONFIGFILE|IGNORE_FONTDATABASE);
         T1_SetLogLevel(T1LOG_DEBUG);
- GD_GLOBAL(le_ps_font) = register_list_destructors(_php3_free_ps_font, NULL);
         if (cfg_get_string("ps.default_encoding", &GD_GLOBAL(php3_gd_module).default_encoding) != FAILURE
                 && GD_GLOBAL(php3_gd_module).default_encoding[0] != 0) {
                 T1_SetDefaultEncoding(T1_LoadEncoding(GD_GLOBAL(php3_gd_module).default_encoding));
         }
+
 #endif
         return SUCCESS;
 }
@@ -1839,6 +1840,11 @@
         efree(f_ind);
 }
 
+void _php3_free_ps_enc(char **enc)
+{
+ T1_DeleteEncoding(enc);
+}
+
 /* {{{ proto int imagepsloadfont(string pathname)
 Load a new font from specified file */
 void php3_imagepsloadfont(INTERNAL_FUNCTION_PARAMETERS) {
@@ -1994,6 +2000,7 @@
                 php3_error(E_WARNING, "Couldn't reencode font");
                 RETURN_FALSE;
         }
+ php3_list_insert(enc_vector, GD_GLOBAL(le_ps_enc));
         RETURN_TRUE;
 }
 /* }}} */
@@ -2061,8 +2068,7 @@
         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 dx, dy, width, amount_kern;
- int make_path = 0;
+ int width, amount_kern, add_width;
         double angle;
         unsigned long aa_greys[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
         gdImagePtr bg_img;
@@ -2113,7 +2119,6 @@
                 width = wd->value.lval;
                 convert_to_double(ang);
                 angle = ang->value.dval;
- make_path = width || angle ? 1 : 0;
                 break;
         default:
                 WRONG_PARAM_COUNT;
@@ -2163,41 +2168,33 @@
                 RETURN_FALSE;
         }
 
- if (make_path) {
-#ifdef HAVE_LIBT1_OUTLINE
- dy = 0;
- dx = (int) width/f_ind->extend;
-
         if (angle) {
                 transform = T1_RotateMatrix(NULL, angle);
         }
 
+ if (width) {
+#ifdef HAVE_LIBT1_OUTLINE
         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 = (int) T1_GetKerning(f_ind->font_id, str->value.str.val[i-1], str->value.str.val[i]);
                 amount_kern += str->value.str.val[i-1] == ' ' ? space : 0;
- char_path = T1_GetMoveOutline(f_ind->font_id, (int)amount_kern/f_ind->extend, dy, 0, sz->value.lval, transform);
- str_path = T1_ConcatOutlines(str_path, char_path);
+ add_width = (int) (amount_kern+width)/f_ind->extend;
 
- char_path = T1_GetMoveOutline(f_ind->font_id, dx, dy, 0, sz->value.lval, transform);
+ char_path = T1_GetMoveOutline(f_ind->font_id, add_width, 0, 0, sz->value.lval, transform);
                 str_path = T1_ConcatOutlines(str_path, char_path);
+
                 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);
-
 #else
- php3_error(E_WARNING, "This form of function ImagePSText is supported only with t1lib version 0.8 or above");
+ php3_error(E_WARNING, "Setting space between characters in function ImagePSText is supported only with t1lib version 0.9 or above");
         RETURN_FALSE;
 #endif
         } else {
-#ifdef HAVE_LIBT1_OUTLINE
- 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->font_id, str->value.str.val, str->value.str.len,
- space, T1_KERNING, sz->value.lval, 0);
-#endif
+ str_img = T1_AASetString(f_ind->font_id, str->value.str.val, str->value.str.len,
+ space, T1_KERNING, sz->value.lval, transform);
         }
 
         if (T1_errno) RETURN_FALSE;
@@ -2216,10 +2213,7 @@
                         }
                 }
         }
- /*
- free(str_img);
- str_img = NULL;
- */
+
         if (array_init(return_value) == FAILURE) {
                 RETURN_FALSE;
         }
@@ -2228,6 +2222,7 @@
         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);
+
 }
 /* }}} */
 
Index: php3/functions/php3_gd.h
diff -u php3/functions/php3_gd.h:1.32 php3/functions/php3_gd.h:1.33
--- php3/functions/php3_gd.h:1.32 Sun May 30 05:26:59 1999
+++ php3/functions/php3_gd.h Tue Jun 1 18:04:25 1999
@@ -29,7 +29,7 @@
  */
 
 
-/* $Id: php3_gd.h,v 1.32 1999/05/30 09:26:59 jah Exp $ */
+/* $Id: php3_gd.h,v 1.33 1999/06/01 22:04:25 jah Exp $ */
 
 #ifndef _PHP3_GD_H
 #define _PHP3_GD_H
@@ -43,6 +43,10 @@
 
 #include <gd.h>
 
+#if HAVE_LIBT1
+#include <t1lib.h>
+#endif
+
 extern php3_module_entry gd_module_entry;
 #define gd_module_ptr &gd_module_entry
 
@@ -115,6 +119,7 @@
 } gd_ps_font;
 
 extern void _php3_free_ps_font(gd_ps_font *);
+extern void _php3_free_ps_enc(char **);
 extern gd_module php3_gd_module;
 
 #endif

-- 
PHP Development Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>