Changed the entire file structure to remove the .c includes from cairo.c
[phpCairo.git] / testcases / phpCairo / font-matrix-translation.php
blob59d94ee320f7303874de02ce816652a6b8e0aedb
1 <?
2 function box_text($str, $x, $y)
4 global $con;
5 $con->save();
6 $ext = $con->textExtents($str);
7 $sf = $con->getScaledFont();
8 $sext = $sf->textExtents("text");
9 $lw = $con->getLineWidth();
10 $con->rectangle($x + $ext["x_bearing"]-$lw/2, $y + $ext["y_bearing"] - $lw/2, $ext["width"]+$lw, $ext["height"]+ $lw);
11 $con->stroke();
12 $con->moveTo($x,$y);
13 $con->showText($str);
14 $con->restore();
16 $sur = new CairoImageSurface(FORMAT_ARGB32, 38, 34);
17 $con = new CairoContext($sur);
19 $con->setSourceRgb(1,1,1);
20 $con->paint();
22 $con->selectFontFace("Bitstream Vera Sans");
23 $con->setFontSize(12);
24 $con->translate(4,4);
25 $con->setLineWidth(1);
26 $ext = $con->textExtents("text");
28 $con->setSourceRgb(0,0,0);
29 box_text("text", 0, -$ext["y_bearing"]);
30 $mat = new CairoMatrix();
31 $mat->translate(6,16);
32 $mat->scale(12,12);
33 $con->setFontMatrix($mat);
34 $con->setSourceRgb(0,0,1);
35 box_text("text", 0, -$ext["y_bearing"]);
37 $sur->writeToPng("font-matrix-translation-php.png");