JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches

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

#include <jkqtmathtext.h>

Inheritance diagram for JKQTMathText:
[legend]
Collaboration diagram for JKQTMathText:
[legend]

Public Member Functions

 JKQTMathText (QObject *parent=nullptr, bool useFontsForGUI=false)
 class constructor with a paren QObject parent and calls useGuiFonts() if useFontsForGUI =true
 
 ~JKQTMathText ()
 class destructor
 
Determine the Size of the Output
QSizeF getSize (QPainter &painter)
 get the size of the drawn representation. returns an invalid size if no text has been parsed.
 
QSize getIntSize (QPainter &painter)
 get the rounded (using ceil) to an integer size of the drawn representation. returns QSize(0,0) if no text has been parsed.
 
double getDescent (QPainter &painter)
 return the descent, i.e. the distance from the baseline to the lowest part of the representation
 
double getAscent (QPainter &painter)
 return the ascentt, i.e. the distance from the baseline to the highest part of the representation
 
void getSizeDetail (QPainter &painter, double &width, double &ascent, double &descent, double &strikeoutPos)
 return the detailes sizes of the text
 
JKQTMathTextNodeSize getSizeDetail (QPainter &painter)
 return the detailes sizes of the text
 
Rendering
void draw (QPainter &painter, QPointF x, bool drawBoxes=false)
 draw a representation to the object at the specified position x , y
 
double draw (QPainter &painter, double x, double y, bool drawBoxes=false)
 draw a representation to the object at the specified position x , y
 
void draw (QPainter &painter, unsigned int flags, QRectF rect, bool drawBoxes=false)
 draw into a rectangle rect with alignment defined in flags (see below)
 
QPixmap drawIntoPixmap (bool drawBoxes=false, QColor backgroundColor=QColor(Qt::white), int sizeincrease=0, qreal devicePixelRatio=1.0)
 render the last parse result into a QPixmap
 
QImage drawIntoImage (bool drawBoxes=false, QColor backgroundColor=QColor(Qt::white), int sizeincrease=0, qreal devicePixelRatio=1.0, unsigned int resolution_dpi=96)
 render the last parse result into a QImage
 
QPicture drawIntoPicture (bool drawBoxes=false)
 render the last parse result into a QPicture
 
QString toHtml (bool *ok=nullptr, double fontPointSize=10)
 convert LaTeX to HTML. returns ok=true on success and ok=false else.
 
(Defining) Rendering Details
void loadSettings (const QSettings &settings, const QString &group=QString("mathtext/"))
 load the object settings from the given QSettings object with the given name prefix
 
void saveSettings (QSettings &settings, const QString &group=QString("mathtext/")) const
 store the object settings to the given QSettings object with the given name prefix
 
void setBraceFactor (double __value)
 for \left / \right braces: The brace is this factor higher than the child block it surrounds
 
double getBraceFactor () const
 for \left / \right braces: The brace is this factor higher than the child block it surrounds
 
void setSubsuperSizeFactor (double __value)
 resizing factor for font size in sub-/superscript
 
double getSubsuperSizeFactor () const
 resizing factor for font size in sub-/superscript
 
void setSubsuperModeSelectionBySizeFactor (double __value)
 this factor is used to determine how to typeset sub-/superscript.
 
double getSubsuperModeSelectionBySizeFactor () const
 this factor is used to determine how to typeset sub-/superscript.
 
void setOperatorsubsuperSizeFactor (double __value)
 like subsuper_size_factor, but for operators (\sum , \int , ...) where the text is placed above/below the symbol
 
double getOperatorsubsuperSizeFactor () const
 like subsuper_size_factor, but for operators (\sum , \int , ...) where the text is placed above/below the symbol
 
void setOperatorsubsuperDistanceFactor (double __value)
 for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the distance between the operator symbol and the sub-/super-text if multiplied by xHeight
 
double getOperatorsubsuperDistanceFactor () const
 for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the distance between the operator symbol and the sub-/super-text if multiplied by xHeight
 
void setOperatorsubsuperExtraSpaceFactor (double __value)
 for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the additional width added to the width of maximum width of the operator, above and below
 
double getOperatorsubsuperExtraSpaceFactor () const
 for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the additional width added to the width of maximum width of the operator, above and below
 
void setMathoperatorWidthFactor (double __value)
 factor, used to extend the size of an operator in math mode
 
double getMathoperatorWidthFactor () const
 factor, used to extend the size of an operator in math mode
 
void setIntSubSuperXCorrectionFactor (double __value)
 for integrals (\int , \oint , ...) the sub-/superscripts above/below the symbol have to be shifted a bit to the left/right to accomodate the shape of the operator symbol (i.e. some free space at the top-left and bottom-right)
 
double getIntSubSuperXCorrectionFactor () const
 for integrals (\int , \oint , ...) the sub-/superscripts above/below the symbol have to be shifted a bit to the left/right to accomodate the shape of the operator symbol (i.e. some free space at the top-left and bottom-right)
 
void setIntSubBesidesXCorrectionXFactor (double __value)
 for integrals (\int , \oint , ...) the subscripts besides the symbol have to be shifted to the left a bit to the left to accomodate the shape of the operator symbol (i.e. some free space at the bottom-right)
 
double getIntSubBesidesXCorrectionXFactor () const
 for integrals (\int , \oint , ...) the subscripts besides the symbol have to be shifted to the left a bit to the left to accomodate the shape of the operator symbol (i.e. some free space at the bottom-right)
 
void setBigMathoperatorFontFactor (double __value)
 factor, used to increase the font size for big math operators, such as \sum , \prod , ...
 
double getBigMathoperatorFontFactor () const
 factor, used to increase the font size for big math operators, such as \sum , \prod , ...
 
void setSuperShiftFactor (double __value)
 relative shift of text in superscript to normal text, factor is multiplied by font.xHeight()
 
double getSuperShiftFactor () const
 relative shift of text in superscript to normal text, factor is multiplied by font.xHeight()
 
void setSubShiftFactor (double __value)
 relative shift of text in subscript to normal text, factor is multiplied by font.xHeight()
 
double getSubShiftFactor () const
 relative shift of text in subscript to normal text, factor is multiplied by font.xHeight()
 
void setSpecialSuperShiftFactor (double __value)
 relative shift of text in superscript to normal text in special superscript mode (after large previous nodes): 0= superscript descent coincides with the previous node's baselineHeight, 1: top of previous node and top of the superscript nodes coincide
 
double getSpecialSuperShiftFactor () const
 relative shift of text in superscript to normal text in special superscript mode (after large previous nodes): 0= superscript descent coincides with the previous node's baselineHeight, 1: top of previous node and top of the superscript nodes coincide
 
void setSpecialSubShiftFactor (double __value)
 relative shift of text in subscript to normal text in special superscript mode (after large previous nodes): 0=child's baseline at the descent of the previous node, 1: subscript-node starts at the descent of the previous node
 
double getSpecialSubShiftFactor () const
 relative shift of text in subscript to normal text in special superscript mode (after large previous nodes): 0=child's baseline at the descent of the previous node, 1: subscript-node starts at the descent of the previous node
 
void setUnderbraceFactor (double __value)
 scaling factor for font of underbrace/overbrace text
 
double getUnderbraceFactor () const
 scaling factor for font of underbrace/overbrace text
 
void setUnderbraceSeparationXFactor (double __value)
 additional space between the main text to the curly brace and the brace to underbrace/overbrace, multiplied with height("x")
 
double getUnderbraceSeparationXFactor () const
 additional space between the main text to the curly brace and the brace to underbrace/overbrace, multiplied with height("x")
 
void setUnderbraceBraceSizeXFactor (double __value)
 height of the brace in underbrace/overbrace, multiplied with ascent
 
double getUnderbraceBraceSizeXFactor () const
 height of the brace in underbrace/overbrace, multiplied with ascent
 
void setUndersetFactor (double __value)
 scaling factor for font of underset/overset text
 
double getUndersetFactor () const
 scaling factor for font of underset/overset text
 
void setFracFactor (double __value)
 scaling factor for font size of nominator and denominator of a fraction
 
double getFracFactor () const
 scaling factor for font size of nominator and denominator of a fraction
 
void setFracNestedFactor (double __value)
 scaling factor for font size of nominator and denominator of a nested fraction
 
double getFracNestedFactor () const
 scaling factor for font size of nominator and denominator of a nested fraction
 
void setFracShiftFactor (double __value)
 shift of denominator/nummerator away from central line of a frac
 
double getFracShiftFactor () const
 shift of denominator/nummerator away from central line of a frac
 
void setBraceYShiftFactor (double __value)
 fraction of the brace ascent that the brace is shifted downwards, when scaled
 
double getBraceYShiftFactor () const
 fraction of the brace ascent that the brace is shifted downwards, when scaled
 
void setDecorationHeightFactor (double __value)
 size of the decorations (dot, tilde, ...), as fraction of the ascent
 
double getDecorationHeightFactor () const
 size of the decorations (dot, tilde, ...), as fraction of the ascent
 
void setDecorationSeparationXFactor (double __value)
 separation between the text and the decorations (dot, tilde, ...), as fraction of the ascent
 
double getDecorationSeparationFactor () const
 separation between the text and the decorations (dot, tilde, ...), as fraction of the ascent
 
void setDecorationWidthReductionFactor (double __value)
 a decoration has a size, which is slightly smaller than the text- width. the width is reduced by decoration_width_reduction_Xfactor*width("X") and the position is centered around the child-box. Also an italic correction is applied:
 
double getDecorationWidthReductionXFactor () const
 a decoration has a size, which is slightly smaller than the text- width. the width is reduced by decoration_width_reduction_Xfactor*width("X") and the position is centered around the child-box. Also an italic correction is applied:
 
void setSqrtWidthXFactor (double __value)
 width of the sqrt-symbol, as factor to width("X")
 
double getSqrtWidthXFactor () const
 width of the sqrt-symbol, as factor to width("X")
 
void setSqrtHeightFactor (double __value)
 height-increase of the sqrt-symbol, as factor of the child's height
 
