papyrus logo


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 drawn by example code below

void add_text( Papyrus::Canvas::pointer 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( Papyrus::RGBA(0.0, 1.0, 0.0, 0.9) );

  // To color the lines of a text shape, set the stroke paint
  text->set_stroke( Papyrus::RGBA(0.0, 0.0, 0.0, 0.9) );

Generated on Fri Apr 16 12:41:04 2010 for papyrus by doxygen 1.6.1