Code Monkey home page Code Monkey logo

cairo's People

Contributors

auroraeosrose avatar derickr avatar felipensp avatar hholzgra avatar jan-e avatar johannes avatar mahcuz avatar mgdm avatar mhertsch avatar openaki avatar remicollet avatar weltling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cairo's Issues

Unable to display/load fonts

Hi guys, thanks for all the work on Cairo for PHP7, really hoping for some help please.

Following any one of the font based examples (select-font-face.php, large-font.php, etc.) I am unable to to display anything more than squiggly lines and shapes instead of text. What am I missing?

For clarification: everything has compiled successfully and I can draw shapes, but the text "Hi" is displaying as per the attached screenshot. Using PHP 7.1.9.
cairo-text

32 pecl-cairo master tests fail with cairo 1.8

"Oh RedHat, you make life angry!"

Yes, they do!
"old software is stable, and stable software is good."
Therefore: The older, the more stable. like Windows XP .)

CentOS release 6.5 (Final)
 cairo                                       x86_64                                 1.8.8-3.1.el6                                     
 cairo-devel                                 x86_64                                 1.8.8-3.1.el6                                   

=====================================================================
PHP         : /usr/bin/php 
PHP_SAPI    : cli
PHP_VERSION : 5.4.30
ZEND_VERSION: 2.4.0
PHP_OS      : Linux - Linux local@host 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64
INI actual  : /root/git/cairo.medic/tmp-php.ini
More .INIs  :  
CWD         : /root/git/cairo.medic
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2015-02-07 12:49:25

=====================================================================
TIME END 2015-02-07 12:50:37

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   30
---------------------------------------------------------------------

