Text

Text is specified by a size and a string (for now, not all cairo's text handling features are exposed, such as setting the font).

A text object is drawn such that the shape's (x,y) coordinate defines the lower-left corner of the text area.

The following contains an example that will add a text string to a canvas.

The blue lines represent the x and y axes, and show through since an alpha value of 0.9 is used.

text.png

Text drawn by example code below

void add_text( Papyrus::Canvas& canvas ) {
  // Create a text object
  Papyrus::Text::pointer text = Papyrus::Text::create("Text", 40);

  // Add the text to the canvas
  canvas.add( text );

  // Set the fill color to red, with an alpha value of 0.9
  text->set_fill( Cairo::SolidPattern::create_rgba(0.0, 1.0, 0.0, 0.9) );

  // To color the lines of a text shape, set the outline pattern
  text->set_outline( Cairo::SolidPattern::create_rgba(0.0, 0.0, 0.0, 0.9) );
}

Generated on Sun Mar 11 10:01:28 2007 by  doxygen 1.5.1