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
|
As LaTeX also does, fonts are set by font classes. These are defined in JKQTMathTextEnvironmentFont:
\sf
... ( JKQTMathText::setFontSans() and for use in math mode JKQTMathText::setFontMathSans() )\tt
... ( JKQTMathText::setFontTypewriter() )\script
... ( JKQTMathText::setFontScript() )The default font class is "roman" (i.e. MTEroman in text-mode and MTEmathRoman in math-mode). You can switch to "sans-serif" by using LaTeX commands like \sf
.
Especially when using the library in the context of a GUI, usually a sans-serif font is used to typeset text in the GUI as these are generally better readable on a screen than serif fonts. Therefore when using JKQTMathText for GUI rendering, it makes sense to redefine the class "roman" with the GUI font. You can e.g. write:
or the short hand:
With JKQTMathTextFontSpecifier::fromFontSpec() there is a third way that allows to use a special string syntax (handy for INI files) to define fonts, see JKQTMathTextFontSpecifier . You can e.g. simply write:
In all cases the default GUI font is used for rendering default output. For \sf
to make a difference you can additionally set the "sans" class as a serif font, e.g.:
Using the font name "serif"
will cause Qt to lookup a suitable serif font.
These fonts are generic font classes, which font is actually used can be configured in JKQTMathText class with the set
...() functions mentioned above. Additionally some short ahnds exist:
Here are some examples of using different, widely available, fonts:
JKQTMathText::setFontRomanAndMath("Arial")
:JKQTMathText::setFontRomanAndMath("Courier New")
:JKQTMathText::setFontRomanAndMath("Comic Sans MS")
:JKQTMathText::setFontRomanAndMath("Old English Text")
:JKQTMathText::setFontRomanAndMath("CMU Serif")
:JKQTMathText::setFontRoman("Fira Sans"); setFontMathRoman("Fira Math")
:JKQTMathText::setFontRomanAndMath("MS Segoe UI")
:JKQTMathText::setFontRomanAndMath("DejaVu Sans")
:JKQTMathText::setFontRomanAndMath("DejaVu Serif")
:JKQTMathText::useXITS(false)
:JKQTMathText::setFontRomanAndMath("Noto Sans", "Noto Sans Math")
:JKQTMathText::setFontRomanAndMath("Noto Serif", "Noto Serif")
:Math-mode is activated by enclosing your equation in $
...$ or \
[...\] . This mode is optimized for mathematical equations. Here is an example of the difference:
Font Lookup for symbols works as follows in JKQTMathTextSymbolNode:
In "normal text", i.e. JKQTMathTextTextNode no font-lookup is perfomed, i.e. if a acharacter is not available in the selected font, it is not typeset (or typeset with a replacement, like a box). There are exceptions to this rule however: For some special fonts a lookup or synthetisation of the characters is performed. Currently this is implemented for: