ports/142165: [PATCH] lang/php5: add optional patch for gd2
Martin Matuska
mm at FreeBSD.org
Wed Dec 30 10:10:03 UTC 2009
>Number: 142165
>Category: ports
>Synopsis: [PATCH] lang/php5: add optional patch for gd2
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Dec 30 10:10:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Martin Matuska
>Release: FreeBSD 8.0-RELEASE-p1 amd64
>Organization:
>Environment:
System: FreeBSD core.vx.sk 8.0-RELEASE-p1 FreeBSD 8.0-RELEASE-p1 #10: Sat Dec 19 21:25:41 CET 2009
>Description:
Add optional patch for php5-gd2 with extended freetype2 options support.
Suggest new option name: WITH_EXTRAFT2
This patch adds new functionality to imagefttext() function without breaking compatibility.
imagefttext() extrainfo options array parameters added:
load_no_scale FT_LOAD_NO_SCALE
load_no_hinting FT_LOAD_NO_HINTING
load_no_bitmap FT_LOAD_NO_BITMAP
load_force_autohint FT_LOAD_FORCE_AUTOHINT
load_ignore_transform FT_LOAD_IGNORE_TRANSFORM
load_monochrome FT_LOAD_MONOCHROME
load_linear_design FT_LOAD_LINEAR_DESIGN
load_no_autohint FT_LOAD_NO_AUTOHINT
hdpi Horizontal DPI (default 96)
vdpi Vertical DPI (default 96)
screenres Shortcut to set both hdpi and vdpi
slant_angle "Faux italic", float in degrees (default 0)
advance_mult character spacing multiplication, float (default 1.0)
width_mult width multiplication, float (default 1.0)
height_mult height multiplication, float (default 1.0)
More information about the patch and its impact + patch source:
http://greyworld.net/en/projects/php-gd-better-freetype2/
Added file(s):
- files/extra-patch-gd-ft2
Port maintainer (ale at FreeBSD.org) is cc'd.
Generated with FreeBSD Port Tools 0.99
>How-To-Repeat:
>Fix:
--- php5-5.2.12.patch begins here ---
Index: Makefile.ext
===================================================================
RCS file: /home/pcvs/ports/lang/php5/Makefile.ext,v
retrieving revision 1.66
diff -u -r1.66 Makefile.ext
--- Makefile.ext 8 Dec 2009 08:59:27 -0000 1.66
+++ Makefile.ext 30 Dec 2009 10:03:22 -0000
@@ -109,7 +109,8 @@
OPTIONS= T1LIB "Include T1lib support" on \
TRUETYPE "Enable TrueType string function" on \
- JIS "Enable JIS-mapped Japanese font support" off
+ JIS "Enable JIS-mapped Japanese font support" off \
+ EXTRAFT2 "Additional parameters for imagefttext()" off
PHP_HEADER_DIRS=libgd
.endif
@@ -555,6 +556,9 @@
. if defined(WITH_JIS)
CONFIGURE_ARGS+=--enable-gd-jis-conv
. endif
+. if defined(WITH_EXTRAFT2)
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-gd-ft2
+. endif
.endif
.if ${PHP_MODNAME} == "mbstring"
Index: files/extra-patch-gd-ft2
===================================================================
RCS file: files/extra-patch-gd-ft2
diff -N files/extra-patch-gd-ft2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/extra-patch-gd-ft2 30 Dec 2009 10:03:22 -0000
@@ -0,0 +1,160 @@
+diff --git a/ext/gd/gd.c ./gd.c
+--- a/ext/gd/gd.c
++++ ./gd.c
+@@ -88,6 +88,9 @@
+ # include "gdttf.h"
+ #endif
+
++/* Need access to some freetype constants */
++#include <freetype/freetype.h>
++
+ #ifndef M_PI
+ #define M_PI 3.14159265358979323846
+ #endif
+@@ -4264,6 +4267,14 @@
+ angle = angle * (M_PI/180);
+
+ #if HAVE_GD_STRINGFTEX
++ if (extended) {
++ /* Sensible defaults */
++ strex.slant_angle = 0.;
++ strex.width_mult = 1.;
++ strex.height_mult = 1.;
++ strex.advance_mult = 1.;
++ }
++
+ if (extended && EXT) { /* parse extended info */
+ HashPosition pos;
+
+@@ -4286,6 +4297,49 @@
+ convert_to_double_ex(item);
+ strex.flags |= gdFTEX_LINESPACE;
+ strex.linespacing = Z_DVAL_PP(item);
++ } else if (strcmp("load_no_scale", key) == 0) {
++ strex.loadFlags |= FT_LOAD_NO_SCALE;
++ } else if (strcmp("load_no_hinting", key) == 0) {
++ strex.loadFlags |= FT_LOAD_NO_HINTING;
++ } else if (strcmp("load_no_bitmap", key) == 0) {
++ strex.loadFlags |= FT_LOAD_NO_BITMAP;
++ } else if (strcmp("load_force_autohint", key) == 0) {
++ strex.loadFlags |= FT_LOAD_FORCE_AUTOHINT;
++ } else if (strcmp("load_ignore_transform", key) == 0) {
++ strex.loadFlags |= FT_LOAD_IGNORE_TRANSFORM;
++ } else if (strcmp("load_monochrome", key) == 0) {
++ strex.loadFlags |= FT_LOAD_MONOCHROME;
++ } else if (strcmp("load_linear_design", key) == 0) {
++ strex.loadFlags |= FT_LOAD_LINEAR_DESIGN;
++ } else if (strcmp("load_no_autohint", key) == 0) {
++ strex.loadFlags |= FT_LOAD_NO_AUTOHINT;
++ } else if (strcmp("hdpi", key) == 0) {
++ convert_to_long_ex(item);
++ strex.hdpi = Z_LVAL_PP(item);
++ if (!strex.vdpi) strex.vdpi = strex.hdpi;
++ strex.flags |= gdFTEX_RESOLUTION;
++ } else if (strcmp("vdpi", key) == 0) {
++ convert_to_long_ex(item);
++ strex.vdpi = Z_LVAL_PP(item);
++ if (!strex.hdpi) strex.hdpi = strex.vdpi;
++ strex.flags |= gdFTEX_RESOLUTION;
++ } else if (strcmp("screenres", key) == 0) {
++ convert_to_long_ex(item);
++ strex.hdpi = Z_LVAL_PP(item);
++ strex.vdpi = strex.hdpi;
++ strex.flags |= gdFTEX_RESOLUTION;
++ } else if (strcmp("slant_angle", key) == 0) {
++ convert_to_double_ex(item);
++ strex.slant_angle = Z_DVAL_PP(item);
++ } else if (strcmp("advance_mult", key) == 0) {
++ convert_to_double_ex(item);
++ strex.advance_mult = Z_DVAL_PP(item);
++ } else if (strcmp("width_mult", key) == 0) {
++ convert_to_double_ex(item);
++ strex.width_mult = Z_DVAL_PP(item);
++ } else if (strcmp("height_mult", key) == 0) {
++ convert_to_double_ex(item);
++ strex.height_mult = Z_DVAL_PP(item);
+ }
+
+ } while (zend_hash_move_forward_ex(HASH_OF(EXT), &pos) == SUCCESS);
+diff --git a/ext/gd/libgd/gd.h ./libgd/gd.h
+--- a/ext/gd/libgd/gd.h
++++ ./libgd/gd.h
+@@ -347,6 +347,12 @@
+ for in the above order. */
+ int hdpi;
+ int vdpi;
++
++ int loadFlags; /* Freetype's FT_LOAD_* constants */
++ double slant_angle; /* Slant angle, in radians */
++ double advance_mult; /* Advange multiplier (letter spacing) */
++ double width_mult; /* Font's width multiplier */
++ double height_mult; /* Font's height multiplier */
+ }
+ gdFTStringExtra, *gdFTStringExtraPtr;
+
+diff --git a/ext/gd/libgd/gdft.c ./libgd/gdft.c
+--- a/ext/gd/libgd/gdft.c
++++ ./libgd/gdft.c
+@@ -773,7 +773,7 @@
+ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string, gdFTStringExtraPtr strex)
+ {
+ FT_BBox bbox, glyph_bbox;
+- FT_Matrix matrix;
++ FT_Matrix matrix, matrix_a, matrix_b;
+ FT_Vector pen, delta, penf;
+ FT_Face face;
+ FT_Glyph image;
+@@ -790,8 +790,8 @@
+ char *tmpstr = NULL;
+ int render = (im && (im->trueColor || (fg <= 255 && fg >= -255)));
+ FT_BitmapGlyph bm;
+- /* 2.0.13: Bob Ostermann: don't force autohint, that's just for testing freetype and doesn't look as good */
+- int render_mode = FT_LOAD_DEFAULT;
++ /* Render to bitmap by default */
++ int render_mode = FT_LOAD_RENDER;
+ int m, mfound;
+ /* Now tuneable thanks to Wez Furlong */
+ double linespace = LINESPACE;
+@@ -807,9 +807,14 @@
+ /* Tuneable horizontal and vertical resolution in dots per inch */
+ int hdpi, vdpi;
+
+- if (strex && ((strex->flags & gdFTEX_LINESPACE) == gdFTEX_LINESPACE)) {
+- linespace = strex->linespacing;
++ if (strex) {
++ if (strex && ((strex->flags & gdFTEX_LINESPACE) == gdFTEX_LINESPACE)) {
++ linespace = strex->linespacing;
++ }
++ /* Add additional FT_LOAD_* values */
++ render_mode |= strex->loadFlags;
+ }
++
+ tc_cache = gdCacheCreate(TWEENCOLORCACHESIZE, tweenColorTest, tweenColorFetch, tweenColorRelease);
+
+ /***** initialize font library and font cache on first call ******/
+@@ -854,10 +859,10 @@
+ return "Could not set character size";
+ }
+
+- matrix.xx = (FT_Fixed) (cos_a * (1 << 16));
+- matrix.yx = (FT_Fixed) (sin_a * (1 << 16));
+- matrix.xy = -matrix.yx;
+- matrix.yy = matrix.xx;
++ matrix.xx = (FT_Fixed) ((strex->width_mult * cos_a + strex->width_mult * strex->slant_angle * sin_a) * (1 << 16));
++ matrix.xy = (FT_Fixed) ((strex->width_mult * -sin_a + strex->width_mult * strex->slant_angle * cos_a) * (1 << 16));
++ matrix.yx = (FT_Fixed) ((strex->height_mult * sin_a) * (1 << 16));
++ matrix.yy = (FT_Fixed) ((strex->height_mult * cos_a) * (1 << 16));
+
+ penf.x = penf.y = 0; /* running position of non-rotated string */
+ pen.x = pen.y = 0; /* running position of rotated string */
+@@ -1095,8 +1100,8 @@
+ previous = glyph_index;
+
+ /* increment pen position */
+- pen.x += image->advance.x >> 10;
+- pen.y -= image->advance.y >> 10;
++ pen.x += (image->advance.x >> 10) * strex->advance_mult;
++ pen.y -= (image->advance.y >> 10) * strex->advance_mult;
+
+ penf.x += slot->metrics.horiAdvance;
+
--- php5-5.2.12.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list