Number of tests :  447               440
Tests skipped   :    7 (  1.6%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   32 (  7.2%) (  7.3%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :  408 ( 91.3%) ( 92.7%)
---------------------------------------------------------------------
Time taken      :   72 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Cairo::statusToString() method [tests/Cairo/statusToString.phpt]
cairo_text_path() function [tests/CairoContext/Paths/cairo_text_path.phpt]
CairoContext->textPath() method [tests/CairoContext/Paths/textPath.phpt]
cairo_get_scaled_font() function [tests/CairoContext/Text/cairo_get_scaled_font.phpt]
cairo_set_scaled_font() function [tests/CairoContext/Text/cairo_set_scaled_font.phpt]
CairoContext->setScaledFont() method [tests/CairoContext/Text/getScaledFont.phpt]
CairoContext->setScaledFont() method [tests/CairoContext/Text/setScaledFont.phpt]
cairo_restore function [tests/CairoContext/cairo_restore.phpt]
CairoContext->restore() method [tests/CairoContext/restore.phpt]
new CairoScaledFont [ __construct() method ] [tests/CairoScaledFont/__construct.phpt]
cairo_scaled_font_create() function [tests/CairoScaledFont/cairo_scaled_font_create.phpt]
cairo_scaled_font_extents() function [tests/CairoScaledFont/cairo_scaled_font_extents.phpt]
cairo_scaled_font_get_ctm() function [tests/CairoScaledFont/cairo_scaled_font_get_ctm.phpt]
cairo_scaled_font_get_font_face() function [tests/CairoScaledFont/cairo_scaled_font_get_font_face.phpt]
cairo_scaled_font_get_font_matrix() function [tests/CairoScaledFont/cairo_scaled_font_get_font_matrix.phpt]
cairo_scaled_font_get_font_options() function [tests/CairoScaledFont/cairo_scaled_font_get_font_options.phpt]
cairo_scaled_font_get_scale_matrix() function [tests/CairoScaledFont/cairo_scaled_font_get_scale_matrix.phpt]
cairo_scaled_font_get_type() function [tests/CairoScaledFont/cairo_scaled_font_get_type.phpt]
cairo_scaled_font_status() function [tests/CairoScaledFont/cairo_scaled_font_status.phpt]
cairo_scaled_font_text_extents() function [tests/CairoScaledFont/cairo_scaled_font_text_extents.phpt]
CairoScaledFont->extents() method [tests/CairoScaledFont/extents.phpt]
CairoScaledFont->getCtm() method [tests/CairoScaledFont/getCtm.phpt]
CairoScaledFont->getFontFace() method [tests/CairoScaledFont/getFontFace.phpt]
CairoScaledFont->getFontMatrix() method [tests/CairoScaledFont/getFontMatrix.phpt]
CairoScaledFont->getFontOptions() method [tests/CairoScaledFont/getFontOptions.phpt]
CairoScaledFont->getScaleMatrix() method [tests/CairoScaledFont/getScaleMatrix.phpt]
CairoScaledFont->getType() method [tests/CairoScaledFont/getType.phpt]
CairoScaledFont->status() method [tests/CairoScaledFont/status.phpt]
CairoScaledFont->textExtents() method [tests/CairoScaledFont/textExtents.phpt]
new CairoSubSurface [ __construct method ] [tests/CairoSurface/CairoSubSurface/__construct.phpt]
cairo_surface_create_for_rectangle () function [tests/CairoSurface/cairo_surface_create_for_rectangle.phpt]
cairo_status_to_string function [tests/cairo_status_to_string.phpt]
=====================================================================

Bugs found whilst updating example files.

Below are a list of errors encountered whilst re-factoring the example files to work with PHP 7.

Note: I'll continually edit and update this issue until all examples are tested and committed.

a1-image-sample.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Antialias

a1-traps-sample.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Antialias

bitmap-font.php

Uncaught TypeError: Value 2 provided is not a const in enum Cairo\HintMetrics

caps-joins.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\LineCap

caps-sub-paths.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\LineCap

clip-fill-rule.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\FillRule

clip-operator.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\Operator

composite-integer-translate-over.php

Uncaught TypeError: Value 2 provided is not a const in enum Cairo\Operator

composite-integer-translate-over-repeat.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Extend

composite-integer-translate-source.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Operator

dash-caps-joins.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\LineCap

dash-curve.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\LineCap

dash-scale.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\LineCap

degenerate-arc.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\LineCap

degenerate-path.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\LineCap

degenerate-pen.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\LineJoin

device-offset.php

Uncaught TypeError: Cairo\Surface::createSimilar() expects parameter 1 to be integer, object given
$s = $context->getGroupSurface();
$c = $s->getContent();
$s1 = $s->createSimilar($c, $size / 2, $size / 2);

device-offset-positive.php

Uncaught TypeError: Cairo\Surface::createSimilar() expects parameter 1 to be integer, object given
$s = $context->getGroupSurface();
$c = $s->getContent();
$s1 = $s->createSimilar($c, $size / 2, $size / 2);

extend-pad.php

Uncaught TypeError: Value 3 provided is not a const in enum Cairo\Extend

extend-reflect.php

Uncaught TypeError: Value 2 provided is not a const in enum Cairo\Extend

extend-repeat.php

Uncaught TypeError: Value 2 provided is not a const in enum Cairo\Extend

extend-repeat-similar.php

Uncaught TypeError: Cairo\Surface::createSimilar() expects parameter 1 to be integer, object given
$s = new Image(ImageFormat::ARGB32, 100, 100);
$s->createFromPng(dirname(__FILE__).'/romedalen.png');
$s1 = $surface->createSimilar($surface->getContent(), 320, 256);

fill-rule.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\FillRule

finer-grained-fallbacks.php

Uncaught TypeError: Value 2 provided is not a const in enum Cairo\Operator

group-paint.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Operator

infinite-join.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\LineJoin

large-source.php

Uncaught ArgumentCountError: Cairo\Surface\Image::createForData() expects exactly 4 parameters, 5 given
$s->createForData($data, ImageFormat::A1, $width, $height, $stride);

linear-gradient-reflect.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\LineJoin

mask-ctm.php

Uncaught ArgumentCountError: Cairo\Surface\Image::createForData() expects exactly 4 parameters, 5 given
$s = new Image(ImageFormat::ARGB32, 1, 1);
$s->createForData($data, ImageFormat::ARGB32, 2, 2, 8);

mask-surface-ctm.php

Uncaught ArgumentCountError: Cairo\Surface\Image::createForData() expects exactly 4 parameters, 5 given
$s = new Image(ImageFormat::ARGB32, 1, 1);
$s->createForData($data, ImageFormat::ARGB32, 2, 2, 8);

meta-surface-pattern.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\Extend

move-to-show.php

Uncaught ArgumentCountError: Cairo\Surface\Image::createForData() expects exactly 4 parameters, 5 given
$s->createForData($c[$i], ImageFormat::RGB24, 1, 1, 4);

nil-surface.php

Uncaught TypeError: Argument 1 passed to Cairo\Pattern\Surface::__construct() must be an instance of Cairo\Surface, null given
$patternSurface = new PatternSurface(null);

operator-clear.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\Operator

operator-source.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Operator

over-above-source.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Operator

over-between-source.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Operator

paint-source-alpha.php

Uncaught ArgumentCountError: Cairo\Surface\Image::createForData() expects exactly 4 parameters, 5 given
$s->createForData($data, ImageFormat::ARGB32, 4, 4, 16);

pdf-surface-source.php

Segmentation fault (core dumped)

ps-surface-source.php

Segmentation fault (core dumped)

random-intersections.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\FillRule

rectangle-rounding-error.php

Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Antialias

rectilinear-stroke.php

Uncaught TypeError: Value 2 provided is not a const in enum Cairo\LineCap

rotate-image-surface-paint.php

Uncaught TypeError: Value 3 provided is not a const in enum Cairo\Filter

scale-down-source-surface-paint.php

Uncaught ArgumentCountError: Cairo\Surface\Image::createForData() expects exactly 4 parameters, 5 given
$s = new Image(ImageFormat::ARGB32, 100, 100);
$s->createForData($data, ImageFormat::RGB24, 4, 4, 16);

scale-source-surface-paint.php

Uncaught ArgumentCountError: Cairo\Surface\Image::createForData() expects exactly 4 parameters, 5 given
$s = new Image(ImageFormat::ARGB32, 100, 100);
$s->createForData($data, ImageFormat::RGB24, 4, 4, 16);

set-source.php

Uncaught ArgumentCountError: Cairo\Surface\Image::createForData() expects exactly 4 parameters, 5 given
$s = new Image(ImageFormat::ARGB32, 1, 1);
$s->createForData($color, ImageFormat::ARGB32, 1, 1, 4);

sphere.php

Uncaught TypeError: Value 0 provided is not a const in enum Cairo\Antialias

surface-check.php

Uncaught Error: Call to undefined function cairo_available_surfaces()

PHP 7 compatibility

Version 0.3.2 doesn't currently seem to compile with php7 because of the changes in ze3 (e.g. "zend_object_value" etc. don't exist anymore). Are there plans to update the cairo extension to compile successfully with php7?

master branch segfaults in FT_Set_Transform

Hi,
because 0.3.2 shows a (for me very bad) memory leak, i planned to go with master.
the good news: the memory leak is gone.

1st i suffered the FT_Free problem, which i solved by updating to a more recent version of libcairo + libfreetype

Now i suffer another segfault about every 10th request. I am using php-fpm, but also php-fcgi shows this behaviour:

(gdb) bt
#0  FT_Set_Transform (face=0x21b3b90, matrix=0x7fff54270010, delta=0x0) at /root/rpmbuild/BUILD/freetype-2.5.5/src/base/ftobjs.c:506
#1  0x00007f95d491f27f in _cairo_ft_unscaled_font_set_scale (unscaled=0x21b40c0, scale=) at cairo-ft-font.c:831
#2  0x00007f95d491f4d1 in _cairo_ft_font_face_scaled_font_create (abstract_font_face=0x24001d0, font_matrix=0x2181200, ctm=0x7fff54270330, options=0x7fff54270360, 
    font_out=0x7fff542702e8) at cairo-ft-font.c:1935