double getSqrtHeightFactor () const
 height-increase of the sqrt-symbol, as factor of the child's height
 
void setSqrtSmallFontFactor (double __value)
 scaling factor for the small font used to indicate the degree of the sqrt
 
double getSqrtSmallFontFactor () const
 scaling factor for the small font used to indicate the degree of the sqrt
 
double getMatrixLinewidthThinFactor ()
 width of thin table lines, this factor is multiplied with the current font.linewidth()
 
void setMatrixLinewidthThinFactor (double factor)
 width of thin table lines, this factor is multiplied with the current font.linewidth()
 
double getMatrixLinewidthHeavyFactor ()
 width of heavy table lines, this factor is multiplied with the current font.linewidth()
 
void setMatrixLinewidthHeavyFactor (double factor)
 width of heavy table lines, this factor is multiplied with the current font.linewidth()
 
double getMatrixLineSeparationFactor ()
 separation of double-lines in tables, this factor is multiplied with the font.linewidth()
 
void setMatrixLineSeparationFactor (double factor)
 separation of double-lines in tables, this factor is multiplied with the font.linewidth()
 
double getMatrixXSeparationFactor ()
 x-separation of two columns, this factor is multiplied with the font.width("x")
 
void setMatrixXSeparationFactor (double factor)
 x-separation of two columns, this factor is multiplied with the font.width("x")
 
double getMatrixYSeparationFactor ()
 y-separation of two columns, this factor is multiplied with the font.width("x")
 
void setMatrixYSeparationFactor (double factor)
 y-separation of two columns, this factor is multiplied with the font.width("x")
 
double getMatrixXPaddingFactor ()
 x-padding of two columns, this factor is multiplied with the font.width("x")
 
void setMatrixXPaddingFactor (double factor)
 x-padding of two columns, this factor is multiplied with the font.width("x")
 
double getMatrixYPaddingFactor ()
 y-padding of two columns, this factor is multiplied with the font.width("x")
 
void setMatrixYPaddingFactor (double factor)
 y-padding of two columns, this factor is multiplied with the font.width("x")
 

Static Public Attributes

static const double ABS_MIN_LINEWIDTH
 minimum linewidth allowed in a JKQTMathText (given in pt)
 

Protected Member Functions

void deleteParsedNode ()
 this function moves a delete parsedNode-call into the cpp-file, as JKQTMathTextNode is "only" forward declared here and therefore, deleting it may cause undefined behaviour
 
void modifyEnvironmentFromFontSettings (JKQTMathTextEnvironment &ev) const
 sets all properties of JKQTMathTextEnvironment ev from the fon settings stored in this class (e.g. fontSize, fontOptions, ...)
 

Protected Attributes

double bigmathoperator_font_factor
 factor, used to increase the font size for big math operators, such as \sum , \prod , ...
 
JKQTMathTextBlackboradDrawingMode blackboradFontMode
 specifies how to draw blackboard font characters (i.e. \mathbb{N} )
 
double brace_factor
 for \left / \right braces: The brace is this factor higher than the child block it surrounds
 
double brace_y_shift_factor
 fraction of the brace ascent that the brace is shifted downwards, when scaled
 
double decoration_height_factor
 size of the decorations (dot, tilde, ...), as fraction of the ascent
 
double decoration_separation_factor
 separation between the text and the decorations (dot, tilde, ...), as fraction of the ascent
 
double decoration_width_reduction_Xfactor
 a decoration has a size, which is slightly smaller than the text- width. the width is reduced by decoration_width_reduction_Xfactor*width("X") and the position is centered around the child-box. Also an italic correction is applied:
 
QColor fontColor
 font color
 
QHash< JKQTMathTextEnvironmentFont, JKQTMathTextFontDefinitionfontDefinitions
 stores information about the different fonts used by LaTeX markup
 
QMap< QString, JKQTMathTextFontEncodingfontEncodingReplacements
 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!
 
BaseFontOptions fontOptions
 additional options for the base fonts
 
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!
 
double fontSize
 base font size in the units defined in fontSizeUnits
 
JKQTMathTextEnvironment::FontSizeUnit fontSizeUnits
 unit of fontSize
 
double frac_factor
 scaling factor for font size of nominator and denominator of a fraction
 
double frac_nested_factor
 scaling factor for font size of nominator and denominator of a nested fraction
 
double frac_shift_factor
 shift of denominator/nummerator away from central line of a frac
 
double intsubbesides_xcorrection_xfactor
 for integrals (\int , \oint , ...) the subscripts besides the symbol have to be shifted to the left a bit to the left to accomodate the shape of the operator symbol (i.e. some free space at the bottom-right)
 
double intsubsuper_xcorrection_factor
 for integrals (\int , \oint , ...) the sub-/superscripts above/below the symbol have to be shifted a bit to the left/right to accomodate the shape of the operator symbol (i.e. some free space at the top-left and bottom-right)
 
double mathoperator_width_factor
 factor, used to extend the size of an operator in math mode
 
double matrix_line_separation_factor
 separation of double-lines in tables, this factor is multiplied with the font.linewidth()
 
double matrix_linewidth_heavy_factor
 width of heavy table lines, this factor is multiplied with the current font.linewidth()
 
double matrix_linewidth_thin_factor
 width of thin table lines, this factor is multiplied with the current font.linewidth()
 
double matrix_xPadding_factor
 x-padding of two columns, this factor is multiplied with the font.width("x")
 
double matrix_xSeparation_factor
 x-separation of two columns, this factor is multiplied with the font.width("x")
 
double matrix_yPadding_factor
 y-padding of two columns, this factor is multiplied with the font.width("x")
 
double matrix_ySeparation_factor
 y-separation of two columns, this factor is multiplied with the font.width("x")
 
double operatorsubsuper_distance_factor
 for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the distance between the operator symbol and the sub-/super-text if multiplied by xHeight
 
double operatorsubsuper_extraspace_factor
 for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the additional width added to the width of maximum width of the operator, above and below
 
double operatorsubsuper_size_factor
 like subsuper_size_factor, but for operators (\sum , \int , ...) where the text is placed above/below the symbol
 
JKQTMathTextNodeparsedNode
 the syntax tree of JKQTMathTextNode's that was created by the last parse() call
 
double special_sub_shift_factor
 relative shift of text in subscript to normal text in special superscript mode (after large previous nodes): 0=child's baseline at the descent of the previous node, 1: subscript-node starts at the descent of the previous node
 
double special_super_shift_factor
 relative shift of text in superscript to normal text in special superscript mode (after large previous nodes): 0= superscript descent coincides with the previous node's baselineHeight, 1: top of previous node and top of the superscript nodes coincide
 
double sqrt_height_factor
 height-increase of the sqrt-symbol, as factor of the child's height
 
double sqrt_smallfont_factor
 scaling factor for the small font used to indicate the degree of the sqrt
 
double sqrt_width_Xfactor
 width of the sqrt-symbol, as factor to width("X")
 
double sub_shift_factor
 relative shift of text in subscript to normal text, factor is multiplied by font.xHeight()
 
double subsuper_mode_selection_by_size_factor
 this factor is used to determine how to typeset sub-/superscript.
 
double subsuper_size_factor
 resizing factor for font size in sub-/superscript
 
double super_shift_factor
 relative shift of text in superscript to normal text, factor is multiplied by font.xHeight()
 
double underbrace_bracesize_xfactor
 height of the brace in underbrace/overbrace, multiplied with ascent
 
double underbrace_factor
 scaling factor for font of underbrace/overbrace text
 
double underbrace_separation_xfactor
 additional space between the main text to the curly brace and the brace to underbrace/overbrace, multiplied with height("x")
 
double underset_factor
 scaling factor for font of underset/overset text
 

Static Protected Attributes

static QString init_blackboardFont
 initial choice for "blackboard" font
 
static QString init_caligraphicFont
 initial choice for "caligraphic" font
 
static QString init_fracturFont
 initial choice for "fraktur" font
 
static QString init_sansFont
 initial choice for "sans-erif" font
 
static QString init_scriptFont
 initial choice for "script" font
 
static QString init_serifFont
 initial choice for "serif" font
 
static QString init_symbolFont
 initial choice for "fallback symbol" font
 
static QString init_typewriterFont
 initial choice for "typewriter" font
 
static bool s_firstStart
 used to check for the first construction of a JKQTMathText ... if true several static variables are initialized in the constructor
 
static std::mutex s_mutex
 mutex to protect the static members
 

Friends

class JKQTMathTextNode
 
class JKQTMathTextParser
 

Parsing Math Markup

enum  ParseOption {
  AddSpaceBeforeAndAfter = 0x01 ,
  StartWithMathMode = 0x02 ,
  AllowLinebreaks = 0x04 ,
  DefaultParseOptions =AllowLinebreaks
}
 options for parse() More...
 
