| 414 | // text align center |
| 415 | struct TestTextAlignCenter : public TestBase { |
| 416 | virtual void run( fli::cairo::Context &ctx ) { |
| 417 | const std::string text = "cairo"; |
| 418 | double x,y; |
| 419 | |
| 420 | ctx.selectFontFace( "Sans", fli::cairo::FONT_SLANT_NORMAL, fli::cairo::FONT_WEIGHT_NORMAL ); |
| 421 | |
| 422 | ctx.setFontSize( 52.0 ); |
| 423 | fli::cairo::TextExtents extents = ctx.textExtents( text ); |
| 424 | x = 128.0 - ( extents.width() / 2 + extents.xBearing() ); |
| 425 | y = 128.0 - ( extents.height() / 2 + extents.yBearing() ); |
| 426 | |
| 427 | ctx.moveTo( x, y ); |
| 428 | ctx.showText( text ); |
| 429 | |
| 430 | // draw helping lines |
| 431 | ctx.setSourceRgba( 1, 0.2, 0.2, 0.6 ); |
| 432 | ctx.setLineWidth( 6.0 ); |
| 433 | ctx.arc( x, y, 10.0, 0, 2 * M_PI ); |
| 434 | ctx.fill(); |
| 435 | ctx.moveTo( 128.0, 0 ); |
| 436 | ctx.relLineTo( 0, 256 ); |
| 437 | ctx.moveTo( 0, 128.0 ); |
| 438 | ctx.relLineTo( 256, 0 ); |
| 439 | ctx.stroke(); |
| 440 | } |
| 441 | }; |
| 442 | |
| 443 | // text extents |
nothing calls this directly
no test coverage detected