#3  0x00007f95d48bbe17 in cairo_scaled_font_create (font_face=, font_matrix=, ctm=, options=0x7fff54270360)
    at cairo-scaled-font.c:1135
#4  0x00007f95d4882b10 in _cairo_gstate_ensure_scaled_font (gstate=0x2181190) at cairo-gstate.c:1861
#5  0x00007f95d4882b79 in _cairo_gstate_get_scaled_font (gstate=0x2181190, scaled_font=0x7fff542703c8) at cairo-gstate.c:1733
#6  0x00007f95d487ede2 in _cairo_default_context_get_scaled_font (abstract_cr=) at cairo-default-context.c:1282
#7  0x00007f95d4878a62 in cairo_text_path (cr=0x2181160, utf8=0x7f95de4493c8 "blah") at cairo.c:3480
#8  0x00007f95d4b91fcb in zif_cairo_text_path (ht=, return_value=, return_value_ptr=, this_ptr=0x7f95de54bb90, 
    return_value_used=) at /root/rpmbuild/BUILD/php-pecl-cairo-0.3.2/NTS/cairo_context.c:2239
#9  0x00000000006596cc in zend_do_fcall_common_helper_SPEC (execute_data=) at /usr/src/debug/php-5.4.30/Zend/zend_vm_execute.h:643
(gdb) f 0
#0  FT_Set_Transform (face=0x21b3b90, matrix=0x7fff54270010, delta=0x0) at /root/rpmbuild/BUILD/freetype-2.5.5/src/base/ftobjs.c:506
506 /root/rpmbuild/BUILD/freetype-2.5.5/src/base/ftobjs.c: No such file or directory.
    in /root/rpmbuild/BUILD/freetype-2.5.5/src/base/ftobjs.c