enum  DefaultParserTypes {
  LatexParser ,
  DefaultParser =LatexParser
}
 lists the parser classes that are available by default (convenience interface to the templated parse()-funktion More...
 
typedef QFlags< ParseOptionParseOptions
 
bool parse (const QString &markup, DefaultParserTypes markupType=DefaultParser, ParseOptions options=DefaultParseOptions)
 parse the given math markup string with a parser derived from markupType.
 
template<class TParser >
bool parse (const QString &markup, ParseOptions options=DefaultParseOptions)
 parse the given math markup string, using the given parser class TParser
 
JKQTMathTextNodegetNodeTree ()
 returns the syntax tree of JKQTMathTextNode's that was created by the last parse() call
 
const JKQTMathTextNodegetNodeTree () const
 the syntax tree of JKQTMathTextNode's that was created by the last parse() call
 

Font Handling

enum  BaseFontOption {
  BaseFontBold = 0x01 ,
  BaseFontItalic = 0x02 ,
  BaseFontUnderlined = 0x04 ,
  BaseFontSmallCaps = 0x08 ,
  BaseFontDefault =0x00
}
 options for the base font More...
 
typedef QFlags< BaseFontOptionBaseFontOptions
 
void setFontColor (const QColor &__value)
 font color
 
QColor getFontColor () const
 font color
 
void setFontSize (double __value)
 set the default font size in points
 
void setFontPointSize (double __value)
 set the default font size in points
 
void setFontSizePixels (double __value)
 set the default font soze in pixels
 
double getFontPointSize () const
 returns the currently set default font size in points, if it was defined in points using setFontSize(), or -1 if it was set in pixels with setFontSizePixels()
 
double getFontSize () const
 returns the currently set default font size in points, if it was defined in points using setFontSize(), or -1 if it was set in pixels with setFontSizePixels()
 
double getFontSizePixels () const
 returns the currently set default font size in pixels, if it was defined in points using setFontSizePixels(), or -1 if it was set in points with setFontSize()
 
void setFontOptions (BaseFontOptions opts)
 set (overwrite) the options applied to the base font
 
void setFontOption (BaseFontOption opt, bool enabled=true)
 en/disable the given base font option
 
BaseFontOptions getFontOptions () const
 returns the options applied to the base font
 
void addReplacementFont (const QString &nonUseFont, const QString &useFont)
 add a font pair to the table with font replacements
 
void addReplacementFont (const QString &nonUseFont, const QString &useFont, JKQTMathTextFontEncoding useFontEncoding)
 add a font pair to the table with font replacements
 
QPair< QString, JKQTMathTextFontEncodinggetReplacementFont (const QString &nonUseFont, const QString &defaultFont, JKQTMathTextFontEncoding 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
 
QPair< QString, JKQTMathTextFontEncodinggetFontData (JKQTMathTextEnvironmentFont font, bool in_math_environment=false) 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
 
void setFontRomanOrSpecial (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font by parsing a special syntax defined in the description of JKQTMathTextFontSpecifier
 
void setFontRomanOrSpecial (const JKQTMathTextFontSpecifier &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font by an instance of JKQTMathTextFontSpecifier
 
void setFontSpecial (const QString &fontSpec)
 set font(s) from parsing a font specifier
 
void setFontRoman (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEroman
 
void setFontRomanAndMath (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text and math, i.e. the logical font MTEroman and MTEmathRoman
 
QString getFontRoman () const
 retrieves the font to be used for text in the logical font MTEroman

 
void setFontSans (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEsans
 
QString getFontSans () const
 retrieves the font to be used for text in the logical font MTEsans

 
void setFontTypewriter (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEtypewriter
 
QString getFontTypewriter () const
 retrieves the font to be used for text in the logical font MTEtypewriter

 
void setFontScript (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEscript
 
QString getFontScript () const
 retrieves the font to be used for text in the logical font MTEscript

 
void setFontFraktur (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEfraktur
 
QString getFontFraktur () const
 retrieves the font to be used for text in the logical font MTEfraktur

 
void setFontCaligraphic (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEcaligraphic
 
QString getFontCaligraphic () const
 retrieves the font to be used for text in the logical font MTEcaligraphic

 
void setFontBlackboard (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEblackboard
 
JKQTMathTextBlackboradDrawingMode getFontBlackboradMode () const
 specifies how to draw blackboard font characters (i.e. \mathbb{N} )
 
void setFontBlackboradMode (JKQTMathTextBlackboradDrawingMode mode)
 specifies how to draw blackboard font characters (i.e. \mathbb{N} )
 
QString getFontBlackboard () const
 retrieves the font to be used for text in the logical font MTEblackboard
 
void setFallbackFontSymbols (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for symbols in the logical font font
 
QString getFallbackFontSymbols () const
 retrieves the font to be used for symbols in the logical font font

 
JKQTMathTextFontEncoding getFontEncodingFallbackFontSymbols () const
 retrieves the encoding used for the symbol font to be used for symbols

 
JKQTMathTextFontEncoding getFontEncodingScript () const
 retrieves the encoding used for the script font

 
JKQTMathTextFontEncoding getFontEncodingFraktur () const
 retrieves the encoding used for the Fraktur font

 
JKQTMathTextFontEncoding getFontEncodingTypewriter () const
 retrieves the encoding used for the typewriter font

 
JKQTMathTextFontEncoding getFontEncodingSans () const
 retrieves the encoding used for the sans-serif font

 
JKQTMathTextFontEncoding getFontEncodingRoman () const
 retrieves the encoding used for the roman font

 
JKQTMathTextFontEncoding getFontEncodingBlackboard () const
 retrieves the encoding used for the blackboard font

 
JKQTMathTextFontEncoding getFontEncodingCaligraphic () const
 retrieves the encoding used for the caligraphic font

 
void setFontMathRoman (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEmathRoman
 
QString getFontMathRoman () const
 retrieves the font to be used for text in the logical font MTEroman

 
void setFontMathSans (const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
 set the font fontName and it's encoding encoding to be used for text in the logical font MTEmathSans
 
QString getFontMathSans () const
 retrieves the font to be used for text in the logical font MTEsans

 
JKQTMathTextFontEncoding getFontEncodingMathSans () const
 retrieves the encoding used for the math-mode sans-serif font

 
JKQTMathTextFontEncoding getFontEncodingMathRoman () const
 retrieves the encoding used for the math-mode roman font

 
bool useSTIX (bool mathModeOnly=true, bool useAsFallbackSymbol=true)
 configures the class to use the STIX fonts in mathmode
 
bool useXITS (bool mathModeOnly=true, bool useAsFallbackSymbol=true)
 configures the class to use the XITS fonts in mathmode
 
bool useFiraMath (bool mathModeOnly=true, bool useAsFallbackSymbol=true)
 configures the class to use the Fira Math fonts in mathmode
 
bool useASANA (bool mathModeOnly=true, bool useAsFallbackSymbol=true)
 configures the class to use the ASANA fonts in mathmode
 
bool useGuiFonts ()
 configures the class to be used for GUI output, i.e. tries to find fonts that are harmonious for the default GUI font, sets the default GUI font for "roman" and finds an oppposite font for "sans", which means that "sans" may actually be a serif font,when the app font is sans serif!
 
void useAnyUnicode (QString timesFont, const QString &sansFont, JKQTMathTextFontEncoding encodingTimes=JKQTMathTextFontEncoding::MTFEUnicode, JKQTMathTextFontEncoding encodingSans=JKQTMathTextFontEncoding::MTFEUnicode)
 sets timesFont (with its encoding encodingTimes ) for serif-text and sansFont (with its encoding encodingSans ) for both mathmode and textmode fonts
 
void useAnyUnicodeForMathOnly (QString timesFont, const QString &sansFont, JKQTMathTextFontEncoding encodingTimes=JKQTMathTextFontEncoding::MTFEUnicode, JKQTMathTextFontEncoding encodingSans=JKQTMathTextFontEncoding::MTFEUnicode)
 sets timesFont (with its encoding encodingTimes ) for serif-text and sansFont (with its encoding encodingSans ) for mathmode fonts only
 
void useAnyUnicodeForTextOnly (QString timesFont, const QString &sansFont, JKQTMathTextFontEncoding encodingTimes=JKQTMathTextFontEncoding::MTFEUnicode, JKQTMathTextFontEncoding encodingSans=JKQTMathTextFontEncoding::MTFEUnicode)
 sets timesFont (with its encoding encodingTimes ) for serif-text and sansFont (with its encoding encodingSans ) for both mathmode fonts only
 
static QString BaseFontOptions2String (BaseFontOptions opt)
 convert BaseFontOptions to a string (e.g. BOLD+ITALIC
 
static BaseFontOptions String2BaseFontOptions (const QString &s)
 convert a string (generated by BaseFontOptions2String() to BaseFontOptions
 

Error Handling

QStringList error_list
 a list that will be filled with error messages while parsing, if any error occur
 
QStringList getErrorList () const
 a list that will be filled with error messages while parsing, if any error occur
 
bool hadErrors () const
 returns true when errors were registered in the system
 
void addToErrorList (const QString &error)
 a list that will be filled with error messages while parsing, if any error occur
 
void clearErrorList ()
 clears all registered errors (see error_list)
 

Detailed Description

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

JKQTMathText is a self-contained mathematical markup 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.

The implementation is split over several classes:

In particular JKQTMathTextLatexParser actually parses e.g. a LaTeX string and draws it in pure C++. It does NOT rely on an installed LaTeX for the rendering! See Supported LaTeX-Subset for a description of the supported LaTeX subset.

More generally these pages describe how the class renders math markup:

Thread-Safety/Re-Entrancy Guarantees

All functions in this class are reentrant. Therefore different instances off JKQTMathtext can be used in parallel in different threads. DO NOT however use the same instance from multiple threads, as the functions are not thread-safe!

Also note that there are certain caches that reuse information (e.g. about fonts) from previous runs, which allow different instances (also over different threads) to profit from each other. On the other hand, this strategy requires a bit of overhead due to synchronization, but usually the speedup outweighs the overhead significantly!

Usage

See also
See Build Instructions for detailed build-instructions and on how to link against JKQTMathText!

Parsing Functions

The class provieds two flavours of a parsing function:

  • There is a function parse(markup, markupType) that accepts the markup, the type of markup (as enum DefaultParserTypes) and parser options. This function determines the appropriate parser class, based on the markup type.
  • A templated function parse<TParser>(markup, options) that gets a parser class to be used on the markup.

Drawing Functions

The class provides different variants of the drawing function draw() that paints using an externlly provided QPainter. These variants either paint into a QRect, or starting from a single location (x,y).

The QRect-variants can align the render result inside the rectangle, whereas the location-variants draw from a position that is on the left-hand side of the output's baseline:

Note that you first need to call one of the Parsing Functions so there is anything to render!

Convenience Functions

Alternatively you can use these methods to directly generate a QPixmap or QPicture:

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 or QFontMetricsF):

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

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.

Example Code

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)$");
// draw the result into a QPixmap
QPixmap result=mathText.drawIntoPixmap();
this class parses a mathematical markup string and can then draw the contained text/equation onto a Q...
Definition jkqtmathtext.h:192
bool parse(const QString &markup, DefaultParserTypes markupType=DefaultParser, ParseOptions options=DefaultParseOptions)
parse the given math markup string with a parser derived from markupType.
bool useXITS(bool mathModeOnly=true, bool useAsFallbackSymbol=true)
configures the class to use the XITS fonts in mathmode
QPixmap drawIntoPixmap(bool drawBoxes=false, QColor backgroundColor=QColor(Qt::white), int sizeincrease=0, qreal devicePixelRatio=1.0)
render the last parse result into a QPixmap
void setFontSize(double __value)
set the default font size in points

Alternatively you can also use this class with a QPainter:

// use the draw() methods to draw the equation using a QPainter (here onto a QPixmap)
QPainter painter;
// first we determine the size of the render output:
const JKQTMathTextNodeSize size=getSizeDetail(painter);
// now we can us that size information to render:
mathText.draw(painter, Qt::AlignCenter, QRectF(0,0,pix.width(), pix.height()), false);
void draw(QPainter &painter, QPointF x, bool drawBoxes=false)
draw a representation to the object at the specified position x , y
void getSizeDetail(QPainter &painter, double &width, double &ascent, double &descent, double &strikeoutPos)
return the detailes sizes of the text
beschreibt die Größe(n) eines Knotens
Definition jkqtmathtexttools.h:393

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!

Example Projects

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

Member Typedef Documentation

◆ BaseFontOptions

◆ ParseOptions

Member Enumeration Documentation

◆ BaseFontOption

options for the base font

Enumerator
BaseFontBold 

output is bold (equivalent to placinf text in \textbf{...})

BaseFontItalic 

output is italic (equivalent to placinf text in \textit{...})

BaseFontUnderlined 

output is underlined (equivalent to placinf text in \underlined{...})

BaseFontSmallCaps 

output is small-caps (equivalent to placinf text in \textsc{...})

BaseFontDefault 

base font is used as is, without modifications

◆ DefaultParserTypes

lists the parser classes that are available by default (convenience interface to the templated parse()-funktion

Enumerator
LatexParser 

use the LaTeX parser from JKQTMathTextLatexParser

DefaultParser 

◆ ParseOption

options for parse()

Enumerator
AddSpaceBeforeAndAfter 

If set, a little bit of space is added before and after the text.

StartWithMathMode 

if set, the parser assumes the LaTeX string is in math-mode (as if surrounded by $ )

AllowLinebreaks 

If set, linebreak (i.e. \ or \newline ) are allowed, otherwise a single line wihtout such linebreak commands is expected.

DefaultParseOptions 

Constructor & Destructor Documentation

◆ JKQTMathText()

JKQTMathText::JKQTMathText ( QObject *  parent = nullptr,
bool  useFontsForGUI = false 
)

class constructor with a paren QObject parent and calls useGuiFonts() if useFontsForGUI =true

◆ ~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,
JKQTMathTextFontEncoding  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

◆ addToErrorList()

void JKQTMathText::addToErrorList ( const QString &  error)
protected

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

This list of errors is (mostly) filled during a call to parse(). During rendering (e.g. with draw() ) only very few errors will be detected, as most errors are caused by wrong markup.

A call to parse() also clears this list.

See also
getErrorList(), hadErrors() and addToErrorList()

◆ BaseFontOptions2String()

static QString JKQTMathText::BaseFontOptions2String ( BaseFontOptions  opt)
static

convert BaseFontOptions to a string (e.g. BOLD+ITALIC

◆ clearErrorList()

void JKQTMathText::clearErrorList ( )
protected

clears all registered errors (see error_list)

◆ deleteParsedNode()

void JKQTMathText::deleteParsedNode ( )
protected

this function moves a delete parsedNode-call into the cpp-file, as JKQTMathTextNode is "only" forward declared here and therefore, deleting it may cause undefined behaviour

◆ draw() [1/3]

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

draw a representation to the object at the specified position x , y

Parameters
painterthe QPainter to use for drawing
xx-position of the left border of the text/expression to be drawn (see sketch below)
yy-position of the baseline of the text/expression to be drawn (see sketch below)
drawBoxesif true boxes defining the size of each node are drawn, example output:

Here is an illustration of the geometry of the drawn text/expression:

◆ draw() [2/3]

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

draw a representation to the object at the specified position x , y

Parameters
painterthe QPainter to use for drawing
xposition of the left border of the text/expression to be drawn (see sketch below)
drawBoxesif true boxes defining the size of each node are drawn, example output:

Here is an illustration of the geometry of the drawn text/expression:

◆ draw() [3/3]

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

draw into a rectangle rect with alignment defined in flags (see below)

Parameters
painterthe QPainter to use for drawing
rectrectangle to draw the text/expression into (see sketch below)
flagsalignment within rect (see below), use e.g. Qt::AlignHCenter | Qt::AlignVCenter to center the expression inside rect The flags (dark-red is the rectangle rect) are interpreted in the following way:
drawBoxesif true boxes defining the size of each node are drawn, example output:
See also
drawIntoPixmap(), drawIntoPicture(), getSize(), getSizeDetail()

◆ drawIntoImage()

QImage JKQTMathText::drawIntoImage ( bool  drawBoxes = false,
QColor  backgroundColor = QColor(Qt::white),
int  sizeincrease = 0,
qreal  devicePixelRatio = 1.0,
unsigned int  resolution_dpi = 96 
)

render the last parse result into a QImage

Parameters
drawBoxesif true boxes defining the size of each node are drawn, example output:
backgroundColorfill color for the returnes QPixmap
sizeincreasemargin around the tight size of the rendering result for the returned QPixmap
devicePixelRatiothe devicePixelRatio of the returned QImage
resolution_dpiresolution in dots/inch

◆ drawIntoPicture()

QPicture JKQTMathText::drawIntoPicture ( bool  drawBoxes = false)

render the last parse result into a QPicture

Parameters
drawBoxesif true boxes defining the size of each node are drawn, example output:

◆ drawIntoPixmap()

QPixmap JKQTMathText::drawIntoPixmap ( bool  drawBoxes = false,
QColor  backgroundColor = QColor(Qt::white),
int  sizeincrease = 0,
qreal  devicePixelRatio = 1.0 
)

render the last parse result into a QPixmap

Parameters
drawBoxesif true boxes defining the size of each node are drawn, example output:
backgroundColorfill color for the returnes QPixmap
sizeincreasemargin around the tight size of the rendering result for the returned QPixmap
devicePixelRatiothe devicePixelRatio of the returned QPixmap

◆ getAscent()

double JKQTMathText::getAscent ( QPainter &  painter)

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

◆ getBigMathoperatorFontFactor()

double JKQTMathText::getBigMathoperatorFontFactor ( ) const

factor, used to increase the font size for big math operators, such as \sum , \prod , ...

◆ getBraceFactor()

double JKQTMathText::getBraceFactor ( ) const

for \left / \right braces: The brace is this factor higher than the child block it surrounds

◆ 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 fraction of the ascent

◆ getDecorationSeparationFactor()

double JKQTMathText::getDecorationSeparationFactor ( ) const

separation between the text and the decorations (dot, tilde, ...), as fraction of the ascent

◆ getDecorationWidthReductionXFactor()

double JKQTMathText::getDecorationWidthReductionXFactor ( ) const

a decoration has a size, which is slightly smaller than the text- width. the width is reduced by decoration_width_reduction_Xfactor*width("X") and the position is centered around the child-box. Also an italic correction is applied:

◆ 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

This list of errors is (mostly) filled during a call to parse(). During rendering (e.g. with draw() ) only very few errors will be detected, as most errors are caused by wrong markup.

A call to parse() also clears this list.

See also
getErrorList(), hadErrors() and addToErrorList()

◆ getFallbackFontSymbols()

QString JKQTMathText::getFallbackFontSymbols ( ) const

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

◆ getFontBlackboard()

QString JKQTMathText::getFontBlackboard ( ) const

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

See also
blackboradFontMode

◆ getFontBlackboradMode()

JKQTMathTextBlackboradDrawingMode JKQTMathText::getFontBlackboradMode ( ) const

specifies how to draw blackboard font characters (i.e. \mathbb{N} )

Blackboard fonts are not widely available on target systems (viable fonts are e.g. "Double Stroke", "CloisterOpenFace BT", "GoudyHandtooled BT", "Castellar", "MathJax_AMS", "Castellar Standard", "MathJax_AMS Standard", "Colonna MT"). But the most important blackboard characters are usually available in the higher unicode codepoints of Fonts specialized for math (e.g. XIST, STIX, ASANA).

Therefore JKQTMathText supports using these characters, or simulating a blackboard font in addition to using one of the fonts above. You can set that by setting JKQTMathText::setFontBlackboradMode() with one of the options from JKQTMathTextBlackboradDrawingMode:

  • MTBBDMfontDirectly: use a blackboard font specified by JKQTMathText::setFontBlackboard()
    using JKQTMathText::setFontBlackboard("Castellar")
  • MTBBDMsimulate:
    using JKQTMathText::setFontBlackboard("Arial")
  • MTBBDMunicodeCharactersOrFontDirectly:
    using JKQTMathText::setFontBlackboard("Castellar")
  • MTBBDMunicodeCharactersOrSimulate:
    using JKQTMathText::setFontBlackboard("Arial")
See also
JKQTMathTextBlackboradDrawingMode, setFontBlackboard(), setBlackboardFontMode(), Font Handling

◆ 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, JKQTMathTextFontEncoding > JKQTMathText::getFontData ( JKQTMathTextEnvironmentFont  font,
bool  in_math_environment = false 
) 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()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingBlackboard ( ) const

retrieves the encoding used for the blackboard font

◆ getFontEncodingCaligraphic()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingCaligraphic ( ) const

retrieves the encoding used for the caligraphic font

◆ getFontEncodingFallbackFontSymbols()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingFallbackFontSymbols ( ) const

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

◆ getFontEncodingFraktur()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingFraktur ( ) const

retrieves the encoding used for the Fraktur font

◆ getFontEncodingMathRoman()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingMathRoman ( ) const

retrieves the encoding used for the math-mode roman font

◆ getFontEncodingMathSans()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingMathSans ( ) const

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

◆ getFontEncodingRoman()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingRoman ( ) const

retrieves the encoding used for the roman font

◆ getFontEncodingSans()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingSans ( ) const

retrieves the encoding used for the sans-serif font

◆ getFontEncodingScript()

JKQTMathTextFontEncoding JKQTMathText::getFontEncodingScript ( ) const

retrieves the encoding used for the script font

◆ getFontEncodingTypewriter()

JKQTMathTextFontEncoding 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

◆ getFontOptions()

BaseFontOptions JKQTMathText::getFontOptions ( ) const

returns the options applied to the base font

See also
BaseFontOptions

◆ getFontPointSize()

double JKQTMathText::getFontPointSize ( ) const

returns the currently set default font size in points, if it was defined in points using setFontSize(), or -1 if it was set in pixels with setFontSizePixels()

See also
setFontSize(), fontSize, fontSizeUnits

◆ 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

returns the currently set default font size in points, if it was defined in points using setFontSize(), or -1 if it was set in pixels with setFontSizePixels()

See also
setFontSize(), fontSize, fontSizeUnits

◆ getFontSizePixels()

double JKQTMathText::getFontSizePixels ( ) const

returns the currently set default font size in pixels, if it was defined in points using setFontSizePixels(), or -1 if it was set in points with setFontSize()

See also
setFontSizePixels(), fontSize, fontSizeUnits

◆ 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 size of nominator and denominator of a fraction

◆ getFracNestedFactor()

double JKQTMathText::getFracNestedFactor ( ) const

scaling factor for font size of nominator and denominator of a nested fraction

◆ getFracShiftFactor()

double JKQTMathText::getFracShiftFactor ( ) const

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

◆ getIntSize()

QSize JKQTMathText::getIntSize ( QPainter &  painter)

get the rounded (using ceil) to an integer size of the drawn representation. returns QSize(0,0) if no text has been parsed.

◆ getIntSubBesidesXCorrectionXFactor()

double JKQTMathText::getIntSubBesidesXCorrectionXFactor ( ) const

for integrals (\int , \oint , ...) the subscripts besides the symbol have to be shifted to the left a bit to the left to accomodate the shape of the operator symbol (i.e. some free space at the bottom-right)

This factor is multiplied by the width of an x: xshift=intsubbesides_xcorrection_xfactor*xWidth Then the subscript besides the symbol is shifted by xshift to the left

This correction is applied to \int, \iint, \iiint, \oint, ...

◆ getIntSubSuperXCorrectionFactor()

double JKQTMathText::getIntSubSuperXCorrectionFactor ( ) const

for integrals (\int , \oint , ...) the sub-/superscripts above/below the symbol have to be shifted a bit to the left/right to accomodate the shape of the operator symbol (i.e. some free space at the top-left and bottom-right)

This factor is multiplied by the symbol width: xshift=intsubsuper_xcorrection_factor*symbolWidth Then the subscript below is placed at centerx(symbol)-xshift and the superscript at centerx(symbol)+shiftx. This is also used to correct a subset next to the symbol by shifting it to rightx(symbol)-xshift.

This correction is applied to \int, \iint, \iiint, \oint, ...

◆ getMathoperatorWidthFactor()

double JKQTMathText::getMathoperatorWidthFactor ( ) const

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

The next image demonstrates the effect of this property, which adds extra space around certain math operators in math mode:

◆ getMatrixLineSeparationFactor()

double JKQTMathText::getMatrixLineSeparationFactor ( )

separation of double-lines in tables, this factor is multiplied with the font.linewidth()

◆ getMatrixLinewidthHeavyFactor()

double JKQTMathText::getMatrixLinewidthHeavyFactor ( )

width of heavy table lines, this factor is multiplied with the current font.linewidth()

◆ getMatrixLinewidthThinFactor()

double JKQTMathText::getMatrixLinewidthThinFactor ( )

width of thin table lines, this factor is multiplied with the current font.linewidth()

◆ getMatrixXPaddingFactor()

double JKQTMathText::getMatrixXPaddingFactor ( )

x-padding of two columns, this factor is multiplied with the font.width("x")

◆ getMatrixXSeparationFactor()

double JKQTMathText::getMatrixXSeparationFactor ( )

x-separation of two columns, this factor is multiplied with the font.width("x")

◆ getMatrixYPaddingFactor()

double JKQTMathText::getMatrixYPaddingFactor ( )

y-padding of two columns, this factor is multiplied with the font.width("x")

◆ getMatrixYSeparationFactor()

double JKQTMathText::getMatrixYSeparationFactor ( )

y-separation of two columns, this factor is multiplied with the font.width("x")

◆ getNodeTree() [1/2]

JKQTMathTextNode * JKQTMathText::getNodeTree ( )

returns the syntax tree of JKQTMathTextNode's that was created by the last parse() call

◆ getNodeTree() [2/2]

const JKQTMathTextNode * JKQTMathText::getNodeTree ( ) const

the syntax tree of JKQTMathTextNode's that was created by the last parse() call

◆ getOperatorsubsuperDistanceFactor()

double JKQTMathText::getOperatorsubsuperDistanceFactor ( ) const

for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the distance between the operator symbol and the sub-/super-text if multiplied by xHeight

◆ getOperatorsubsuperExtraSpaceFactor()

double JKQTMathText::getOperatorsubsuperExtraSpaceFactor ( ) const

for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the additional width added to the width of maximum width of the operator, above and below

◆ getOperatorsubsuperSizeFactor()

double JKQTMathText::getOperatorsubsuperSizeFactor ( ) const

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

◆ getReplacementFont()

QPair< QString, JKQTMathTextFontEncoding > JKQTMathText::getReplacementFont ( const QString &  nonUseFont,
const QString &  defaultFont,
JKQTMathTextFontEncoding  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() [1/2]

JKQTMathTextNodeSize JKQTMathText::getSizeDetail ( QPainter &  painter)

return the detailes sizes of the text

◆ getSizeDetail() [2/2]

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

return the detailes sizes of the text

◆ getSpecialSubShiftFactor()

double JKQTMathText::getSpecialSubShiftFactor ( ) const

relative shift of text in subscript to normal text in special superscript mode (after large previous nodes): 0=child's baseline at the descent of the previous node, 1: subscript-node starts at the descent of the previous node

◆ getSpecialSuperShiftFactor()

double JKQTMathText::getSpecialSuperShiftFactor ( ) const

relative shift of text in superscript to normal text in special superscript mode (after large previous nodes): 0= superscript descent coincides with the previous node's baselineHeight, 1: top of previous node and top of the superscript nodes coincide

◆ getSqrtHeightFactor()

double JKQTMathText::getSqrtHeightFactor ( ) const

height-increase of the sqrt-symbol, as factor of the child's height

◆ getSqrtSmallFontFactor()

double JKQTMathText::getSqrtSmallFontFactor ( ) const

scaling factor for the small font used to indicate the degree of the sqrt

◆ getSqrtWidthXFactor()

double JKQTMathText::getSqrtWidthXFactor ( ) const

width of the sqrt-symbol, as factor to width("X")

◆ getSubShiftFactor()

double JKQTMathText::getSubShiftFactor ( ) const

relative shift of text in subscript to normal text, factor is multiplied by font.xHeight()

◆ getSubsuperModeSelectionBySizeFactor()

double JKQTMathText::getSubsuperModeSelectionBySizeFactor ( ) const

this factor is used to determine how to typeset sub-/superscript.

If the ascent for superscript of descent for subscript of the previous character is >=subsuper_mode_selection_by_size_factor*ascent(currentFont) or <=subsuper_mode_selection_by_size_factor*descent(currentFont) respectively, the sub/superscript is typeset, aligned with the ascent or descent of the previous character. Otherwise it is aligned with the default method:

Default mode:

Special mode:

This method fixes problems with characters that are significantyl larger that normal text character of the fonst, such as generated by \sum,\int,... .

◆ 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, factor is multiplied by font.xHeight()

◆ getUnderbraceBraceSizeXFactor()

double JKQTMathText::getUnderbraceBraceSizeXFactor ( ) const

height of the brace in underbrace/overbrace, multiplied with ascent

◆ getUnderbraceFactor()

double JKQTMathText::getUnderbraceFactor ( ) const

scaling factor for font of underbrace/overbrace text

◆ getUnderbraceSeparationXFactor()

double JKQTMathText::getUnderbraceSeparationXFactor ( ) const

additional space between the main text to the curly brace and the brace to underbrace/overbrace, multiplied with height("x")

◆ getUndersetFactor()

double JKQTMathText::getUndersetFactor ( ) const

scaling factor for font of underset/overset text

◆ hadErrors()

bool JKQTMathText::hadErrors ( ) const

returns true when errors were registered in the system

See also
error_list

◆ 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

◆ modifyEnvironmentFromFontSettings()

void JKQTMathText::modifyEnvironmentFromFontSettings ( JKQTMathTextEnvironment ev) const
protected

sets all properties of JKQTMathTextEnvironment ev from the fon settings stored in this class (e.g. fontSize, fontOptions, ...)

◆ parse() [1/2]

bool JKQTMathText::parse ( const QString &  markup,
DefaultParserTypes  markupType = DefaultParser,
ParseOptions  options = DefaultParseOptions 
)

parse the given math markup string with a parser derived from markupType.

Parameters
markupthe string of math markup
markupTypedefines the language the markup is written in (and is used to derive the parser to use)
optionsOptions for parsing,
See also
ParseOptions
Returns
true on success.

◆ parse() [2/2]

template<class TParser >
bool JKQTMathText::parse ( const QString &  markup,
ParseOptions  options = DefaultParseOptions 
)
inline

parse the given math markup string, using the given parser class TParser

Template Parameters
TParserthe parser (deived from JKQTMathTextParser) to be used
Parameters
markupthe string of math markup
optionsOptions for parsing,
See also
ParseOptions
Returns
true on success.

◆ 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

◆ setBigMathoperatorFontFactor()

void JKQTMathText::setBigMathoperatorFontFactor ( double  __value)

factor, used to increase the font size for big math operators, such as \sum , \prod , ...

◆ setBraceFactor()

void JKQTMathText::setBraceFactor ( double  __value)

for \left / \right braces: The brace is this factor higher than the child block it surrounds

◆ 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 fraction of the ascent

◆ setDecorationSeparationXFactor()

void JKQTMathText::setDecorationSeparationXFactor ( double  __value)

separation between the text and the decorations (dot, tilde, ...), as fraction of the ascent

◆ setDecorationWidthReductionFactor()

void JKQTMathText::setDecorationWidthReductionFactor ( double  __value)

a decoration has a size, which is slightly smaller than the text- width. the width is reduced by decoration_width_reduction_Xfactor*width("X") and the position is centered around the child-box. Also an italic correction is applied:

◆ setFallbackFontSymbols()

void JKQTMathText::setFallbackFontSymbols ( const QString &  fontName,
JKQTMathTextFontEncoding  encoding = JKQTMathTextFontEncoding::MTFEStandard 
)

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

See also
Font Handling

◆ setFontBlackboard()

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

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

See also
setFontBlackboardMode()

◆ setFontBlackboradMode()

void JKQTMathText::setFontBlackboradMode ( JKQTMathTextBlackboradDrawingMode  mode)

specifies how to draw blackboard font characters (i.e. \mathbb{N} )

Blackboard fonts are not widely available on target systems (viable fonts are e.g. "Double Stroke", "CloisterOpenFace BT", "GoudyHandtooled BT", "Castellar", "MathJax_AMS", "Castellar Standard", "MathJax_AMS Standard", "Colonna MT"). But the most important blackboard characters are usually available in the higher unicode codepoints of Fonts specialized for math (e.g. XIST, STIX, ASANA).

Therefore JKQTMathText supports using these characters, or simulating a blackboard font in addition to using one of the fonts above. You can set that by setting JKQTMathText::setFontBlackboradMode() with one of the options from JKQTMathTextBlackboradDrawingMode:

  • MTBBDMfontDirectly: use a blackboard font specified by JKQTMathText::setFontBlackboard()
    using JKQTMathText::setFontBlackboard("Castellar")
  • MTBBDMsimulate:
    using JKQTMathText::setFontBlackboard("Arial")
  • MTBBDMunicodeCharactersOrFontDirectly:
    using JKQTMathText::setFontBlackboard("Castellar")
  • MTBBDMunicodeCharactersOrSimulate:
    using JKQTMathText::setFontBlackboard("Arial")
See also
JKQTMathTextBlackboradDrawingMode, setFontBlackboard(), setBlackboardFontMode(), Font Handling

◆ setFontCaligraphic()

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

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

See also
Font Handling

◆ setFontColor()

void JKQTMathText::setFontColor ( const QColor &  __value)

font color

◆ setFontFraktur()

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

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

See also
Font Handling

◆ setFontMathRoman()

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

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

See also
Font Handling

◆ setFontMathSans()

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

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

See also
Font Handling

◆ setFontOption()

void JKQTMathText::setFontOption ( BaseFontOption  opt,
bool  enabled = true 
)

en/disable the given base font option

See also
BaseFontOptions

◆ setFontOptions()

void JKQTMathText::setFontOptions ( BaseFontOptions  opts)

set (overwrite) the options applied to the base font

See also
BaseFontOptions

◆ setFontPointSize()

void JKQTMathText::setFontPointSize ( double  __value)

set the default font size in points

See also
getFontSize(), fontSize, fontSizeUnits

◆ setFontRoman()

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

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

See also
Font Handling

◆ setFontRomanAndMath()

void JKQTMathText::setFontRomanAndMath ( const QString &  fontName,
JKQTMathTextFontEncoding  encoding = JKQTMathTextFontEncoding::MTFEStandard 
)

set the font fontName and it's encoding encoding to be used for text and math, i.e. the logical font MTEroman and MTEmathRoman

See also
Font Handling

◆ setFontRomanOrSpecial() [1/2]

void JKQTMathText::setFontRomanOrSpecial ( const JKQTMathTextFontSpecifier fontName,
JKQTMathTextFontEncoding  encoding = JKQTMathTextFontEncoding::MTFEStandard 
)

set the font by an instance of JKQTMathTextFontSpecifier

This allows to set the text-mode and math-mode roman fonts.

See also
JKQTMathTextFontSpecifier, setFontRoman(), setFontMathRoman(), Font Handling

◆ setFontRomanOrSpecial() [2/2]

void JKQTMathText::setFontRomanOrSpecial ( const QString &  fontName,
JKQTMathTextFontEncoding  encoding = JKQTMathTextFontEncoding::MTFEStandard 
)

set the font by parsing a special syntax defined in the description of JKQTMathTextFontSpecifier

This allows to set the text-mode and math-mode roman fonts.

Note
This function is a shorthand for
void setFontRomanOrSpecial(const QString &fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard)
set the font by parsing a special syntax defined in the description of JKQTMathTextFontSpecifier
static JKQTMathTextFontSpecifier fromFontSpec(const QString &fontSpec)
construct a JKQTMathTextFontSpecifier, by parsing a fontSpec string as defined in the struct descript...
See also
JKQTMathTextFontSpecifier, setFontRoman(), setFontMathRoman(), Font Handling

◆ setFontSans()

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

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

See also
Font Handling

◆ setFontScript()

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

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

See also
Font Handling

◆ setFontSize()

void JKQTMathText::setFontSize ( double  __value)

set the default font size in points

See also
getFontSize(), fontSize, fontSizeUnits

◆ setFontSizePixels()

void JKQTMathText::setFontSizePixels ( double  __value)

set the default font soze in pixels

See also
getFontSizePixels(), fontSize, fontSizeUnits

◆ setFontSpecial()

void JKQTMathText::setFontSpecial ( const QString &  fontSpec)

set font(s) from parsing a font specifier

This function understands a font-specifier in the following forms:

  • fontRoman - set "roman" and "math-roman" to fontRoman "sans"/"math-sans" are reset to the default, when constructing the object
  • fontRoman/fontSans - set "roman" and "math-roman" to fontRoman and "sans" and "math-sans" to fontSans
  • fontRoman/fontSans/fontMathRoman/fontMathSans - sets all four majpr fonts
  • any above with addition:
    • +XITS use XITS for math/symbols, calls useXITS()
    • +ASANA use ASANA for math/symbols, calls useASANA()
    • +STIX use STIX for math/symbols, calls useSTIX()
    • +FIRA use Fira Math for math/symbols, calls useFiraMath()
    • +BOLD make font initially bold
    • +ITALIC make font initially italic
    • +UNDERLINED make font initially underlines
    • +SMALLCAPS make font initially smallcaps

Font names can also be one of the special names, specified in the documentation of JKQTMathTextFontSpecifier and JKQTMathTextFontSpecifier::transformFontNameAndDecodeSpecialFonts()

◆ setFontTypewriter()

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

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

See also
Font Handling

◆ setFracFactor()

void JKQTMathText::setFracFactor ( double  __value)

scaling factor for font size of nominator and denominator of a fraction

◆ setFracNestedFactor()

void JKQTMathText::setFracNestedFactor ( double  __value)

scaling factor for font size of nominator and denominator of a nested fraction

◆ setFracShiftFactor()

void JKQTMathText::setFracShiftFactor ( double  __value)

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

◆ setIntSubBesidesXCorrectionXFactor()

void JKQTMathText::setIntSubBesidesXCorrectionXFactor ( double  __value)

for integrals (\int , \oint , ...) the subscripts besides the symbol have to be shifted to the left a bit to the left to accomodate the shape of the operator symbol (i.e. some free space at the bottom-right)

This factor is multiplied by the width of an x: xshift=intsubbesides_xcorrection_xfactor*xWidth Then the subscript besides the symbol is shifted by xshift to the left

This correction is applied to \int, \iint, \iiint, \oint, ...

◆ setIntSubSuperXCorrectionFactor()

void JKQTMathText::setIntSubSuperXCorrectionFactor ( double  __value)

for integrals (\int , \oint , ...) the sub-/superscripts above/below the symbol have to be shifted a bit to the left/right to accomodate the shape of the operator symbol (i.e. some free space at the top-left and bottom-right)

This factor is multiplied by the symbol width: xshift=intsubsuper_xcorrection_factor*symbolWidth Then the subscript below is placed at centerx(symbol)-xshift and the superscript at centerx(symbol)+shiftx. This is also used to correct a subset next to the symbol by shifting it to rightx(symbol)-xshift.

This correction is applied to \int, \iint, \iiint, \oint, ...

◆ setMathoperatorWidthFactor()

void JKQTMathText::setMathoperatorWidthFactor ( double  __value)

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

The next image demonstrates the effect of this property, which adds extra space around certain math operators in math mode:

◆ setMatrixLineSeparationFactor()

void JKQTMathText::setMatrixLineSeparationFactor ( double  factor)

separation of double-lines in tables, this factor is multiplied with the font.linewidth()

◆ setMatrixLinewidthHeavyFactor()

void JKQTMathText::setMatrixLinewidthHeavyFactor ( double  factor)

width of heavy table lines, this factor is multiplied with the current font.linewidth()

◆ setMatrixLinewidthThinFactor()

void JKQTMathText::setMatrixLinewidthThinFactor ( double  factor)

width of thin table lines, this factor is multiplied with the current font.linewidth()

◆ setMatrixXPaddingFactor()

void JKQTMathText::setMatrixXPaddingFactor ( double  factor)

x-padding of two columns, this factor is multiplied with the font.width("x")

◆ setMatrixXSeparationFactor()

void JKQTMathText::setMatrixXSeparationFactor ( double  factor)

x-separation of two columns, this factor is multiplied with the font.width("x")

◆ setMatrixYPaddingFactor()

void JKQTMathText::setMatrixYPaddingFactor ( double  factor)

y-padding of two columns, this factor is multiplied with the font.width("x")

◆ setMatrixYSeparationFactor()

void JKQTMathText::setMatrixYSeparationFactor ( double  factor)

y-separation of two columns, this factor is multiplied with the font.width("x")

◆ setOperatorsubsuperDistanceFactor()

void JKQTMathText::setOperatorsubsuperDistanceFactor ( double  __value)

for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the distance between the operator symbol and the sub-/super-text if multiplied by xHeight

◆ setOperatorsubsuperExtraSpaceFactor()

void JKQTMathText::setOperatorsubsuperExtraSpaceFactor ( double  __value)

for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the additional width added to the width of maximum width of the operator, above and below

◆ setOperatorsubsuperSizeFactor()

void JKQTMathText::setOperatorsubsuperSizeFactor ( double  __value)

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

◆ setSpecialSubShiftFactor()

void JKQTMathText::setSpecialSubShiftFactor ( double  __value)

relative shift of text in subscript to normal text in special superscript mode (after large previous nodes): 0=child's baseline at the descent of the previous node, 1: subscript-node starts at the descent of the previous node

◆ setSpecialSuperShiftFactor()

void JKQTMathText::setSpecialSuperShiftFactor ( double  __value)

relative shift of text in superscript to normal text in special superscript mode (after large previous nodes): 0= superscript descent coincides with the previous node's baselineHeight, 1: top of previous node and top of the superscript nodes coincide

◆ setSqrtHeightFactor()

void JKQTMathText::setSqrtHeightFactor ( double  __value)

height-increase of the sqrt-symbol, as factor of the child's height

◆ setSqrtSmallFontFactor()

void JKQTMathText::setSqrtSmallFontFactor ( double  __value)

scaling factor for the small font used to indicate the degree of the sqrt

◆ setSqrtWidthXFactor()

void JKQTMathText::setSqrtWidthXFactor ( double  __value)

width of the sqrt-symbol, as factor to width("X")

◆ setSubShiftFactor()

void JKQTMathText::setSubShiftFactor ( double  __value)

relative shift of text in subscript to normal text, factor is multiplied by font.xHeight()

◆ setSubsuperModeSelectionBySizeFactor()

void JKQTMathText::setSubsuperModeSelectionBySizeFactor ( double  __value)

this factor is used to determine how to typeset sub-/superscript.

If the ascent for superscript of descent for subscript of the previous character is >=subsuper_mode_selection_by_size_factor*ascent(currentFont) or <=subsuper_mode_selection_by_size_factor*descent(currentFont) respectively, the sub/superscript is typeset, aligned with the ascent or descent of the previous character. Otherwise it is aligned with the default method:

Default mode:

Special mode:

This method fixes problems with characters that are significantyl larger that normal text character of the fonst, such as generated by \sum,\int,... .

◆ 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, factor is multiplied by font.xHeight()

◆ setUnderbraceBraceSizeXFactor()

void JKQTMathText::setUnderbraceBraceSizeXFactor ( double  __value)

height of the brace in underbrace/overbrace, multiplied with ascent

◆ setUnderbraceFactor()

void JKQTMathText::setUnderbraceFactor ( double  __value)

scaling factor for font of underbrace/overbrace text

◆ setUnderbraceSeparationXFactor()

void JKQTMathText::setUnderbraceSeparationXFactor ( double  __value)

additional space between the main text to the curly brace and the brace to underbrace/overbrace, multiplied with height("x")

◆ setUndersetFactor()

void JKQTMathText::setUndersetFactor ( double  __value)

scaling factor for font of underset/overset text

◆ String2BaseFontOptions()

static BaseFontOptions JKQTMathText::String2BaseFontOptions ( const QString &  s)
static

convert a string (generated by BaseFontOptions2String() to BaseFontOptions

◆ 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,
const QString &  sansFont,
JKQTMathTextFontEncoding  encodingTimes = JKQTMathTextFontEncoding::MTFEUnicode,
JKQTMathTextFontEncoding  encodingSans = JKQTMathTextFontEncoding::MTFEUnicode 
)

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

Note
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.

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

br
useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");:

useAnyUnicodeForMathOnly("Comic Sans MS", "Comic Sans MS");:

See also
useAnyUnicodeForMathOnly(), useAnyUnicodeForTextOnly(), Font Handling

◆ useAnyUnicodeForMathOnly()

void JKQTMathText::useAnyUnicodeForMathOnly ( QString  timesFont,
const QString &  sansFont,
JKQTMathTextFontEncoding  encodingTimes = JKQTMathTextFontEncoding::MTFEUnicode,
JKQTMathTextFontEncoding  encodingSans = JKQTMathTextFontEncoding::MTFEUnicode 
)

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

Note
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.

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

br
useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");:

useAnyUnicodeForMathOnly("Comic Sans MS", "Comic Sans MS");:

See also
useAnyUnicodeForTextOnly(), useAnyUnicode(), Font Handling

◆ useAnyUnicodeForTextOnly()

void JKQTMathText::useAnyUnicodeForTextOnly ( QString  timesFont,
const QString &  sansFont,
JKQTMathTextFontEncoding  encodingTimes = JKQTMathTextFontEncoding::MTFEUnicode,
JKQTMathTextFontEncoding  encodingSans = JKQTMathTextFontEncoding::MTFEUnicode 
)

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

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

br
useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");:

useAnyUnicodeForMathOnly("Comic Sans MS", "Comic Sans MS");:

See also
useAnyUnicodeForMathOnly(), useAnyUnicode(), Font Handling

◆ useASANA()

bool JKQTMathText::useASANA ( bool  mathModeOnly = true,
bool  useAsFallbackSymbol = 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 or in math and text-mode (if mathModeOnly ==false )

If useAsFallbackSymbol is set ==true then the XITS fonts are also used as MTEFallbackSymbols

This function does not only use default font-names for ASANA, but searches the font database of the system with several different variants, using JKQTMathTextFontSpecifier::getASANAFamilies(). It also sets the special math-variant of ASANA for math mode and the normal variant for text-mode

See also
Font Handling

◆ useFiraMath()

bool JKQTMathText::useFiraMath ( bool  mathModeOnly = true,
bool  useAsFallbackSymbol = true 
)

configures the class to use the Fira Math fonts in mathmode

use Fira Math fonts from https://github.com/firamath/firamath in math-mode or in math and text-mode (if mathModeOnly ==false ).

If useAsFallbackSymbol is set ==true then the Fira Math fonts are also used as MTEFallbackSymbols

Note
The Fira Math fonts can be compiled into JKQTPlotter, when the CMake-option JKQtPlotter_BUILD_INCLUDE_FIRAMATH_FONTS is set to ON (default: ON). Then the Fira Math fonts are added as Qt-Ressources to the library binary. If this is not the case, you have to provide the Fira Math fonts on the target system by other means, if you want to use them.

This function does not only use default font-names for Fira Math, but searches the font database of the system with several different variants, using JKQTMathTextFontSpecifier::getFIRAFamilies(). It also sets the special math-variant of Fira for math mode and the normal variant for text-mode

See also
Font Handling

◆ useGuiFonts()

bool JKQTMathText::useGuiFonts ( )

configures the class to be used for GUI output, i.e. tries to find fonts that are harmonious for the default GUI font, sets the default GUI font for "roman" and finds an oppposite font for "sans", which means that "sans" may actually be a serif font,when the app font is sans serif!

See also
Font Handling

◆ useSTIX()

bool JKQTMathText::useSTIX ( bool  mathModeOnly = true,
bool  useAsFallbackSymbol = 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 or in math and text-mode (if mathModeOnly ==false )

If useAsFallbackSymbol is set ==true then the XITS fonts are also used as MTEFallbackSymbols

This function does not only use default font-names for STIX, but searches the font database of the system with several different variants, using JKQTMathTextFontSpecifier::getSTIXFamilies(). It also sets the special math-variant of STIX for math mode and the normal variant for text-mode

See also
Font Handling

◆ useXITS()

bool JKQTMathText::useXITS ( bool  mathModeOnly = true,
bool  useAsFallbackSymbol = true 
)

configures the class to use the XITS fonts in mathmode

use XITS fonts from https://github.com/alif-type/xits in math-mode or in math and text-mode (if mathModeOnly ==false ).

If useAsFallbackSymbol is set ==true then the XITS fonts are also used as MTEFallbackSymbols

Note
The XITS fonts can be compiled into JKQTPlotter, when the CMake-option JKQtPlotter_BUILD_INCLUDE_XITS_FONTS is set to ON (default: ON). Then the XITS fonts are added as Qt-Ressources to the library binary. If this is not the case, you have to provide the XITS fonts on the target system by other means, if you want to use them.

This function does not only use default font-names for XITS, but searches the font database of the system with several different variants, using JKQTMathTextFontSpecifier::getXITSFamilies(). It also sets the special math-variant of XITS for math mode and the normal variant for text-mode

See also
Font Handling

Friends And Related Symbol Documentation

◆ JKQTMathTextNode

friend class JKQTMathTextNode
friend

◆ JKQTMathTextParser

friend class JKQTMathTextParser
friend

Member Data Documentation

◆ ABS_MIN_LINEWIDTH

const double JKQTMathText::ABS_MIN_LINEWIDTH
static

minimum linewidth allowed in a JKQTMathText (given in pt)

◆ bigmathoperator_font_factor

double JKQTMathText::bigmathoperator_font_factor
protected

factor, used to increase the font size for big math operators, such as \sum , \prod , ...

◆ blackboradFontMode

JKQTMathTextBlackboradDrawingMode JKQTMathText::blackboradFontMode
protected

specifies how to draw blackboard font characters (i.e. \mathbb{N} )

Blackboard fonts are not widely available on target systems (viable fonts are e.g. "Double Stroke", "CloisterOpenFace BT", "GoudyHandtooled BT", "Castellar", "MathJax_AMS", "Castellar Standard", "MathJax_AMS Standard", "Colonna MT"). But the most important blackboard characters are usually available in the higher unicode codepoints of Fonts specialized for math (e.g. XIST, STIX, ASANA).

Therefore JKQTMathText supports using these characters, or simulating a blackboard font in addition to using one of the fonts above. You can set that by setting JKQTMathText::setFontBlackboradMode() with one of the options from JKQTMathTextBlackboradDrawingMode:

  • MTBBDMfontDirectly: use a blackboard font specified by JKQTMathText::setFontBlackboard()
    using JKQTMathText::setFontBlackboard("Castellar")
  • MTBBDMsimulate:
    using JKQTMathText::setFontBlackboard("Arial")
  • MTBBDMunicodeCharactersOrFontDirectly:
    using JKQTMathText::setFontBlackboard("Castellar")
  • MTBBDMunicodeCharactersOrSimulate:
    using JKQTMathText::setFontBlackboard("Arial")
See also
JKQTMathTextBlackboradDrawingMode, setFontBlackboard(), setBlackboardFontMode(), Font Handling

◆ brace_factor

double JKQTMathText::brace_factor
protected

for \left / \right braces: The brace is this factor higher than the child block it surrounds

◆ brace_y_shift_factor

double JKQTMathText::brace_y_shift_factor
protected

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

◆ decoration_height_factor

double JKQTMathText::decoration_height_factor
protected

size of the decorations (dot, tilde, ...), as fraction of the ascent

◆ decoration_separation_factor

double JKQTMathText::decoration_separation_factor
protected

separation between the text and the decorations (dot, tilde, ...), as fraction of the ascent

◆ decoration_width_reduction_Xfactor

double JKQTMathText::decoration_width_reduction_Xfactor
protected

a decoration has a size, which is slightly smaller than the text- width. the width is reduced by decoration_width_reduction_Xfactor*width("X") and the position is centered around the child-box. Also an italic correction is applied:

◆ error_list

QStringList JKQTMathText::error_list
protected

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

This list of errors is (mostly) filled during a call to parse(). During rendering (e.g. with draw() ) only very few errors will be detected, as most errors are caused by wrong markup.

A call to parse() also clears this list.

See also
getErrorList(), hadErrors() and addToErrorList()

◆ fontColor

QColor JKQTMathText::fontColor
protected

font color

◆ fontDefinitions

QHash<JKQTMathTextEnvironmentFont, JKQTMathTextFontDefinition> JKQTMathText::fontDefinitions
protected

stores information about the different fonts used by LaTeX markup

◆ fontEncodingReplacements

QMap<QString, JKQTMathTextFontEncoding> 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!

◆ fontOptions

BaseFontOptions JKQTMathText::fontOptions
protected

additional options for the base fonts

◆ 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 the units defined in fontSizeUnits

See also
fontSizeUnits

◆ fontSizeUnits

JKQTMathTextEnvironment::FontSizeUnit JKQTMathText::fontSizeUnits
protected

unit of fontSize

◆ frac_factor

double JKQTMathText::frac_factor
protected

scaling factor for font size of nominator and denominator of a fraction

◆ frac_nested_factor

double JKQTMathText::frac_nested_factor
protected

scaling factor for font size of nominator and denominator of a nested fraction

◆ frac_shift_factor

double JKQTMathText::frac_shift_factor
protected

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

◆ init_blackboardFont

QString JKQTMathText::init_blackboardFont
staticprotected

initial choice for "blackboard" font

◆ init_caligraphicFont

QString JKQTMathText::init_caligraphicFont
staticprotected

initial choice for "caligraphic" font

◆ init_fracturFont

QString JKQTMathText::init_fracturFont
staticprotected

initial choice for "fraktur" font

◆ init_sansFont

QString JKQTMathText::init_sansFont
staticprotected

initial choice for "sans-erif" font

◆ init_scriptFont

QString JKQTMathText::init_scriptFont
staticprotected

initial choice for "script" font

◆ init_serifFont

QString JKQTMathText::init_serifFont
staticprotected

initial choice for "serif" font

◆ init_symbolFont

QString JKQTMathText::init_symbolFont
staticprotected

initial choice for "fallback symbol" font

◆ init_typewriterFont

QString JKQTMathText::init_typewriterFont
staticprotected

initial choice for "typewriter" font

◆ intsubbesides_xcorrection_xfactor

double JKQTMathText::intsubbesides_xcorrection_xfactor
protected

for integrals (\int , \oint , ...) the subscripts besides the symbol have to be shifted to the left a bit to the left to accomodate the shape of the operator symbol (i.e. some free space at the bottom-right)

This factor is multiplied by the width of an x: xshift=intsubbesides_xcorrection_xfactor*xWidth Then the subscript besides the symbol is shifted by xshift to the left

This correction is applied to \int, \iint, \iiint, \oint, ...

◆ intsubsuper_xcorrection_factor

double JKQTMathText::intsubsuper_xcorrection_factor
protected

for integrals (\int , \oint , ...) the sub-/superscripts above/below the symbol have to be shifted a bit to the left/right to accomodate the shape of the operator symbol (i.e. some free space at the top-left and bottom-right)

This factor is multiplied by the symbol width: xshift=intsubsuper_xcorrection_factor*symbolWidth Then the subscript below is placed at centerx(symbol)-xshift and the superscript at centerx(symbol)+shiftx. This is also used to correct a subset next to the symbol by shifting it to rightx(symbol)-xshift.

This correction is applied to \int, \iint, \iiint, \oint, ...

◆ mathoperator_width_factor

double JKQTMathText::mathoperator_width_factor
protected

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

The next image demonstrates the effect of this property, which adds extra space around certain math operators in math mode:

◆ matrix_line_separation_factor

double JKQTMathText::matrix_line_separation_factor
protected

separation of double-lines in tables, this factor is multiplied with the font.linewidth()

◆ matrix_linewidth_heavy_factor

double JKQTMathText::matrix_linewidth_heavy_factor
protected

width of heavy table lines, this factor is multiplied with the current font.linewidth()

◆ matrix_linewidth_thin_factor

double JKQTMathText::matrix_linewidth_thin_factor
protected

width of thin table lines, this factor is multiplied with the current font.linewidth()

◆ matrix_xPadding_factor

double JKQTMathText::matrix_xPadding_factor
protected

x-padding of two columns, this factor is multiplied with the font.width("x")

◆ matrix_xSeparation_factor

double JKQTMathText::matrix_xSeparation_factor
protected

x-separation of two columns, this factor is multiplied with the font.width("x")

◆ matrix_yPadding_factor

double JKQTMathText::matrix_yPadding_factor
protected

y-padding of two columns, this factor is multiplied with the font.width("x")

◆ matrix_ySeparation_factor

double JKQTMathText::matrix_ySeparation_factor
protected

y-separation of two columns, this factor is multiplied with the font.width("x")

◆ operatorsubsuper_distance_factor

double JKQTMathText::operatorsubsuper_distance_factor
protected

for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the distance between the operator symbol and the sub-/super-text if multiplied by xHeight

◆ operatorsubsuper_extraspace_factor

double JKQTMathText::operatorsubsuper_extraspace_factor
protected

for operators (\sum , \int , ...) where the text is placed above/below the symbol, this is the additional width added to the width of maximum width of the operator, above and below

◆ 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

JKQTMathTextNode* JKQTMathText::parsedNode
protected

the syntax tree of JKQTMathTextNode's that was created by the last parse() call

◆ s_firstStart

bool JKQTMathText::s_firstStart
staticprotected

used to check for the first construction of a JKQTMathText ... if true several static variables are initialized in the constructor

◆ s_mutex

std::mutex JKQTMathText::s_mutex
staticprotected

mutex to protect the static members

◆ special_sub_shift_factor

double JKQTMathText::special_sub_shift_factor
protected

relative shift of text in subscript to normal text in special superscript mode (after large previous nodes): 0=child's baseline at the descent of the previous node, 1: subscript-node starts at the descent of the previous node

◆ special_super_shift_factor

double JKQTMathText::special_super_shift_factor
protected

relative shift of text in superscript to normal text in special superscript mode (after large previous nodes): 0= superscript descent coincides with the previous node's baselineHeight, 1: top of previous node and top of the superscript nodes coincide

◆ sqrt_height_factor

double JKQTMathText::sqrt_height_factor
protected

height-increase of the sqrt-symbol, as factor of the child's height

◆ sqrt_smallfont_factor

double JKQTMathText::sqrt_smallfont_factor
protected

scaling factor for the small font used to indicate the degree of the sqrt

◆ sqrt_width_Xfactor

double JKQTMathText::sqrt_width_Xfactor
protected

width of the sqrt-symbol, as factor to width("X")

◆ sub_shift_factor

double JKQTMathText::sub_shift_factor
protected

relative shift of text in subscript to normal text, factor is multiplied by font.xHeight()

◆ subsuper_mode_selection_by_size_factor

double JKQTMathText::subsuper_mode_selection_by_size_factor
protected

this factor is used to determine how to typeset sub-/superscript.

If the ascent for superscript of descent for subscript of the previous character is >=subsuper_mode_selection_by_size_factor*ascent(currentFont) or <=subsuper_mode_selection_by_size_factor*descent(currentFont) respectively, the sub/superscript is typeset, aligned with the ascent or descent of the previous character. Otherwise it is aligned with the default method:

Default mode:

Special mode:

This method fixes problems with characters that are significantyl larger that normal text character of the fonst, such as generated by \sum,\int,... .

◆ 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, factor is multiplied by font.xHeight()

◆ underbrace_bracesize_xfactor

double JKQTMathText::underbrace_bracesize_xfactor
protected

height of the brace in underbrace/overbrace, multiplied with ascent

◆ underbrace_factor

double JKQTMathText::underbrace_factor
protected

scaling factor for font of underbrace/overbrace text

◆ underbrace_separation_xfactor

double JKQTMathText::underbrace_separation_xfactor
protected

additional space between the main text to the curly brace and the brace to underbrace/overbrace, multiplied with height("x")

◆ underset_factor

double JKQTMathText::underset_factor
protected

scaling factor for font of underset/overset text


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