TextRender

class mono::display::TextRender

Text Render class to paint Text paragraphs on a DisplayController.

This is a Text glyph and paragraph render. It uses a bitmap based fonts and typesets the text to provide.

You need to provide the text render with either a DisplayPainter or IDisplayController that serves as a target for the text rendering.

The TextRender does not include any Font definitions. When you render your text, you need to provide a pointer to the MonoFont structure, that should by used as the rendered font.

This renderer has a palette like DisplayPainter, and uses it the blend the semi-transparent pixels in the font anti-aliasing. The font bitmap defines pixel intensities, that are the foreground opacity.

The Font defines the text size and the anti-aliasing quality. Some fonts has 2 bit pixels, others have 4 bit pixels.

Public Functions

TextRender(IDisplayController *displayCtrl = 0)

Construct a TextRender that renders to a DisplayController Text Colors default to View::Standard colors.

Parameters
  • displayCtrl: A pointer to the display controller that is the render target

TextRender(IDisplayController *displayCtrl, Color foreground, Color background)

Construct a TextRender that renders to a DisplayController You provide explicit text colors.

Parameters
  • displayCtrl: A pointer to the display controller that is the render target
  • foreground: The text color
  • background: the background color

TextRender(const DisplayPainter &painter)

Construct a TextRender that renders to the DisplayController provided by a DisplayPainter. The painter current pencil colors are used for the text color.

Parameters
  • painter: The display painter to copy DisplayController and color palette from

void drawInRect(geo::Rect rect, String text, const MonoFont &fontFace)

Renders a text string in a provided Rectangle.

THis method paints / renders the text in bounding rectangle. The text is always rendered with origin in the rectangles top left corner. If the provided Rect is not large enough, the text is clipped!

Parameters
  • rect: The rectangle to render in
  • text: The text string to render
  • fontFace: A pointer the fontface to use

mono::geo::Size renderDimension(String text, const MonoFont &fontFace)

Return the resulting dimension / size of some rendered text.

The final width and height of a rendered text, with the defined font face.

void setForeground(Color fg)

MARK: Accessors.

Set the text color

void setBackground(Color bg)

Set the background color. Transparent pixels will be blended with this color.

Color Foreground() const

Get the current text color.

Color Background() const

Get the current text background color.

Protected Functions

void drawChar(geo::Point position, char character, const MonoFont &font, geo::Rect const &boundingRect)

Render a single character

void writePixel(uint8_t intensity, bool bg = false)

Blend and emit a single pixel to the DisplayController.