| 443 | // text extents |
| 444 | struct TestTextExtents : public TestBase { |
| 445 | virtual void run( fli::cairo::Context &ctx ) { |
| 446 | const std::string text = "cairo"; |
| 447 | double x,y; |
| 448 | |
| 449 | ctx.selectFontFace( "Sans", fli::cairo::FONT_SLANT_NORMAL, fli::cairo::FONT_WEIGHT_NORMAL ); |
| 450 | |
| 451 | ctx.setFontSize( 100.0 ); |
| 452 | fli::cairo::TextExtents extents = ctx.textExtents( text ); |
| 453 | x = 25.0; |
| 454 | y = 150.0; |
| 455 | |
| 456 | ctx.moveTo( x, y ); |
| 457 | ctx.showText( text ); |
| 458 | |
| 459 | // draw helping lines |
| 460 | ctx.setSourceRgba( 1, 0.2, 0.2, 0.6 ); |
| 461 | ctx.setLineWidth( 6.0 ); |
| 462 | ctx.arc( x, y, 10.0, 0, 2 * M_PI ); |
| 463 | ctx.fill(); |
| 464 | ctx.moveTo( x, y ); |
| 465 | ctx.relLineTo( 0, -extents.height() ); |
| 466 | ctx.relLineTo( extents.width(), 0 ); |
| 467 | ctx.relLineTo( extents.xBearing(), -extents.yBearing() ); |
| 468 | ctx.stroke(); |
| 469 | } |
| 470 | }; |
| 471 | |
| 472 | int main( int argc, char **argv ) |
nothing calls this directly
no test coverage detected