QCAD
Open Source 2D CAD
RTextRenderer Class Reference

Copyright (c) 2011-2016 by Andrew Mustun. More...

#include <RTextRenderer.h>

Public Types

enum  Target { PainterPaths = 0x01, RichText = 0x02 }
 

Public Member Functions

RBox getBoundingBox () const
 
double getHeight () const
 
QList< RPainterPathgetPainterPaths () const
 
QString getRichText () const
 
QList< RTextLayoutgetTextLayouts () const
 
double getWidth () const
 
void render ()
 Renders the text data into painter paths. More...
 
void renderSimple ()
 Renders the text data into painter paths. More...
 
 RTextRenderer (const RTextBasedData &textData, bool draft, RTextRenderer::Target target, double fontHeightFactor=1.0)
 

Static Public Attributes

static QChar chDegree = QChar(0x00b0)
 Copyright (c) 2011-2016 by Andrew Mustun. More...
 
static QChar chDiameter = QChar(0x00f8)
 
static QChar chPlusMinus = QChar(0x00b1)
 
static QString escDegree = "%%d"
 
static QString escDiameter = "%%c"
 
static QString escPlusMinus = "%%p"
 
static QString rxAlignmentCenter = "\\\\pxqc;"
 
static QString rxAlignmentChange = "\\\\A(\\d+);"
 
static QString rxAlignmentLeft = "\\\\pxql;"
 
static QString rxAlignmentRight = "\\\\pxqr;"
 
static QString rxAll
 
static QString rxBackslash = "\\\\\\\\"
 
static QString rxBeginBlock = "\\{"
 
static QString rxColorChangeCustom ="\\\\c(\\d+);"
 
static QString rxColorChangeIndex = "\\\\C(\\d+);"
 
static QString rxCurlyClose = "\\\\\\}"
 
static QString rxCurlyOpen = "\\\\\\{"
 
static QString rxDegree = "%%[dD]"
 
static QString rxDiameter = "%%[cC]"
 
static QString rxEndBlock = "\\}"
 
static QString rxFontChangeCad = "(?:\\\\F([^|]*)\\|c(\\d+);|\\\\F([^|;]*);)"
 
static QString rxFontChangeTtf
 
static QString rxHeightChange = "\\\\H(\\d*\\.?\\d+)(x?);"
 
static QString rxLineFeed = "\\\\p(?:x?i(\\d*\\.?\\d+);)?"
 
static QString rxNonBreakingSpace = "\\\\~"
 
static QString rxObliqueAngleChange = "\\\\Q(\\d*\\.?\\d+);"
 
static QString rxOverlineOff = "\\\\o"
 
static QString rxOverlineOn = "\\\\O"
 
static QString rxParagraphFeed = "\\\\P"
 
static QString rxPlusMinus = "%%[pP]"
 
static QString rxStackedText = "\\\\S([^^]*)\\^([^;]*);"
 
static QString rxTrackChange = "\\\\T(\\d*\\.?\\d+);"
 
static QString rxUnderlined = "%%[uU]"
 
static QString rxUnderlineOff = "\\\\l"
 
static QString rxUnderlineOn = "\\\\L"
 
static QString rxUnicode = "\\\\[Uu]\\+([0-9a-fA-F]{4})"
 
static QString rxWidthChange = "\\\\W(\\d*\\.?\\d+);"
 
static QString rxXFeed = "\\\\X"
 

Private Member Functions

bool getBlockBold () const
 
QString getBlockFont () const
 
QString getBlockFontFile () const
 
double getBlockHeight () const
 
bool getBlockItalic () const
 
QRectF getCharacterRect (const QString &fontName, const QChar &ch) const
 
QRectF getCharacterRect (const QFont &font, const QChar &ch) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QTextCharFormat getCurrentFormat () const
 
QList< RPainterPathgetPainterPathsForBlock (const QString &blockText, const QList< QTextLayout::FormatRange > &formats, double &horizontalAdvance, double &horizontalAdvanceNoSpacing, double &ascent, double &descent)
 
QList< RPainterPathgetPainterPathsForBlockCad (const QString &blockText, const QList< QTextLayout::FormatRange > &formats, double &horizontalAdvance, double &horizontalAdvanceNoSpacing, double &ascent, double &descent)
 
QList< RPainterPathgetPainterPathsForBlockTtf (const QString &blockText, const QList< QTextLayout::FormatRange > &formats, double &horizontalAdvance, double &horizontalAdvanceNoSpacing, double &ascent, double &descent)
 
QString getRichTextForBlock (const QString &blockText, const QList< QTextLayout::FormatRange > &formats)
 
bool getUseCadFont () const
 
void preparePath (RPainterPath &path, const RColor &color, double cursor, double cxfScale)
 
