MCPcopy Create free account
hub / github.com/cinder/Cinder / run

Method run

test/cairoTest/cairoTest.cpp:416–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414// text align center
415struct 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

Callers

nothing calls this directly

Calls 13

selectFontFaceMethod · 0.80
setFontSizeMethod · 0.80
textExtentsMethod · 0.80
heightMethod · 0.80
showTextMethod · 0.80
setSourceRgbaMethod · 0.80
setLineWidthMethod · 0.80
relLineToMethod · 0.80
strokeMethod · 0.80
widthMethod · 0.45
moveToMethod · 0.45
arcMethod · 0.45

Tested by

no test coverage detected