(gdb) p *face
$31 = {num_faces = 140281616704264, face_index = 140281616704264, face_flags = 35339136, style_flags = 35339136, num_glyphs = 3417, family_name = 0x0, style_name = 0x0, 
  num_fixed_sizes = 0, available_sizes = 0x0, num_charmaps = 0, charmaps = 0x0, generic = {data = 0x0, finalizer = 0}, bbox = {xMin = -1361, yMin = -665, xMax = 4096, 
    yMax = 2060}, units_per_EM = 2048, ascender = 1854, descender = -434, height = 2355, max_advance_width = 4096, max_advance_height = 2355, underline_position = -292, 
  underline_thickness = 150, glyph = 0x0, size = 0x0, charmap = 0x2407ef0, driver = 0x24089f0, memory = 0x21bc630, stream = 0x0, sizes_list = {head = 0x0, tail = 0x0}, 
  autohint = {data = 0x0, finalizer = 0}, extensions = 0x0, internal = 0x0}
(gdb) p *face->internal
Cannot access memory at address 0x0

freetype codepath:

  FT_Set_Transform( FT_Face     face,
                    FT_Matrix*  matrix,
                    FT_Vector*  delta )
  {
    FT_Face_Internal  internal;


    if ( !face )
      return;

    internal = face->internal;

    internal->transform_flags = 0;

    if ( !matrix )
    {
      internal->transform_matrix.xx = 0x10000L;
      internal->transform_matrix.xy = 0;
      internal->transform_matrix.yx = 0;
      internal->transform_matrix.yy = 0x10000L;

      matrix = &internal->transform_matrix;
    }

i tried different versions of freetype & cairo,
but the relevant component is cairo-pecl :(

i bisect'ed, it was introduced with commit 6b6fea4

The script i am using is:

  $fontFile = dirname(__FILE__) . "/arial.ttf";

  $surface = new \CairoImageSurface(
    CairoFormat::ARGB32,
    750,
    750
  );

  $context = new \CairoContext( $surface );
  $fontFaceObject = new \CairoFtFontFace($fontFile);
  $context->setFontFace( $fontFaceObject );
  $CairoFontMatrix = new \CairoMatrix();
  $CairoFontMatrix->scale( 12, 12 );

    for( $i = 0; $i < 10; ++$i ) {
        $angle = rand(1, 360);
        $CairoFontMatrix->rotate(deg2rad($angle));
        $context->setFontMatrix( $CairoFontMatrix );

       $x = rand(0, 750);
       $y = rand(0, 750);
        $context->MoveTo( $x, $y );
        $context->textPath( "blah" . $i );
    }

Problem with create from PNG

Hi guys,

I'm not able to get the create-from-png.php and create-from-png-stream.php examples to work. I have copied and pasted the code exactly from the example files, along with the create-from-png-ref.png source image and my output file is always empty.

The confusing thing is that my PHP error log is quiet. If I misuse any of the functions I get errors reported as expected which leads me to believe that my implementation is correct.

Would anyone be able to help me determine what I am missing?

I'm using:
PHP: 7.2.2
Cairo: 1.14.8-2.el7

php7版本make报错,请问如何处理? error ? please help ,how to fix?

cc -I. -I/opt/php-7.0.14/ext/cairo-php7 -DPHP_ATOM_INC -I/opt/php-7.0.14/ext/cairo-php7/include -I/opt/php-7.0.14/ext/cairo-php7/main -I/opt/php-7.0.14/ext/cairo-php7 -I/usr/local/php70/include/php -I/usr/local/php70/include/php/main -I/usr/local/php70/include/php/TSRM -I/usr/local/php70/include/php/Zend -I/usr/local/php70/include/php/ext -I/usr/local/php70/include/php/ext/date/lib -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DHAVE_CONFIG_H -g -O2 -c /opt/php-7.0.14/ext/cairo-php7/src/cairo.c -fPIC -DPIC -o src/.libs/cairo.o
/opt/php-7.0.14/ext/cairo-php7/src/cairo.c: In function ‘php_cairo_get_ft_error’:
/opt/php-7.0.14/ext/cairo-php7/src/cairo.c:35: warning: initialization discards qualifiers from pointer target type
/bin/sh /opt/php-7.0.14/ext/cairo-php7/libtool --mode=compile cc -I. -I/opt/php-7.0.14/ext/cairo-php7 -DPHP_ATOM_INC -I/opt/php-7.0.14/ext/cairo-php7/include -I/opt/php-7.0.14/ext/cairo-php7/main -I/opt/php-7.0.14/ext/cairo-php7 -I/usr/local/php70/include/php -I/usr/local/php70/include/php/main -I/usr/local/php70/include/php/TSRM -I/usr/local/php70/include/php/Zend -I/usr/local/php70/include/php/ext -I/usr/local/php70/include/php/ext/date/lib -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DHAVE_CONFIG_H -g -O2 -c /opt/php-7.0.14/ext/cairo-php7/src/pattern.c -o src/pattern.lo
cc -I. -I/opt/php-7.0.14/ext/cairo-php7 -DPHP_ATOM_INC -I/opt/php-7.0.14/ext/cairo-php7/include -I/opt/php-7.0.14/ext/cairo-php7/main -I/opt/php-7.0.14/ext/cairo-php7 -I/usr/local/php70/include/php -I/usr/local/php70/include/php/main -I/usr/local/php70/include/php/TSRM -I/usr/local/php70/include/php/Zend -I/usr/local/php70/include/php/ext -I/usr/local/php70/include/php/ext/date/lib -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DHAVE_CONFIG_H -g -O2 -c /opt/php-7.0.14/ext/cairo-php7/src/pattern.c -fPIC -DPIC -o src/.libs/pattern.o
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c: In function ‘php_cairo_get_pattern_ce’:
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c:98: error: ‘CAIRO_PATTERN_TYPE_MESH’ undeclared (first use in this function)
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c:98: error: (Each undeclared identifier is reported only once
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c:98: error: for each function it appears in.)
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c:101: error: ‘CAIRO_PATTERN_TYPE_RASTER_SOURCE’ undeclared (first use in this function)
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c: In function ‘zim_CairoPatternMesh___construct’:
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c:778: warning: assignment makes pointer from integer without a cast
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c: In function ‘zim_CairoPatternMesh_getPath’:
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c:1048: warning: assignment makes pointer from integer without a cast
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c: In function ‘zm_startup_cairo_pattern’:
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c:1387: error: ‘CAIRO_PATTERN_TYPE_MESH’ undeclared (first use in this function)
/opt/php-7.0.14/ext/cairo-php7/src/pattern.c:1388: error: ‘CAIRO_PATTERN_TYPE_RASTER_SOURCE’ undeclared (first use in this function)
make: *** [src/pattern.lo] Error 1

memory leak / segmentation fault after ft_mem_free() when using freetype .

This error still exists, so i thought i give more detailed informations.

I am able to reproduce a memory leak with the following script:

<?php
$fontFile = dirname(__FILE__) . "/Vera.ttf";

$surface = new \CairoImageSurface(
    CairoFormat::ARGB32,
    750,
    750
);
$context = new \CairoContext( $surface );

try {
    $fontFaceObject = new \CairoFtFontFace($fontFile);
    //$fontFaceObject = cairo_ft_font_face_create($fontFile);
    $context->setFontFace( $fontFaceObject );
    $CairoFontMatrix = new \CairoMatrix();

    $CairoFontMatrix->scale( 12, 12 );

    for( $i = 0; $i < 10; ++$i ) {
        $angle = rand(1, 360);
        $CairoFontMatrix->rotate(deg2rad($angle));
        $context->setFontMatrix( $CairoFontMatrix );

        $x = rand(0, 750);
        $y = rand(0, 750);
        $context->MoveTo( $x, $y );
        $context->textPath( "blah" );

        $context->setSourceRgba(
            rand(0,255) / 255, rand(0,255) / 255, rand(0,255) / 255, 1 - rand(0,255) / 255
        );
        $context->fill();
    }

} catch (\CairoException $exc) {
    echo "<pre>";
    print_r($exc);
    print_r($fontFaceObject);
    echo $exc->getMessage();
    echo $exc->getTraceAsString();
    die();
}

header( "Content-Type: image/png" );
$surface->writeToPng( "php://output" );

unset($context);
unset($surface);
unset($fontFaceObject);

Fix the travis and appveyor builds on both branches

travis is not apparently building right in either branch, and appveyor is only building on the 7 branch
although I'm going to flip master to the 7 branch and archive current master as the 5 branch (need a release worthy port yet) the ci should still be building/testing on both branches

Current PHP7 status

  • Pattern enums
  • Pattern
  • Gradient
  • Linear
  • Radial
  • Solid
  • Surface
  • Raster
  • Mesh
  • Region
  • Surface
  • Matrix
  • Status
  • Versions
  • Types

New features added

  1. Matrices have their properties exposed and can be manipulated
  2. Mesh and raster pattern support ( not yet complete)
  3. Rectangles

Changes

  1. Namespaced
  2. License change
  3. Has extension dep
  4. Real enums

Odds and ends

  • Mesh Tests
  • Mesh Paths

PHP7 compiling error

Hi Elizabeth,
i got an error while compiling with PHP7 alpha2 on OpenSuse 13.2:

/bin/sh /usr/src/cairo/libtool --mode=compile cc  -I. -I/usr/src/cairo -DPHP_ATOM_INC -I/usr/src/cairo
/include -I/usr/src/cairo/main -I/usr/src/cairo -I/usr/local/include/php -I/usr/local/include/php/main -I/usr
/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include
/php/ext/date/lib -I/usr/local/include/cairo -I/usr/local/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib64
/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include
/libpng16  -DHAVE_CONFIG_H  -g -O2   -c /usr/src/cairo/src/cairo.c -o src/cairo.lo
mkdir src/.libs

 cc -I. -I/usr/src/cairo -DPHP_ATOM_INC -I/usr/src/cairo/include -I/usr/src/cairo/main -I/usr/src/cairo 
-I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include
/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local/include/cairo 
-I/usr/local/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1
 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -DHAVE_CONFIG_H -g -O2 -c 
/usr/src/cairo/src/cairo.c  -fPIC -DPIC -o src/.libs/cairo.o
make: *** No rule to make target '/usr/src/cairo/src/exception.c', needed by 'src/exception.lo'.  Stop.

Just FYI, please don't stress yourself, i only wanted trying it out, nothing more ☺️

memory leak with v0.3.2

Hi,
using php-fpm there seems to be a memory leak regarding FtFontFace

setFontFace( $fontFaceObject ); ?>

I found n-times the content of arial.ttf within allocated memory, where n equals number of requests.

therefore, the memory leak is directly related to sizeof($fontFaceObject) :-(

New PECL release

I'm currently only able to deploy version 0.3.2 via PECL, and I've encountered bugs which appear to have been fixed in the commits since that time (April 2012). Any chance of pushing a new release out?

Apply releases tags consistently

tl;dr -- this is a request to rename existing tags and include any missing versioned commits as new tags. Here's the table of tags with their respective commit hash and commit date:

Tag Abbrev Hash Commit Date
0.1.0-alpha 464c82f 2009-07-05
0.2.0-beta cff7f3e 2010-02-03
0.3.0-beta c1a3bd0 2011-12-28
0.3.1-beta 2b52581 2012-02-15
0.3.2-beta 04f689e 2012-04-21

You can also see this applied in my fork: https://github.com/jamesan/cairo/releases.


I'm packaging this software for Arch Linux's user-contributed package repo. Part of the package spec includes a derivation of the upstream version string. When the upstream source is a git repo, the standard derivation expects version strings to be managed using tagged releases.

I forked this repo, intending to make a pull request containing consistently named tags including any missing ones, but pull requests don't support pulling in tags. Tags can only be created by repo contributors, so can someone with write access please apply these few tags?

Thanks!

using enums with Cairo/Context not working anymore under php 7.1

Hi Elizabeth,

I wanted to try out cairo under php 7.1, but suddenly i got an error. Setting the Fillrule, Antialias (or any other enum) under php 7.0.x works fine, but under 7.1 it raises an TypeError :(

<?php

$surface = new \Cairo\Surface\Image(
    \Cairo\Surface\ImageFormat::ARGB32, 1, 1
);

$context = new \Cairo\Context($surface);

// var_dump( \Cairo\FillRule::EVEN_ODD );

try {
    $context->setFillRule( \Cairo\FillRule::EVEN_ODD );
    $context->setAntialias( \Cairo\Antialias::SUBPIXEL );
} catch (\TypeError $e) {
    echo $e->getMessage(), "\n";
}

gives me:
"Value 1 provided is not a const in enum Cairo\FillRule"

Please, can u take a look at it? I would be very appriciate.

Swen

PHP7 (PHPNG) compatibility

It would be great if this extension is compatible for the next generation of PHP. I know that it would take a few modifications. But if we all want to use this great extension in the future, and to not loose too much time before PHP7 gets widely used, compatibility has to be made for sure.

Value 1 provided is not a const in enum Cairo\Antialias

I'm in the process of working through the examples and re-factoring them to work with PHP 7. After updating the first example I believe I've encountered a bug.

The updated example can be found here and the error message after execution is:

PHP Fatal error:  Uncaught TypeError: Value 1 provided is not a const in enum Cairo\Antialias in /home/adam/cairo/examples/a1-image-sample.php:21
Stack trace:
#0 /home/adam/cairo/examples/a1-image-sample.php(21): Cairo\Context->setAntialias(1)
#1 {main}
  thrown in /home/adam/cairo/examples/a1-image-sample.php on line 21

PHP 8 compatibility

Hello everybody. Since PHP 8 was released last year, maybe some are looking for a port of the cairo-extension for PHP.
Here it is! It took quite a bit of work, but now it's finished after all.

I've created a fork and a new branch. The code can be found here:
https://github.com/swen100/cairo

What have I done:

  • Ported to PHP8
  • full rewrite of all tests and added tests for new methods
  • added support for direct raster-output in format JPEG
  • added 17 methods and class-constants to Cairo\Region (cairo 1.10)
  • added 7 methods and class-constants to Cairo\Surface\Pdf (cairo 1.12, 1.16)
  • added 2 methods and class-constants to Cairo\Surface\Svg (cairo 1.16)
  • added 1 method to Cairo\Surface\Recording (cairo 1.12)
  • added 5 methods to Cairo\Surface (cairo 1.12 and 1.14)

I would be happy if someone in charge and with access to the project could make a php8-branch in the original project to be able to take over the code from my branch.

Btw, the extension needed for cairo (datastructures) was also adapted to work with PHP 8 and can be found here:
https://github.com/swen100/structures

Many greetings, Swen

Compile error

Hello,

I'm getting error when I try to compile. I'm running Ubuntu 16.04 with php 7.0.8. I complied and installed eosforphp/datastructures first. Thank you in advance.

/bin/bash /tmp/cairo/libtool --mode=compile cc -I. -I/tmp/cairo -DPHP_ATOM_INC -I/tmp/cairo/include -I/tmp/cairo/main -I/tmp/cairo -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DHAVE_CONFIG_H -g -O2 -c /tmp/cairo/cairo.c -o cairo.lo
libtool: compile: cc -I. -I/tmp/cairo -DPHP_ATOM_INC -I/tmp/cairo/include -I/tmp/cairo/main -I/tmp/cairo -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DHAVE_CONFIG_H -g -O2 -c /tmp/cairo/cairo.c -fPIC -DPIC -o .libs/cairo.o
In file included from /tmp/cairo/cairo.c:32:0:
/tmp/cairo/php_cairo.h:541:8: error: unknown type name ‘zend_object_value’
extern zend_object_value cairo_surface_object_new(zend_class_entry *ce TSRMLS_DC);
^
In file included from /tmp/cairo/cairo.c:32:0:
/tmp/cairo/php_cairo.h:548:8: error: unknown type name ‘zend_object_value’
extern zend_object_value cairo_font_face_object_new(zend_class_entry *ce TSRMLS_DC);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.