Typo ;)
[phpCairo.git] / testcases / phpCairo / font-matrix-translation.php
blob8ac11a51b13a5bb531fda15474f3b205f8df06c2
1 <?
2 function box_text($str, $x, $y)
4 global $con;
5 $con->save();
6 $ext = $con->text_extents($str);
7 $sf = $con->get_scaled_font();
8 $sext = $sf->text_extents("text");
9 $lw = $con->get_line_width();
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->move_to($x,$y);
13 $con->show_text($str);
14 $con->restore();
16 $sur = new CairoImageSurface(FORMAT_ARGB32, 38, 34);
17 $con = new CairoContext($sur);
19 $con->set_source_rgb(1,1,1);
20 $con->paint();
22 $con->select_font_face("Bitstream Vera Sans");
23 $con->set_font_size(12);
24 $con->translate(4,4);
25 $con->set_line_width(1);
26 $ext = $con->text_extents("text");
28 $con->set_source_rgb(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->set_font_matrix($mat);
34 $con->set_source_rgb(0,0,1);
35 box_text("text", 0, -$ext["y_bearing"]);
37 $sur->write_to_png("font-matrix-translation-php.png");