JKQTPlotter
an extensive Qt4/Qt5 Plotter framework (including a fast variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
JKQTMathText Class Reference

this class parses a LaTeX string and can then draw the contained text/equation onto a QPainter More...

#include <jkqtmathtext.h>

Inheritance diagram for JKQTMathText:
Collaboration diagram for JKQTMathText:

Classes

struct  FontDefinition
 summarizes all information available on a font for a specific MTenvironmentFont More...
 
class  MTbraceNode
 subclass representing a brace node More...
 
class  MTdecoratedNode
 subclass representing a decorated text m (e.g. \vec \hat ...) node More...
 
struct  MTenvironment
 describes the current drawing environment (base fontname ...) More...
 
class  MTfracNode
 subclass representing a \frac node More...
 
class  MTinstruction1Node
 subclass representing an instruction node with exactly one argument in the syntax tree More...
 
class  MTlistNode
 subclass representing a list of nodes in the syntax tree More...
 
class  MTmatrixNode
 subclass representing a \begin{matrix} node More...
 
class  MTnode
 subclass representing one node in the syntax tree More...
 
struct  MTnodeSize
 beschreibt die Größe eines Knotens More...
 
class  MTplainTextNode
 subclass representing one text node in the syntax tree More...
 
class  MTsqrtNode
 subclass representing a sqrt node More...
 
class  MTsubscriptNode
 subclass representing an subscript node with exactly one argument in the syntax tree More...
 
class  MTsuperscriptNode
 subclass representing an superscript node with exactly one argument in the syntax tree More...
 
class  MTsymbolNode
 subclass representing one symbol (e.g. \alpha , \cdot ...) node in the syntax tree More...
 
class  MTtextNode
 subclass representing one text node in the syntax tree More...
 
class  MTwhitespaceNode
 subclass representing one whitepsace node in the syntax tree More...
 
struct  tbrData
 
struct  tbrDataH
 

Public Types

enum  FontSubclass {
  FontSubclass::Text,
  FontSubclass::Default =Text,
  FontSubclass::Symbols,
  FontSubclass::Greek
}
 
enum  MTdecoration {
  MTDvec,
  MTDhat,
  MTDdot,
  MTDddot,
  MTDbar,
  MTDarrow,
  MTDoverline,
  MTDdoubleoverline,
  MTDunderline,
  MTDdoubleunderline,
  MTDtilde
}
 
enum  MTenvironmentFont {
  MTEroman,
  MTEsans,
  MTEmathRoman,
  MTEmathSans,
  MTEtypewriter,
  MTEscript,
  MTEblackboard,
  MTEcaligraphic,
  MTEfraktur,
  MTenvironmentFontCount
}
 the available logical fonts (default is MTEroman)
More...
 
enum  MTfontEncoding {
  MTFEwinSymbol,
  MTFEunicode,
  MTFEunicodeLimited,
  MTFEStandard
}
 used to specify the font encoding used for drawing More...
 
enum  MTfracMode {
  MTFMfrac,
  MTFMdfrac,
  MTFMtfrac,
  MTFMsfrac,
  MTFMstfrac,
  MTFMunderbrace,
  MTFMoverbrace,
  MTFMstackrel,
  MTFMunderset,
  MTFMoverset
}
 

Public Member Functions

 JKQTMathText (QObject *parent=nullptr)
 class constructor More...
 
 ~JKQTMathText ()
 class destructor More...
 
void addReplacementFont (const QString &nonUseFont, const QString &useFont)
 add a font pair to the table with font replacements More...
 
void addReplacementFont (const QString &nonUseFont, const QString &useFont, MTfontEncoding useFontEncoding)
 add a font pair to the table with font replacements More...
 
void draw (QPainter &painter, double x, double y, bool drawBoxes=false)
 draw a representation to the QPainter object at the specified position More...
 
void draw (QPainter &painter, unsigned int flags, QRectF rect, bool drawBoxes=false)
 overloaded version of draw(QPainter& painter, double x, double y). More...
 
double getAscent (QPainter &painter)
 return the ascentt, i.e. the distance from the baseline to the highest part of the representation More...
 
double getBraceFactor () const
 resizing factor for braces in math mode More...
 
double getBraceShrinkFactor () const
 shrinking the width of braces in math mode 0: reduce to 0 pixel width, 1: leave unchanged More...
 
double getBraceYShiftFactor () const
 fraction of the brace ascent that the brace is shifted downwards, when scaled More...
 
double getDecorationHeightFactor () const
 size of the decorations (dot, tilde, ...), as fractio of the baselineheight More...
 
double getDescent (QPainter &painter)
 return the descent, i.e. the distance from the baseline to the lowest part of the representation More...
 
QStringList getErrorList () const
 a list that will be filled with error messages while parsing, if any error occur More...
 
bool getExpensiveRendering () const
 switches on some options that will grant better rendering at the expense of higher time consumption More...
 
QString getFontBlackboard () const
 retrieves the font to be used for text in the logical font MTEblackboard
More...
 
QString getFontCaligraphic () const
 retrieves the font to be used for text in the logical font MTEcaligraphic
More...
 
QColor getFontColor () const
 font color More...
 
QPair< QString, MTfontEncodinggetFontData (MTenvironmentFont font, bool in_math_environment=false, FontSubclass subclass=FontSubclass::Default) const
 retrieve the font and encoding to be used for font, which might optionally be typeset inside a math environment, specified by in_math_environment, possibly for the given font subclass subclass More...
 
MTfontEncoding getFontEncodingBlackboard () const
 retrieves the encoding used for the blackboard font More...
 
JKQTMathText::MTfontEncoding getFontEncodingCaligraphic () const
 retrieves the encoding used for the caligraphic font More...
 
MTfontEncoding getFontEncodingFraktur () const
 retrieves the encoding used for the Fraktur font More...
 
MTfontEncoding getFontEncodingMathRoman () const
 retrieves the encoding used for the math-mode roman font More...
 
MTfontEncoding getFontEncodingMathSans () const
 retrieves the encoding used for the math-mode sans-serif font More...
 
MTfontEncoding getFontEncodingRoman () const
 retrieves the encoding used for the roman font More...
 
MTfontEncoding getFontEncodingSans () const
 retrieves the encoding used for the sans-serif font More...
 
MTfontEncoding getFontEncodingScript () const
 retrieves the encoding used for the script font More...
 
MTfontEncoding getFontEncodingTypewriter () const
 retrieves the encoding used for the typewriter font More...
 
QString getFontFraktur () const
 retrieves the font to be used for text in the logical font MTEfraktur
More...
 
QString getFontMathRoman () const
 retrieves the font to be used for text in the logical font MTEroman
More...
 
QString getFontMathSans () const
 retrieves the font to be used for text in the logical font MTEsans
More...
 
QString getFontRoman () const
 retrieves the font to be used for text in the logical font MTEroman
More...
 
QString getFontSans () const
 retrieves the font to be used for text in the logical font MTEsans
More...
 
QString getFontScript () const
 retrieves the font to be used for text in the logical font MTEscript
More...
 
double getFontSize () const
 base font size in points More...
 
QString getFontTypewriter () const
 retrieves the font to be used for text in the logical font MTEtypewriter
More...
 
double getFracFactor () const
 scaling factor for font of nominator and denominator of a fraction More...
 
double getFracShiftFactor () const
 shift of denominator/nummerator away from central line of a frac More...
 
double getItalicCorrectionFactor () const
 fraction of a whitespace by which to shift a sub-/superscript left/right when the previous text is italic More...
 
double getMathoperatorWidthFactor () const
 factor, used to extend the size of an operator in math mode More...
 
double getOperatorsubsuperSizeFactor () const
 like subsuper_size_factor, but for operators (\sum, \int) where the text is placed above/below the symbol More...
 
MTnodegetParsedNode () const
 the result of parsing the last string supplied to the object via parse() More...
 
QPair< QString, MTfontEncodinggetReplacementFont (const QString &nonUseFont, const QString &defaultFont, MTfontEncoding defaultFontEncoding) const
 retrieves a replacement for the given font name nonUseFont, including its encoding. Returns the given default values defaultFont and/or defaultFontEncoding if one of the two is not found More...
 
QSizeF getSize (QPainter &painter)
 get the size of the drawn representation. returns an invalid size if no text has been parsed. More...
 
void getSizeDetail (QPainter &painter, double &width, double &ascent, double &descent, double &strikeoutPos)
 return the detailes sizes of the text More...
 
double getSubShiftFactor () const
 relative shift of text in subscript to normal text: 0= baseline kept, 1: baseline shifted to bottom of normal text More...
 
double getSubsuperSizeFactor () const
 resizing factor for font size in sub-/superscript More...
 
double getSuperShiftFactor () const
 relative shift of text in superscript to normal text: 0= baseline kept, 1: baseline shifted to top of normal text More...
 
MTfontEncoding getSymbolfontEncodingGreek (MTenvironmentFont font) const
 retrieves the encoding used for the greek letter font to be used for symbols in the logical font font
More...
 
MTfontEncoding getSymbolfontEncodingSymbol (MTenvironmentFont font) const
 retrieves the encoding used for the symbol font to be used for symbols in the logical font font
More...
 
QString getSymbolfontGreek (MTenvironmentFont font) const
 retrieves the font to be used for greek letters in the logical font font
More...
 
QString getSymbolfontSymbol (MTenvironmentFont font) const
 retrieves the font to be used for symbols in the logical font font
More...
 
double getUnderbraceFactor () const
 scaling factor for font of underbrace/overbrace text More...
 
double getUndersetFactor () const
 scaling factor for font of underset/overset text More...
 
bool isFontBlackboardSimulated () const
 is blackboard font simulated by using roman with outlines only More...
 
bool isUsingUnparsed () const
 if true, the unparsedNode is drawn More...
 
void loadSettings (const QSettings &settings, const QString &group=QString("mathtext/"))
 load the object settings from the given QSettings object with the given name prefix More...
 
bool parse (QString text)
 parse the given enhanced string. Returns true on success. More...
 
void saveSettings (QSettings &settings, const QString &group=QString("mathtext/")) const
 store the object settings to the given QSettings object with the given name prefix More...
 
void setBraceFactor (double __value)
 resizing factor for braces in math mode More...
 
void setBraceShrinkFactor (double __value)
 shrinking the width of braces in math mode 0: reduce to 0 pixel width, 1: leave unchanged More...
 
void setBraceYShiftFactor (double __value)
 fraction of the brace ascent that the brace is shifted downwards, when scaled More...
 
void setDecorationHeightFactor (double __value)
 size of the decorations (dot, tilde, ...), as fractio of the baselineheight More...
 
void setExpensiveRendering (bool __value)
 switches on some options that will grant better rendering at the expense of higher time consumption More...
 
void setFontBlackboard (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEblackboard
More...
 
void setFontBlackboardSimulated (bool doSimulate)
 blackboard font is simulated by using roman with outlines only More...
 
void setFontCaligraphic (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEcaligraphic
More...
 
void setFontColor (const QColor &__value)
 font color More...
 
void setFontFraktur (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEfraktur
More...
 
void setFontMathRoman (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEmathRoman
More...
 
void setFontMathSans (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEmathSans
More...
 
void setFontRoman (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEroman
More...
 
void setFontRomanOrSpecial (const QString &fontName)
 calls setFontRoman(), or calls useXITS() if __value =="XITS". calls useSTIX() if __value =="STIX", ... More...
 
void setFontSans (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEsans
More...
 
void setFontScript (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEscript
More...
 
void setFontSize (double __value)
 base font size in points More...
 
void setFontTypewriter (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEtypewriter
More...
 
void setFracFactor (double __value)
 scaling factor for font of nominator and denominator of a fraction More...
 
void setFracShiftFactor (double __value)
 shift of denominator/nummerator away from central line of a frac More...
 
void setItalicCorrectionFactor (double __value)
 fraction of a whitespace by which to shift a sub-/superscript left/right when the previous text is italic More...
 
void setMathoperatorWidthFactor (double __value)
 factor, used to extend the size of an operator in math mode More...
 
void setOperatorsubsuperSizeFactor (double __value)
 like subsuper_size_factor, but for operators (\sum, \int) where the text is placed above/below the symbol More...
 
void setSubShiftFactor (double __value)
 relative shift of text in subscript to normal text: 0= baseline kept, 1: baseline shifted to bottom of normal text More...
 
void setSubsuperSizeFactor (double __value)
 resizing factor for font size in sub-/superscript More...
 
void setSuperShiftFactor (double __value)
 relative shift of text in superscript to normal text: 0= baseline kept, 1: baseline shifted to top of normal text More...
 
void setSymbolfontGreek (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for integrals in all logical fonts
More...
 
void setSymbolfontGreek (MTenvironmentFont font, const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for greek letters in the logical font font
More...
 
void setSymbolfontSymbol (const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for integrals in all logical fonts
More...
 
void setSymbolfontSymbol (MTenvironmentFont font, const QString &fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for symbols in the logical font font
More...
 
void setUnderbraceFactor (double __value)
 scaling factor for font of underbrace/overbrace text More...
 
void setUndersetFactor (double __value)
 scaling factor for font of underset/overset text More...
 
void setUseUnparsed (bool __value)
 if true, the unparsedNode is drawn More...
 
QString toHtml (bool *ok=nullptr, double fontPointSize=10)
 convert LaTeX to HTML. returns ok=true on success and ok=false else. More...
 
void useAnyUnicode (QString timesFont=QString(""), const QString &sansFont=QString(""), MTfontEncoding encodingTimes=MTfontEncoding::MTFEunicode, MTfontEncoding encodingSans=MTfontEncoding::MTFEunicode)
 sets timesFont (with its encoding encodingTimes ) for serif-text and sansFont (with its encoding encodingSans ) for both mathmode and textmode fonts More...
 
bool useASANA (bool mathModeOnly=true)
 configures the class to use the ASANA fonts in mathmode More...
 
bool useSTIX (bool mathModeOnly=true)
 configures the class to use the STIX fonts in mathmode More...
 
bool useXITS (bool mathModeOnly=true)
 configures the class to use the XITS fonts in mathmode More...
 

Static Public Member Functions

static QString decorationToString (MTdecoration mode)
 
static QString encoding2String (MTfontEncoding e)
 convert MTfontEncoding to a string More...
 
static QString fracModeToString (MTfracMode mode)
 
static QRectF getTightBoundingRect (const QFont &fm, const QString &text, QPaintDevice *pd)
 

Static Public Attributes

static const double ABS_MIN_LINEWIDTH
 minimum linewidth allowed in a JKQTMathText (given in pt) More...
 
static QHash< JKQTMathText::tbrDataH, QRectF > tbrh
 
static QList< JKQTMathText::tbrDatatbrs
 

Protected Types

enum  tokenType {
  MTTnone,
  MTTtext,
  MTTinstruction,
  MTTunderscore,
  MTThat,
  MTTdollar,
  MTTopenbrace,
  MTTclosebrace,
  MTTwhitespace,
  MTTampersand
}
 the token types that may arrise in the string More...
 

Protected Member Functions

tokenType getToken ()
 tokenizer for the LaTeX parser More...
 
MTnodegetTree () const
 
MTnodeparseLatexString (bool get, const QString &quitOnClosingBrace=QString(""), const QString &quitOnEnvironmentEnd=QString(""))
 parse a LaTeX string More...
 
MTnodeparseMath (bool get)
 parse a LaTeX math environment More...
 

Protected Attributes

bool blackboardSimulated
 if enabled, the blackboard-characters are simulated by using font outlines only More...
 
double brace_factor
 resizing factor for braces in math mode More...
 
double brace_shrink_factor
 shrinking the width of braces in math mode 0: reduce to 0 pixel width, 1: leave unchanged More...
 
double brace_y_shift_factor
 fraction of the brace ascent that the brace is shifted downwards, when scaled More...
 
tokenType currentToken
 used by the tokenizer. type of the current token More...
 
int currentTokenID
 used by the tokenizer. Points to the currently read character in parseString More...
 
QString currentTokenName
 used by the tokenizer. Name of the current token, id applicable More...
 
double decoration_height_factor
 size of the decorations (dot, tilde, ...), as fractio of the baselineheight More...
 
QStringList error_list
 a list that will be filled with error messages while parsing, if any error occur More...
 
bool expensiveRendering
 switches on some options that will grant better rendering at the expense of higher time consumption More...
 
QColor fontColor
 font color More...
 
QHash< MTenvironmentFont, FontDefinitionfontDefinitions
 stores information about the different fonts used by LaTeX markup More...
 
QMap< QString, MTfontEncodingfontEncodingReplacements
 acompanies fontReplacements and collects the encodings of the replacement fonts, if no entry is present, the default encoding is used, as given to the setter! More...
 
QMap< QString, QString > fontReplacements
 table with font replacements to use (e.g. if it is known that a certain font is not good for rendering, you can add an alternative using addReplacementFont(). These are automatically applied, when setting a new font name! More...
 
double fontSize
 base font size in points More...
 
double frac_factor
 scaling factor for font of nominator and denominator of a fraction More...
 
double frac_shift_factor
 shift of denominator/nummerator away from central line of a frac More...
 
double italic_correction_factor
 fraction of a whitespace by which to shift a sub-/superscript left/right when the previous text is italic More...
 
double mathoperator_width_factor
 factor, used to extend the size of an operator in math mode More...
 
double operatorsubsuper_size_factor
 like subsuper_size_factor, but for operators (\sum, \int) where the text is placed above/below the symbol More...
 
MTnodeparsedNode
 the result of parsing the last string supplied to the object via parse() More...
 
QString parseString
 used by the tokenizer. The string to be parsed More...
 
bool parsingMathEnvironment
 used by the parser. indicates whether we are in a math environment More...
 
bool showRightBrace
 used by the parser. This is used to implement brace pairs with \right. More...
 
double sub_shift_factor
 relative shift of text in subscript to normal text: 0= baseline kept, 1: baseline shifted to bottom of normal text More...
 
double subsuper_size_factor
 resizing factor for font size in sub-/superscript More...
 
double super_shift_factor
 relative shift of text in superscript to normal text: 0= baseline kept, 1: baseline shifted to top of normal text More...
 
double underbrace_factor
 scaling factor for font of underbrace/overbrace text More...
 
double undersetFactor
 scaling factor for font of underset/overset text More...
 
MTnodeunparsedNode
 a tree containing the unparsed text as a single node More...
 
bool useUnparsed
 if true, the unparsedNode is drawn More...
 

Detailed Description

this class parses a LaTeX string and can then draw the contained text/equation onto a QPainter

JKQTMathText is a self-contained LaTeX-renderer for Qt. It is used to renderer labels in JKQTPlotter/JKQTBasePlotter, but can be used independently. The class does not depend on any library, except Qt. In particular it actually parses a LaTeX string and draws it in pure C++. It does NOT rely on an installed LaTeX for the rendering!

Usage

Direct Usage

This small piece of C++ code may serve as an example of the usage and capabilities of the class:

// create a JKQTMathText object.
JKQTMathText mathText;
// configure its properties to influence the rendering (e.g. fonts to use, font size, ...)
mathText.useXITS();
mathText.setFontSize(20);
// parse some LaTeX code (the Schroedinger's equation)
mathText.parse("$\\left[-\\frac{\\hbar^2}{2m}\\frac{\\partial^2}{\\partial x^2}+V(x)\\right]\\Psi(x)=\\mathrm{i}\\hbar\\frac{\\partial}{\\partial t}\\Psi(x)$");
// use the draw() methods to draw the equation using a QPainter (here onto a QPixmap)
QPainter painter;
QPixmap pix(600,400);
painter.begin(&pix);
mathText.draw(painter, Qt::AlignCenter, QRectF(0,0,pix.width(), pix.height()), false);
painter.end();

Determining the size of an equation

In addition there are also functions that allow to calculate the size of the equation, before drawing it (just like the functions in QFontMetrics and QFontMetricsF):

Error Handling

The class is designed to be as robust as possible and will still return some output, even if the equation contains some errors. Nevertheless, several errors are detected while parsing. You can get a list of error messages using getErrorList() after calling parse(). Also parse() will return false if an error occured while parsing.

Usage within a QLabel class JKQTMathTextLabel

Finally, there is also a QLabel-derived class JKQTMathTextLabel which can be used for drawing a LaTeX string onto a Qt form.

See also
JKQTMathTextLabel

Examples

Examples for the usage of this class can be found here:

Supported LaTeX Subset

Simple Instructions

The supported LaTeX subset is listes below. Please note that some commands are used differently than in actual LaTeX. For example \bf is just a renamed form of \textbf and used as \bf{...} and NOT as {\bf...} .

  • $ : enter/leave math mode
  • \bf{...} \textbf{...} \mathbf{...}: draw the contained text in bold face
  • \it{...} \textit{...} \mathit{...} : draw the contained text in italic face
  • \rm{...} \textrm{...} \mathrm{...} \mbox{...} : draw the contained text in normal upright roman font face
  • \sf{...} \textsf{...} \mathsf{...} : draw the contained text in normal upright sans-serif font face
  • \script{...} \textscript{...} \mathscript{...} : draw the contained text in a script font face
  • \sc{...} : draw the text in small caps
  • \ul{...} \underline{...} \underlined{...} : draw the text with underlining
  • \ol{...} \overline{...} \overlined{...} : draw the text with overlining
  • \tt{...} \texttt{...} \mathtt{...} : draw text in typewriter font
  • \textcolor{color}{...} \color{color} \mathcolor{color}{...} : draw colored text
  • \boxed{...} : draw text with a box around it
  • \colorbox{color}{...} : draw a colored box around text
  • \alpha ... : display the according greek letter
  • ^{...} _{...} : display the contents of braces in superscript/subscript

    Special subscript/superscript typesetting applies, when the sub/super follows \sum \Prod ...:
  • \{ / \} : display opening/closing brace
  • \_ : display underscore
  • \sum \prod \int ... : plot special symbol. Note that depending on the fontEncoding the available symbols may differ (there are not all symbols defined in the MS Windows Symbol font!). Best coverage should be given by Unicode font encoding with a good unicode font installed!
  • \vec{x} \dot{x} \ddot{x} \overline{x} \underline{x} \hat{x} \tilde{x} \uul{x} \ool{x} \bar{x} \arrow{x} : Decorations over/under symbols
  • \verb{don't parse this _aaa\LaTeX} : interpret enclosed text as verbose

Braces ...

Braces in math mode are adjusted in size, so they are a small bit (factor brace_factor ) larger than the contents. To enable this you have to write braces with \left and \right. These types of braces are defined (slight differences to LaTeX standard):

  • \left( \right) : default meaning (),
  • \left[ \right] : default meaning [],
  • \left\{ \right\} : default meaning {},
  • \left< \right> : "averaging" braces ,
  • \left\lfloor \right\rfloor : floor braces ,
  • \left~ \right~ \left\lceil \right\rceil : ceil braces ,
  • \left| \right| : absolute value braces | |,
  • \left\| \right\| : norm braces || ||,
  • You can use \left. or \right. to have only right or only left brace

Undersetting, Oversetting, Underbraces, Overbraces ...

There are also instructions that allow to under/overset braces, arrows, ...:

  • $\underbrace{x+x+...+x}{k\ \mathrm{times}}$
  • $\overbrace{x+x+...+x}{k\ \mathrm{times}}$
  • $\overset{main}{over}$
  • $\underset{main}{under}$

Matrix/Array Type Instructions

Several Matrix/Array-typed LaTeX instructions are supported:

  • $\frac{...}{...}$, $\tfrac{...}{...}$ (70% smaller font), $\dfrac{...}{...}$
  • $\sfrac{...}{...}$
  • $\stfrac{...}{...}$ (70% smaller font)
  • $\stackrel{...}{...}$ $\binom{...}{...}$
  • $\begin{cases} ... & ... \ ... & ... \end{cases}$
  • $\begin{array} a & b & ...\ c & d & ...\end{array}$ $\begin{matrix} a & b & ...\ c & d & ...\end{matrix}$
  • $\begin{pmatrix} a & b & ...\ c & d & ...\end{pmatrix}$
  • $\begin{bmatrix} a & b & ...\ c & d & ...\end{bmatrix}$
  • $\begin{Bmatrix} a & b & ...\ c & d & ...\end{Bmatrix}$
  • $\begin{vmatrix} a & b & ...\ c & d & ...\end{vmatrix}$
  • $\begin{Vmatrix} a & b & ...\ c & d & ...\end{Vmatrix}$

Font Handling

Several fonts are defined as properties to the class:

These fonts are generic font classes, which font is actually used can be configured in JKQTMathText class with the set...() functions mentioned above. You can also use these functions to set the fonts used for math rendering in math-mode:

Math-mode is activated by enclosing your equation in $...$ or \[...\] . This mode is optimized for mathematical equations. Here is an example of the difference:

  • math-mode (XITS fonts are used, whitespaces are mostly not drawn directly, symbol spacing is different) $...$:
  • normal mode (Times new Roman is used, whitespaces are evaluated directly):

Convert to HTML

The method toHtml() may be used to get a HTML representation of the LaTeX string, if possible (only for simple LaTeX equations!). Whether the transformation was possible is returned as a call by value argument!

Member Enumeration Documentation

◆ FontSubclass

Enumerator
Text 
Default 
Symbols 
Greek 

◆ MTdecoration

Enumerator
MTDvec 

vector arrow over block

MTDhat 

hat over block

MTDdot 

single dot over block

MTDddot 

double dot over block

MTDbar 

bar over block

MTDarrow 

arrow over block

MTDoverline 

overline over block

MTDdoubleoverline 

double overline over block

MTDunderline 

underline under block

MTDdoubleunderline 

double underline under block

MTDtilde 

tilde over block

◆ MTenvironmentFont

the available logical fonts (default is MTEroman)

Enumerator
MTEroman 

roman font, e.g. \rm{}

MTEsans 

sans-serif font, e.g. \sf{}

MTEmathRoman 

math-mode roman font, e.g. \mathrm{}

MTEmathSans 

math-mode sans-serif font, e.g. \mathsf{}

MTEtypewriter 

typewriter font, e.g. \tt{},\mathtt{}

MTEscript 

script font, e.g. \script{},\mathscript{}

MTEblackboard 

blackboard font, e.g. \mathbb{}

MTEcaligraphic 

caligraphic font, e.g. \mathcal{}

MTEfraktur 

fraktur font, e.g. \mathfrak{}

MTenvironmentFontCount 

internal enum value that allows to iterate over MTenvironmentFont

◆ MTfontEncoding

used to specify the font encoding used for drawing

Enumerator
MTFEwinSymbol 

This assumes that symbols shall be taken from a MS Windows style Symbol font.

MTFEunicode 

This assumes that symbols shall be taken from a Unicode font (e.g. the STIX fonts from http://www.stixfonts.org/)

MTFEunicodeLimited 

This assumes that the fonts used are Unicode, but only offer a limited set of symbols. Especially math symbols are missing from this encoding.

MTFEStandard 

the encoding of a standard TTF font (i.e. we can only expect letters,number and not many special characters)

◆ MTfracMode

Enumerator
MTFMfrac 

normal fraction

MTFMdfrac 

normal fraction, without scaling of under/over text

MTFMtfrac 

text fraction (smaller than MTFMfrac)

MTFMsfrac 

slanted fraction

MTFMstfrac 

slanted text fraction

MTFMunderbrace 

curly underbrace

MTFMoverbrace 

curly overbrace

MTFMstackrel 

binom/fraction without line

MTFMunderset 

underset text

MTFMoverset 

overset text

◆ tokenType

enum JKQTMathText::tokenType
protected

the token types that may arrise in the string

Enumerator
MTTnone 
MTTtext 
MTTinstruction 
MTTunderscore 
MTThat 
MTTdollar 
MTTopenbrace 
MTTclosebrace 
MTTwhitespace 
MTTampersand 

Constructor & Destructor Documentation

◆ JKQTMathText()

JKQTMathText::JKQTMathText ( QObject *  parent = nullptr)

class constructor

◆ ~JKQTMathText()

JKQTMathText::~JKQTMathText ( )

class destructor

Member Function Documentation

◆ addReplacementFont() [1/2]

void JKQTMathText::addReplacementFont ( const QString &  nonUseFont,
const QString &  useFont 
)

add a font pair to the table with font replacements

e.g. if it is known that a certain font is not good for rendering, you can add an alternative with this function. These are automatically applied, when setting a new font name!

Parameters
nonUseFontthe font not to use
useFontreplacement font for nonUseFont

The entry in the encodings for this font is kept empty (or even deleted), so the default encoding of the font to be replaced is used!

◆ addReplacementFont() [2/2]

void JKQTMathText::addReplacementFont ( const QString &  nonUseFont,
const QString &  useFont,
MTfontEncoding  useFontEncoding 
)

add a font pair to the table with font replacements

e.g. if it is known that a certain font is not good for rendering, you can add an alternative with this function. These are automatically applied, when setting a new font name!

Parameters
nonUseFontthe font not to use
useFontreplacement font for nonUseFont
useFontEncodingencoding of the replacement font

◆ decorationToString()

static QString JKQTMathText::decorationToString ( MTdecoration  mode)
static

◆ draw() [1/2]

void JKQTMathText::draw ( QPainter &  painter,
double  x,
double  y,
bool  drawBoxes = false 
)

draw a representation to the QPainter object at the specified position

◆ draw() [2/2]

void JKQTMathText::draw ( QPainter &  painter,
unsigned int  flags,
QRectF  rect,
bool  drawBoxes = false 
)

overloaded version of draw(QPainter& painter, double x, double y).

This version draws the text inside the given rectangle according to the specified flags.

◆ encoding2String()

static QString JKQTMathText::encoding2String ( MTfontEncoding  e)
static

convert MTfontEncoding to a string

◆ fracModeToString()

static QString JKQTMathText::fracModeToString ( MTfracMode  mode)
static

◆ getAscent()

double JKQTMathText::getAscent ( QPainter &  painter)

return the ascentt, i.e. the distance from the baseline to the highest part of the representation

◆ getBraceFactor()

double JKQTMathText::getBraceFactor ( ) const

resizing factor for braces in math mode

◆ getBraceShrinkFactor()

double JKQTMathText::getBraceShrinkFactor ( ) const

shrinking the width of braces in math mode 0: reduce to 0 pixel width, 1: leave unchanged

◆ getBraceYShiftFactor()

double JKQTMathText::getBraceYShiftFactor ( ) const

fraction of the brace ascent that the brace is shifted downwards, when scaled

◆ getDecorationHeightFactor()

double JKQTMathText::getDecorationHeightFactor ( ) const

size of the decorations (dot, tilde, ...), as fractio of the baselineheight

◆ getDescent()

double JKQTMathText::getDescent ( QPainter &  painter)

return the descent, i.e. the distance from the baseline to the lowest part of the representation

◆ getErrorList()

QStringList JKQTMathText::getErrorList ( ) const

a list that will be filled with error messages while parsing, if any error occur

◆ getExpensiveRendering()

bool JKQTMathText::getExpensiveRendering ( ) const

switches on some options that will grant better rendering at the expense of higher time consumption

◆ getFontBlackboard()

QString JKQTMathText::getFontBlackboard ( ) const

retrieves the font to be used for text in the logical font MTEblackboard

◆ getFontCaligraphic()

QString JKQTMathText::getFontCaligraphic ( ) const

retrieves the font to be used for text in the logical font MTEcaligraphic

◆ getFontColor()

QColor JKQTMathText::getFontColor ( ) const

font color

◆ getFontData()

QPair<QString, MTfontEncoding> JKQTMathText::getFontData ( MTenvironmentFont  font,
bool  in_math_environment = false,
FontSubclass  subclass = FontSubclass::Default 
) const

retrieve the font and encoding to be used for font, which might optionally be typeset inside a math environment, specified by in_math_environment, possibly for the given font subclass subclass

◆ getFontEncodingBlackboard()

MTfontEncoding JKQTMathText::getFontEncodingBlackboard ( ) const

retrieves the encoding used for the blackboard font

◆ getFontEncodingCaligraphic()

JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingCaligraphic ( ) const

retrieves the encoding used for the caligraphic font

◆ getFontEncodingFraktur()

MTfontEncoding JKQTMathText::getFontEncodingFraktur ( ) const

retrieves the encoding used for the Fraktur font

◆ getFontEncodingMathRoman()

MTfontEncoding JKQTMathText::getFontEncodingMathRoman ( ) const

retrieves the encoding used for the math-mode roman font

◆ getFontEncodingMathSans()

MTfontEncoding JKQTMathText::getFontEncodingMathSans ( ) const

retrieves the encoding used for the math-mode sans-serif font

◆ getFontEncodingRoman()

MTfontEncoding JKQTMathText::getFontEncodingRoman ( ) const

retrieves the encoding used for the roman font

◆ getFontEncodingSans()

MTfontEncoding JKQTMathText::getFontEncodingSans ( ) const

retrieves the encoding used for the sans-serif font

◆ getFontEncodingScript()

MTfontEncoding JKQTMathText::getFontEncodingScript ( ) const

retrieves the encoding used for the script font

◆ getFontEncodingTypewriter()

MTfontEncoding JKQTMathText::getFontEncodingTypewriter ( ) const

retrieves the encoding used for the typewriter font

◆ getFontFraktur()

QString JKQTMathText::getFontFraktur ( ) const

retrieves the font to be used for text in the logical font MTEfraktur

◆ getFontMathRoman()

QString JKQTMathText::getFontMathRoman ( ) const

retrieves the font to be used for text in the logical font MTEroman

◆ getFontMathSans()

QString JKQTMathText::getFontMathSans ( ) const

retrieves the font to be used for text in the logical font MTEsans

◆ getFontRoman()

QString JKQTMathText::getFontRoman ( ) const

retrieves the font to be used for text in the logical font MTEroman

◆ getFontSans()

QString JKQTMathText::getFontSans ( ) const

retrieves the font to be used for text in the logical font MTEsans

◆ getFontScript()

QString JKQTMathText::getFontScript ( ) const

retrieves the font to be used for text in the logical font MTEscript

◆ getFontSize()

double JKQTMathText::getFontSize ( ) const

base font size in points

◆ getFontTypewriter()

QString JKQTMathText::getFontTypewriter ( ) const

retrieves the font to be used for text in the logical font MTEtypewriter

◆ getFracFactor()

double JKQTMathText::getFracFactor ( ) const

scaling factor for font of nominator and denominator of a fraction

◆ getFracShiftFactor()

double JKQTMathText::getFracShiftFactor ( ) const

shift of denominator/nummerator away from central line of a frac

◆ getItalicCorrectionFactor()

double JKQTMathText::getItalicCorrectionFactor ( ) const

fraction of a whitespace by which to shift a sub-/superscript left/right when the previous text is italic

◆ getMathoperatorWidthFactor()

double JKQTMathText::getMathoperatorWidthFactor ( ) const

factor, used to extend the size of an operator in math mode

◆ getOperatorsubsuperSizeFactor()

double JKQTMathText::getOperatorsubsuperSizeFactor ( ) const

like subsuper_size_factor, but for operators (\sum, \int) where the text is placed above/below the symbol

◆ getParsedNode()

MTnode* JKQTMathText::getParsedNode ( ) const

the result of parsing the last string supplied to the object via parse()

◆ getReplacementFont()

QPair<QString, MTfontEncoding> JKQTMathText::getReplacementFont ( const QString &  nonUseFont,
const QString &  defaultFont,
MTfontEncoding  defaultFontEncoding 
) const

retrieves a replacement for the given font name nonUseFont, including its encoding. Returns the given default values defaultFont and/or defaultFontEncoding if one of the two is not found

◆ getSize()

QSizeF JKQTMathText::getSize ( QPainter &  painter)

get the size of the drawn representation. returns an invalid size if no text has been parsed.

◆ getSizeDetail()

void JKQTMathText::getSizeDetail ( QPainter &  painter,
double &  width,
double &  ascent,
double &  descent,
double &  strikeoutPos 
)

return the detailes sizes of the text

◆ getSubShiftFactor()

double JKQTMathText::getSubShiftFactor ( ) const

relative shift of text in subscript to normal text: 0= baseline kept, 1: baseline shifted to bottom of normal text

◆ getSubsuperSizeFactor()

double JKQTMathText::getSubsuperSizeFactor ( ) const

resizing factor for font size in sub-/superscript

◆ getSuperShiftFactor()

double JKQTMathText::getSuperShiftFactor ( ) const

relative shift of text in superscript to normal text: 0= baseline kept, 1: baseline shifted to top of normal text

◆ getSymbolfontEncodingGreek()

MTfontEncoding JKQTMathText::getSymbolfontEncodingGreek ( MTenvironmentFont  font) const

retrieves the encoding used for the greek letter font to be used for symbols in the logical font font

◆ getSymbolfontEncodingSymbol()

MTfontEncoding JKQTMathText::getSymbolfontEncodingSymbol ( MTenvironmentFont  font) const

retrieves the encoding used for the symbol font to be used for symbols in the logical font font

◆ getSymbolfontGreek()

QString JKQTMathText::getSymbolfontGreek ( MTenvironmentFont  font) const

retrieves the font to be used for greek letters in the logical font font

◆ getSymbolfontSymbol()

QString JKQTMathText::getSymbolfontSymbol ( MTenvironmentFont  font) const

retrieves the font to be used for symbols in the logical font font

◆ getTightBoundingRect()

static QRectF JKQTMathText::getTightBoundingRect ( const QFont &  fm,
const QString &  text,
QPaintDevice *  pd 
)
static

◆ getToken()

tokenType JKQTMathText::getToken ( )
protected

tokenizer for the LaTeX parser

◆ getTree()

MTnode* JKQTMathText::getTree ( ) const
protected

◆ getUnderbraceFactor()

double JKQTMathText::getUnderbraceFactor ( ) const

scaling factor for font of underbrace/overbrace text

◆ getUndersetFactor()

double JKQTMathText::getUndersetFactor ( ) const

scaling factor for font of underset/overset text

◆ isFontBlackboardSimulated()

bool JKQTMathText::isFontBlackboardSimulated ( ) const

is blackboard font simulated by using roman with outlines only

◆ isUsingUnparsed()

bool JKQTMathText::isUsingUnparsed ( ) const

if true, the unparsedNode is drawn

◆ loadSettings()

void JKQTMathText::loadSettings ( const QSettings &  settings,
const QString &  group = QString("mathtext/") 
)

load the object settings from the given QSettings object with the given name prefix

◆ parse()

bool JKQTMathText::parse ( QString  text)

parse the given enhanced string. Returns true on success.

◆ parseLatexString()

MTnode* JKQTMathText::parseLatexString ( bool  get,
const QString &  quitOnClosingBrace = QString(""),
const QString &  quitOnEnvironmentEnd = QString("") 
)
protected

parse a LaTeX string

◆ parseMath()

MTnode* JKQTMathText::parseMath ( bool  get)
protected

parse a LaTeX math environment

◆ saveSettings()

void JKQTMathText::saveSettings ( QSettings &  settings,
const QString &  group = QString("mathtext/") 
) const

store the object settings to the given QSettings object with the given name prefix

◆ setBraceFactor()

void JKQTMathText::setBraceFactor ( double  __value)

resizing factor for braces in math mode

◆ setBraceShrinkFactor()

void JKQTMathText::setBraceShrinkFactor ( double  __value)

shrinking the width of braces in math mode 0: reduce to 0 pixel width, 1: leave unchanged

◆ setBraceYShiftFactor()

void JKQTMathText::setBraceYShiftFactor ( double  __value)

fraction of the brace ascent that the brace is shifted downwards, when scaled

◆ setDecorationHeightFactor()

void JKQTMathText::setDecorationHeightFactor ( double  __value)

size of the decorations (dot, tilde, ...), as fractio of the baselineheight

◆ setExpensiveRendering()

void JKQTMathText::setExpensiveRendering ( bool  __value)

switches on some options that will grant better rendering at the expense of higher time consumption

◆ setFontBlackboard()

void JKQTMathText::setFontBlackboard ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEblackboard

◆ setFontBlackboardSimulated()

void JKQTMathText::setFontBlackboardSimulated ( bool  doSimulate)

blackboard font is simulated by using roman with outlines only

◆ setFontCaligraphic()

void JKQTMathText::setFontCaligraphic ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEcaligraphic

◆ setFontColor()

void JKQTMathText::setFontColor ( const QColor &  __value)

font color

◆ setFontFraktur()

void JKQTMathText::setFontFraktur ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEfraktur

◆ setFontMathRoman()

void JKQTMathText::setFontMathRoman ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEmathRoman

◆ setFontMathSans()

void JKQTMathText::setFontMathSans ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEmathSans

◆ setFontRoman()

void JKQTMathText::setFontRoman ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEroman

◆ setFontRomanOrSpecial()

void JKQTMathText::setFontRomanOrSpecial ( const QString &  fontName)

calls setFontRoman(), or calls useXITS() if __value =="XITS". calls useSTIX() if __value =="STIX", ...

See also
setFontRoman(), useXITS(), useSTIX() for more information

◆ setFontSans()

void JKQTMathText::setFontSans ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEsans

◆ setFontScript()

void JKQTMathText::setFontScript ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEscript

◆ setFontSize()

void JKQTMathText::setFontSize ( double  __value)

base font size in points

◆ setFontTypewriter()

void JKQTMathText::setFontTypewriter ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text in the logical font MTEtypewriter

◆ setFracFactor()

void JKQTMathText::setFracFactor ( double  __value)

scaling factor for font of nominator and denominator of a fraction

◆ setFracShiftFactor()

void JKQTMathText::setFracShiftFactor ( double  __value)

shift of denominator/nummerator away from central line of a frac

◆ setItalicCorrectionFactor()

void JKQTMathText::setItalicCorrectionFactor ( double  __value)

fraction of a whitespace by which to shift a sub-/superscript left/right when the previous text is italic

◆ setMathoperatorWidthFactor()

void JKQTMathText::setMathoperatorWidthFactor ( double  __value)

factor, used to extend the size of an operator in math mode

◆ setOperatorsubsuperSizeFactor()

void JKQTMathText::setOperatorsubsuperSizeFactor ( double  __value)

like subsuper_size_factor, but for operators (\sum, \int) where the text is placed above/below the symbol

◆ setSubShiftFactor()

void JKQTMathText::setSubShiftFactor ( double  __value)

relative shift of text in subscript to normal text: 0= baseline kept, 1: baseline shifted to bottom of normal text

◆ setSubsuperSizeFactor()

void JKQTMathText::setSubsuperSizeFactor ( double  __value)

resizing factor for font size in sub-/superscript

◆ setSuperShiftFactor()

void JKQTMathText::setSuperShiftFactor ( double  __value)

relative shift of text in superscript to normal text: 0= baseline kept, 1: baseline shifted to top of normal text

◆ setSymbolfontGreek() [1/2]

void JKQTMathText::setSymbolfontGreek ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for integrals in all logical fonts

◆ setSymbolfontGreek() [2/2]

void JKQTMathText::setSymbolfontGreek ( MTenvironmentFont  font,
const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for greek letters in the logical font font

◆ setSymbolfontSymbol() [1/2]

void JKQTMathText::setSymbolfontSymbol ( const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for integrals in all logical fonts

◆ setSymbolfontSymbol() [2/2]

void JKQTMathText::setSymbolfontSymbol ( MTenvironmentFont  font,
const QString &  fontName,
MTfontEncoding  encoding = MTfontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for symbols in the logical font font

◆ setUnderbraceFactor()

void JKQTMathText::setUnderbraceFactor ( double  __value)

scaling factor for font of underbrace/overbrace text

◆ setUndersetFactor()

void JKQTMathText::setUndersetFactor ( double  __value)

scaling factor for font of underset/overset text

◆ setUseUnparsed()

void JKQTMathText::setUseUnparsed ( bool  __value)

if true, the unparsedNode is drawn

◆ toHtml()

QString JKQTMathText::toHtml ( bool *  ok = nullptr,
double  fontPointSize = 10 
)

convert LaTeX to HTML. returns ok=true on success and ok=false else.

◆ useAnyUnicode()

void JKQTMathText::useAnyUnicode ( QString  timesFont = QString(""),
const QString &  sansFont = QString(""),
MTfontEncoding  encodingTimes = MTfontEncoding::MTFEunicode,
MTfontEncoding  encodingSans = MTfontEncoding::MTFEunicode 
)

sets timesFont (with its encoding encodingTimes ) for serif-text and sansFont (with its encoding encodingSans ) for both mathmode and textmode fonts

use generic Unicode fonts, e.g. "Arial" and "Times New Roman" in math-mode. You should use fonts that contain as many of the mathematical symbols as possible to ensure good rendering results.

setAnyUnicode("Times New Roman", "Times New Roman"):

setAnyUnicode("Arial", "Arial"):

setAnyUnicode("Courier New", "Courier New"):

setAnyUnicode("Comic Sans MS", "Comic Sans MS"):

◆ useASANA()

bool JKQTMathText::useASANA ( bool  mathModeOnly = true)

configures the class to use the ASANA fonts in mathmode

use the ASANA fonts from https://ctan.org/tex-archive/fonts/Asana-Math/ in math-mode

◆ useSTIX()

bool JKQTMathText::useSTIX ( bool  mathModeOnly = true)

configures the class to use the STIX fonts in mathmode

use STIX (1.x/2.x) fonts from https://www.stixfonts.org/ in math-mode

◆ useXITS()

bool JKQTMathText::useXITS ( bool  mathModeOnly = true)

configures the class to use the XITS fonts in mathmode

use XITS fonts from https://github.com/alif-type/xits in math-mode. These are included by default in this library and also activated by default.

Member Data Documentation

◆ ABS_MIN_LINEWIDTH

const double JKQTMathText::ABS_MIN_LINEWIDTH
static

minimum linewidth allowed in a JKQTMathText (given in pt)

◆ blackboardSimulated

bool JKQTMathText::blackboardSimulated
protected

if enabled, the blackboard-characters are simulated by using font outlines only

◆ brace_factor

double JKQTMathText::brace_factor
protected

resizing factor for braces in math mode

◆ brace_shrink_factor

double JKQTMathText::brace_shrink_factor
protected

shrinking the width of braces in math mode 0: reduce to 0 pixel width, 1: leave unchanged

◆ brace_y_shift_factor

double JKQTMathText::brace_y_shift_factor
protected

fraction of the brace ascent that the brace is shifted downwards, when scaled

◆ currentToken

tokenType JKQTMathText::currentToken
protected

used by the tokenizer. type of the current token

◆ currentTokenID

int JKQTMathText::currentTokenID
protected

used by the tokenizer. Points to the currently read character in parseString

◆ currentTokenName

QString JKQTMathText::currentTokenName
protected

used by the tokenizer. Name of the current token, id applicable

◆ decoration_height_factor

double JKQTMathText::decoration_height_factor
protected

size of the decorations (dot, tilde, ...), as fractio of the baselineheight

◆ error_list

QStringList JKQTMathText::error_list
protected

a list that will be filled with error messages while parsing, if any error occur

◆ expensiveRendering

bool JKQTMathText::expensiveRendering
protected

switches on some options that will grant better rendering at the expense of higher time consumption

◆ fontColor

QColor JKQTMathText::fontColor
protected

font color

◆ fontDefinitions

QHash<MTenvironmentFont, FontDefinition> JKQTMathText::fontDefinitions
protected

stores information about the different fonts used by LaTeX markup

◆ fontEncodingReplacements

QMap<QString, MTfontEncoding> JKQTMathText::fontEncodingReplacements
protected

acompanies fontReplacements and collects the encodings of the replacement fonts, if no entry is present, the default encoding is used, as given to the setter!

◆ fontReplacements

QMap<QString, QString> JKQTMathText::fontReplacements
protected

table with font replacements to use (e.g. if it is known that a certain font is not good for rendering, you can add an alternative using addReplacementFont(). These are automatically applied, when setting a new font name!

◆ fontSize

double JKQTMathText::fontSize
protected

base font size in points

◆ frac_factor

double JKQTMathText::frac_factor
protected

scaling factor for font of nominator and denominator of a fraction

◆ frac_shift_factor

double JKQTMathText::frac_shift_factor
protected

shift of denominator/nummerator away from central line of a frac

◆ italic_correction_factor

double JKQTMathText::italic_correction_factor
protected

fraction of a whitespace by which to shift a sub-/superscript left/right when the previous text is italic

◆ mathoperator_width_factor

double JKQTMathText::mathoperator_width_factor
protected

factor, used to extend the size of an operator in math mode

◆ operatorsubsuper_size_factor

double JKQTMathText::operatorsubsuper_size_factor
protected

like subsuper_size_factor, but for operators (\sum, \int) where the text is placed above/below the symbol

◆ parsedNode

MTnode* JKQTMathText::parsedNode
protected

the result of parsing the last string supplied to the object via parse()

◆ parseString

QString JKQTMathText::parseString
protected

used by the tokenizer. The string to be parsed

◆ parsingMathEnvironment

bool JKQTMathText::parsingMathEnvironment
protected

used by the parser. indicates whether we are in a math environment

◆ showRightBrace

bool JKQTMathText::showRightBrace
protected

used by the parser. This is used to implement brace pairs with \right.

◆ sub_shift_factor

double JKQTMathText::sub_shift_factor
protected

relative shift of text in subscript to normal text: 0= baseline kept, 1: baseline shifted to bottom of normal text

◆ subsuper_size_factor

double JKQTMathText::subsuper_size_factor
protected

resizing factor for font size in sub-/superscript

◆ super_shift_factor

double JKQTMathText::super_shift_factor
protected

relative shift of text in superscript to normal text: 0= baseline kept, 1: baseline shifted to top of normal text

◆ tbrh

QHash<JKQTMathText::tbrDataH, QRectF> JKQTMathText::tbrh
static

◆ tbrs

QList<JKQTMathText::tbrData> JKQTMathText::tbrs
static

◆ underbrace_factor

double JKQTMathText::underbrace_factor
protected

scaling factor for font of underbrace/overbrace text

◆ undersetFactor

double JKQTMathText::undersetFactor
protected

scaling factor for font of underset/overset text

◆ unparsedNode

MTnode* JKQTMathText::unparsedNode
protected

a tree containing the unparsed text as a single node

◆ useUnparsed

bool JKQTMathText::useUnparsed
protected

if true, the unparsedNode is drawn


The documentation for this class was generated from the following file:
JKQTMathText
this class parses a LaTeX string and can then draw the contained text/equation onto a QPainter
Definition: jkqtmathtext.h:220
JKQTMathText::draw
void draw(QPainter &painter, double x, double y, bool drawBoxes=false)
draw a representation to the QPainter object at the specified position
JKQTMathText::useXITS
bool useXITS(bool mathModeOnly=true)
configures the class to use the XITS fonts in mathmode
JKQTMathText::setFontSize
void setFontSize(double __value)
base font size in points
JKQTMathText::parse
bool parse(QString text)
parse the given enhanced string. Returns true on success.