An XHTML renderering engine. More...
#include <Wt/Render/WTextRenderer>
Public Member Functions | |
virtual | ~WTextRenderer () |
Destructor. | |
double | render (const WString &text, double y=0) |
Renders an XHTML fragment. | |
double | textWidth (int page) const |
Returns the page text width. | |
double | textHeight (int page) const |
Returns the page text height. | |
void | setFontScale (double scale) |
Sets the scaling factor used for font rendering. | |
double | fontScale () const |
Returns the font scaling factor. | |
virtual double | pageWidth (int page) const =0 |
Returns the page width. | |
virtual double | pageHeight (int page) const =0 |
Returns the page height. | |
virtual double | margin (Side side) const =0 |
Returns the margin. | |
virtual WPaintDevice * | startPage (int page)=0 |
Returns a paint device to render a given page. | |
virtual void | endPage (WPaintDevice *device)=0 |
Stops painting on the given page. | |
Protected Member Functions | |
WTextRenderer () | |
Constructor. |
An XHTML renderering engine.
This class implements a rendering engine for a (subset of) XHTML. Its intended use is to be able to accurately render the output of the WTextEdit widget (although it handles a more general subset of XHTML than is required to do just that). Its focus is on high-quality rendering of text-like contents.
The following are the main features:
Some of the main limitations are:
This class is an abstract class. A concrete class implements the pure virtual methods to create an appropriate WPaintDevice for each page and to provide page dimension information. The paint device needs to support font metrics, which currently is only implemented by WPdfImage.
All coordinates and dimensions used by this class are pixel coordinates.
double Wt::Render::WTextRenderer::fontScale | ( | ) | const |
Returns the font scaling factor.
virtual double Wt::Render::WTextRenderer::margin | ( | Side | side ) | const [pure virtual] |
Returns the margin.
Returns the margin at given side (in pixel units).
Implemented in Wt::Render::WPdfRenderer.
virtual double Wt::Render::WTextRenderer::pageHeight | ( | int | page ) | const [pure virtual] |
Returns the page height.
Returns the total page height (in pixel units), including vertical margins.
Implemented in Wt::Render::WPdfRenderer.
virtual double Wt::Render::WTextRenderer::pageWidth | ( | int | page ) | const [pure virtual] |
Returns the page width.
Returns the total page width (in pixel units), including horizontal margins.
Implemented in Wt::Render::WPdfRenderer.
double Wt::Render::WTextRenderer::render | ( | const WString & | text, |
double | y = 0 |
||
) |
Renders an XHTML fragment.
The text is rendered, starting at position y
, and flowing down the page If necessary, new pages are created using startPage()
to render more contents on a next page. The return value is the position at which rendering stopped on the last page on which was rendered.
This y
position and returned position are text coordinates, which differ from page coordinates in that they exclude margins.
The function returns the end position. You may call this function multiple times.
Each invocation to render() has the effect of resetting the logical page numbering used by pageWidth(), pageHeight() and startPage() so that the current page is page 0.
void Wt::Render::WTextRenderer::setFontScale | ( | double | scale ) |
Sets the scaling factor used for font rendering.
A scaling can be set for text. The scaling factor has as effect that text font sizes are modified by the scale. Also CSS length units that are defined in terms of font units ("em" and "ex") are scaled accordingly.
The default value is 1.
virtual WPaintDevice* Wt::Render::WTextRenderer::startPage | ( | int | page ) | [pure virtual] |
Returns a paint device to render a given page.
The render() method calls this function once for each page it wants to render.
Implemented in Wt::Render::WPdfRenderer.
double Wt::Render::WTextRenderer::textHeight | ( | int | page ) | const |
Returns the page text height.
This returns the height of the page in which text needs to be rendered, excluding vertical margins, in pixels.
double Wt::Render::WTextRenderer::textWidth | ( | int | page ) | const |
Returns the page text width.
This returns the width of the page in which text needs to be rendered, excluding horizontal margins, in pixels.