void setBlockBold (bool on)
 
void setBlockFont (const QString &f)
 
void setBlockFontFile (const QString &f)
 
void setBlockHeight (double h)
 
void setBlockItalic (bool on)
 
void setCurrentFormat (QTextCharFormat f)
 
void setUseCadFont (bool on)
 

Private Attributes

QStack< bool > blockBold
 
QStack< QString > blockFont
 
QStack< QString > blockFontFile
 
QStack< double > blockHeight
 
QStack< bool > blockItalic
 
RBox boundingBox
 
QStack< QTextCharFormat > currentFormat
 
bool draft
 
double fontHeightFactor
 
double height
 
QList< QTransform > lineBlockTransforms
 
QStack< QStringList > openTags
 
QList< RPainterPathpainterPaths
 
QString richText
 
Target target
 
const RTextBasedDatatextData
 
QList< RTextLayouttextLayouts
 
QStack< bool > useCadFont
 
double width
 

Detailed Description

Copyright (c) 2011-2016 by Andrew Mustun.

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD. Renders formatted text into painter paths.

Scriptable:
This class is available in script environments.

Constructor & Destructor Documentation

RTextRenderer::RTextRenderer ( const RTextBasedData textData,
bool  draft,
RTextRenderer::Target  target,
double  fontHeightFactor = 1.0 
)

Member Function Documentation

bool RTextRenderer::getBlockBold ( ) const
inlineprivate
QString RTextRenderer::getBlockFont ( ) const
inlineprivate
QString RTextRenderer::getBlockFontFile ( ) const
inlineprivate
double RTextRenderer::getBlockHeight ( ) const
inlineprivate
bool RTextRenderer::getBlockItalic ( ) const
inlineprivate
RBox RTextRenderer::getBoundingBox ( ) const
inline
QRectF RTextRenderer::getCharacterRect ( const QString &  fontName,
const QChar &  ch 
) const
private
Returns
Bounding box of the given character with the given font in size '1', rendered at 0/0. Used to find out the CAD relevant height, ascent and descent of the font.
QRectF RTextRenderer::getCharacterRect ( const QFont &  font,
const QChar &  ch 
) const
private

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

QTextCharFormat RTextRenderer::getCurrentFormat ( ) const
inlineprivate
double RTextRenderer::getHeight ( ) const
inline
QList<RPainterPath> RTextRenderer::getPainterPaths ( ) const
inline
QList< RPainterPath > RTextRenderer::getPainterPathsForBlock ( const QString &  blockText,
const QList< QTextLayout::FormatRange > &  formats,
double &  horizontalAdvance,
double &  horizontalAdvanceNoSpacing,
double &  ascent,
double &  descent 
)
private
QList< RPainterPath > RTextRenderer::getPainterPathsForBlockCad ( const QString &  blockText,
const QList< QTextLayout::FormatRange > &  formats,
double &  horizontalAdvance,
double &  horizontalAdvanceNoSpacing,
double &  ascent,
double &  descent 
)
private
Returns
Painter paths for the given text block in CAD font, positioned at 0/0 (bottom left corner) and with a font size of 1 drawing unit.
QList< RPainterPath > RTextRenderer::getPainterPathsForBlockTtf ( const QString &  blockText,
const QList< QTextLayout::FormatRange > &  formats,
double &  horizontalAdvance,
double &  horizontalAdvanceNoSpacing,
double &  ascent,
double &  descent 
)
private
Returns
Painter paths for the given text block in TTF font, positioned at 0/0 (bottom left corner) and with a font size of 1 drawing unit.
QString RTextRenderer::getRichText ( ) const
inline
QString RTextRenderer::getRichTextForBlock ( const QString &  blockText,
const QList< QTextLayout::FormatRange > &  formats 
)
private
QList<RTextLayout> RTextRenderer::getTextLayouts ( ) const
inline
bool RTextRenderer::getUseCadFont ( ) const
inlineprivate
double RTextRenderer::getWidth ( ) const
inline
void RTextRenderer::preparePath ( RPainterPath path,
const RColor color,
double  cursor,
double  cxfScale 
)
private
void RTextRenderer::render ( )

Renders the text data into painter paths.

void RTextRenderer::renderSimple ( )

Renders the text data into painter paths.

void RTextRenderer::setBlockBold ( bool  on)
inlineprivate
void RTextRenderer::setBlockFont ( const QString &  f)
inlineprivate
void RTextRenderer::setBlockFontFile ( const QString &  f)
inlineprivate
void RTextRenderer::setBlockHeight ( double  h)
inlineprivate
void RTextRenderer::setBlockItalic ( bool  on)
inlineprivate
void RTextRenderer::setCurrentFormat ( QTextCharFormat  f)
inlineprivate
void RTextRenderer::setUseCadFont ( bool  on)
inlineprivate

Member Data Documentation

QStack<bool> RTextRenderer::blockBold
private
QStack<QString> RTextRenderer::blockFont
private
QStack<QString> RTextRenderer::blockFontFile
private
QStack<double> RTextRenderer::blockHeight
private
QStack<bool> RTextRenderer::blockItalic
private
RBox RTextRenderer::boundingBox
private
QChar RTextRenderer::chDegree = QChar(0x00b0)
static

Copyright (c) 2011-2016 by Andrew Mustun.

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

QChar RTextRenderer::chDiameter = QChar(0x00f8)
static
QChar RTextRenderer::chPlusMinus = QChar(0x00b1)
static
QStack<QTextCharFormat> RTextRenderer::currentFormat
private
bool RTextRenderer::draft
private
QString RTextRenderer::escDegree = "%%d"
static
QString RTextRenderer::escDiameter = "%%c"
static
QString RTextRenderer::escPlusMinus = "%%p"
static
double RTextRenderer::fontHeightFactor
private
double RTextRenderer::height
private
QList<QTransform> RTextRenderer::lineBlockTransforms
private
QStack<QStringList> RTextRenderer::openTags
private
QList<RPainterPath> RTextRenderer::painterPaths
private
QString RTextRenderer::richText
private
QString RTextRenderer::rxAlignmentCenter = "\\\\pxqc;"
static
QString RTextRenderer::rxAlignmentChange = "\\\\A(\\d+);"
static
QString RTextRenderer::rxAlignmentLeft = "\\\\pxql;"
static
QString RTextRenderer::rxAlignmentRight = "\\\\pxqr;"
static
QString RTextRenderer::rxAll
static
QString RTextRenderer::rxBackslash = "\\\\\\\\"
static
QString RTextRenderer::rxBeginBlock = "\\{"
static
QString RTextRenderer::rxColorChangeCustom ="\\\\c(\\d+);"
static
QString RTextRenderer::rxColorChangeIndex = "\\\\C(\\d+);"
static
QString RTextRenderer::rxCurlyClose = "\\\\\\}"
static
QString RTextRenderer::rxCurlyOpen = "\\\\\\{"
static
QString RTextRenderer::rxDegree = "%%[dD]"
static
QString RTextRenderer::rxDiameter = "%%[cC]"
static
QString RTextRenderer::rxEndBlock = "\\}"
static
QString RTextRenderer::rxFontChangeCad = "(?:\\\\F([^|]*)\\|c(\\d+);|\\\\F([^|;]*);)"
static
QString RTextRenderer::rxFontChangeTtf
static
Initial value:
= "\\\\f([^|]*)"
"(?:\\|([bicp])(\\d+))?"
"(?:\\|([bicp])(\\d+))?"
"(?:\\|([bicp])(\\d+))?"
"(?:\\|([bicp])(\\d+))?"
";"
QString RTextRenderer::rxHeightChange = "\\\\H(\\d*\\.?\\d+)(x?);"
static
QString RTextRenderer::rxLineFeed = "\\\\p(?:x?i(\\d*\\.?\\d+);)?"
static
QString RTextRenderer::rxNonBreakingSpace = "\\\\~"
static
QString RTextRenderer::rxObliqueAngleChange = "\\\\Q(\\d*\\.?\\d+);"
static
QString RTextRenderer::rxOverlineOff = "\\\\o"
static
QString RTextRenderer::rxOverlineOn = "\\\\O"
static
QString RTextRenderer::rxParagraphFeed = "\\\\P"
static
QString RTextRenderer::rxPlusMinus = "%%[pP]"
static
QString RTextRenderer::rxStackedText = "\\\\S([^^]*)\\^([^;]*);"
static
QString RTextRenderer::rxTrackChange = "\\\\T(\\d*\\.?\\d+);"
static
QString RTextRenderer::rxUnderlined = "%%[uU]"
static
QString RTextRenderer::rxUnderlineOff = "\\\\l"
static
QString RTextRenderer::rxUnderlineOn = "\\\\L"
static
QString RTextRenderer::rxUnicode = "\\\\[Uu]\\+([0-9a-fA-F]{4})"
static
QString RTextRenderer::rxWidthChange = "\\\\W(\\d*\\.?\\d+);"
static
QString RTextRenderer::rxXFeed = "\\\\X"
static
Target RTextRenderer::target
private
const RTextBasedData& RTextRenderer::textData
private
QList<RTextLayout> RTextRenderer::textLayouts
private
QStack<bool> RTextRenderer::useCadFont
private
double RTextRenderer::width
private

The documentation for this class was generated from the following files: