As LaTeX also does, fonts are set by font classes. These are defined in JKQTMathTextEnvironmentFont:
- A "roman" (MTEroman / MTEmathRoman) font used as the standard font ( JKQTMathText::setFontRoman() and for use in math mode JKQTMathText::setFontMathRoman() )
- A "sans-serif" (MTEsans / MTEmathSans) font which may be activated with \c \\sf ... ( JKQTMathText::setFontSans() and for use in math mode JKQTMathText::setFontMathSans() )
- A "typewriter" (MTEtypewriter) font which may be activated with \c \\tt ... ( JKQTMathText::setFontTypewriter() )
- A "script" (MTEscript) font which may be activated with \c \\script ... ( JKQTMathText::setFontScript() )
- A "math-roman" (MTEmathRoman) font used as the standard font in math mode ( JKQTMathText::setFontMathRoman() )
- A "math-sans-serif" (MTEmathSans) used as sans serif font in math mode ( JKQTMathText::setFontMathSans() )
- A "blackboard" (MTEblackboard) font used to display double stroked characters ( JKQTMathText::setFontBlackboard() )
- A "caligraphic" (MTEcaligraphic) font used to display caligraphic characters ( JKQTMathText::setFontCaligraphic() )
- A "fraktur" (MTEfraktur) font used to display fraktur characters ( JKQTMathText::setFontFraktur() )
- A fallback font MTEFallbackSymbols for (math) symbols, greek letters ... (if the symbols are not present in the currently used font). ( JKQTMathText::setFallbackFontSymbols() )
.
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 \c \\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:
In all cases the default GUI font is used for rendering default output. For \c \\sf to make a difference you can additionally
set the "sans" class as a serif font, e.g.:
\code
JKQTMathText::setFontSans("serif");
JKQTMathText::setFontMathSans("serif");
\endcode
Using the font name \c "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 \c set...() functions mentioned above. Additionally some short ahnds exist:
- JKQTMathText::useSTIX() use the STIX fonts from <a href="https://www.stixfonts.org/">https://www.stixfonts.org/</a> in math-mode (or math- and text-mode, additionally also as MTEFallbackSymbols)<br>\image html jkqtmathtext/jkqtmathtext_stix.png
- JKQTMathText::useXITS() use the XITS fonts from <a href="https://github.com/alif-type/xits">https://github.com/alif-type/xits</a> in math-mode (or math- and text-mode, additionally also as MTEFallbackSymbols). These are included by default in this library and also activated by default.<br>\image html jkqtmathtext/jkqtmathtext_xits.png
- JKQTMathText::useASANA() use the ASANA fonts from <a href="https://ctan.org/tex-archive/fonts/Asana-Math/">https://ctan.org/tex-archive/fonts/Asana-Math/</a> in math-mode (or math- and text-mode, additionally also as MTEFallbackSymbols)<br>\image html jkqtmathtext/jkqtmathtext_asana.png
- JKQTMathText::useFiraMath() use the Fira Math fonts from <a href="https://github.com/firamath/firamath">https://github.com/firamath/firamath</a> in math-mode (or math- and text-mode, additionally also as MTEFallbackSymbols)<br>\image html jkqtmathtext/jkqtmathtext_usefira.png
- JKQTMathText::useGuiFonts() use the default application font (e.g. Segoe UI on Win10/11) for the "roman" and "math-roman" and try to determine mathing fonts for "sans"/"math-sans" and MTEFallbackSymbols.<br>\image html jkqtmathtext/jkqtmathtext_useguifonts.png
Here are some examples of using different, widely available, fonts:
- using "Arial" <c>JKQTMathText::setFontRomanAndMath("Arial")</c>: \image html jkqtmathtext/jkqtmathtext_arial.png
- using "Courier New" <c>JKQTMathText::setFontRomanAndMath("Courier New")</c>: \image html jkqtmathtext/jkqtmathtext_couriernew.png
- using "Comic Sans MS" <c>JKQTMathText::setFontRomanAndMath("Comic Sans MS")</c>: \image html jkqtmathtext/jkqtmathtext_comicsans.png
- using "Old English Text" <c>JKQTMathText::setFontRomanAndMath("Old English Text")</c>: \image html jkqtmathtext/jkqtmathtext_OldEnglish.png
- using "Computer Modern" <c>JKQTMathText::setFontRomanAndMath("CMU Serif")</c>: \image html jkqtmathtext/jkqtmathtext_computermodern.png
- using <a href="https://en.wikipedia.org/wiki/Fira_(typeface)">"Fira"</a> <c>JKQTMathText::setFontRoman("Fira Sans"); setFontMathRoman("Fira Math")</c>: \image html jkqtmathtext/jkqtmathtext_fira.png
- using "MS Segoe UI" (the default Win 10/11 GUI font) <c>JKQTMathText::setFontRomanAndMath("MS Segoe UI")</c>: \image html jkqtmathtext/jkqtmathtext_mssegoeui.png
- using <a href="https://dejavu-fonts.github.io/">"DejaVu Sans"</a> <c>JKQTMathText::setFontRomanAndMath("DejaVu Sans")</c>: \image html jkqtmathtext/jkqtmathtext_DejaVuSans.png
- using <a href="https://dejavu-fonts.github.io/">"DejaVu Serif"</a> <c>JKQTMathText::setFontRomanAndMath("DejaVu Serif")</c>: \image html jkqtmathtext/jkqtmathtext_DejaVuSerif.png
- using "XITS" <c>JKQTMathText::useXITS(false)</c>: \image html jkqtmathtext/jkqtmathtext_xits_all.png