From 07d3fdcd99e58f89d35cceb34b4df0432ead7a83 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 21 Aug 2022 14:49:48 +0200 Subject: [PATCH] JKQTMAthText: improvements in font handling and documentation --- doc/dox/jkqtmathtext_fonthandling.dox | 104 +++++++ .../jkqtmathtext_comicsans_mathonly.png | Bin 0 -> 5950 bytes doc/images/jkqtmathtext/jkqtmathtext_stix.png | Bin 7213 -> 7377 bytes doc/jkqtmathtext_docimages_specialfonts.jkmt | 6 +- lib/jkqtmathtext/jkqtmathtext.cpp | 44 ++- lib/jkqtmathtext/jkqtmathtext.h | 255 +++++++++++------- lib/jkqtmathtext/jkqtmathtexttools.cpp | 49 +++- lib/jkqtmathtext/jkqtmathtexttools.h | 34 ++- 8 files changed, 357 insertions(+), 135 deletions(-) create mode 100644 doc/dox/jkqtmathtext_fonthandling.dox create mode 100644 doc/images/jkqtmathtext/jkqtmathtext_comicsans_mathonly.png diff --git a/doc/dox/jkqtmathtext_fonthandling.dox b/doc/dox/jkqtmathtext_fonthandling.dox new file mode 100644 index 0000000000..c2bf027979 --- /dev/null +++ b/doc/dox/jkqtmathtext_fonthandling.dox @@ -0,0 +1,104 @@ +/*! + + \defgroup jkqtmathtext_fonthandling Font Handling + \ingroup jkqtmathtext_general + + + + 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: + \code + JKQTMathText::setFontRoman(QGuiApplication::font().family(), MTFEUnicode); + JKQTMathText::setFontMathRoman(QGuiApplication::font().family(), MTFEUnicode); + JKQTMathText::setFontSize(QGuiApplication::font().pointSize()); + \endcode + or the short hand: + \code + JKQTMathText::setFontRomanAndMath(QGuiApplication::font().family(), MTFEUnicode); + \endcode + 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: + \code + JKQTMathText::setFontRomanAndMath("application+XITS", MTFEUnicode); + \endcode + 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 https://www.stixfonts.org/ in math-mode (or math- and text-mode, additionally also as MTEFallbackSymbols)
\image html jkqtmathtext/jkqtmathtext_stix.png + - JKQTMathText::useXITS() use the XITS fonts from https://github.com/alif-type/xits 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.
\image html jkqtmathtext/jkqtmathtext_xits.png + - JKQTMathText::useASANA() use the ASANA fonts from https://ctan.org/tex-archive/fonts/Asana-Math/ in math-mode (or math- and text-mode, additionally also as MTEFallbackSymbols)
\image html jkqtmathtext/jkqtmathtext_asana.png + - JKQTMathText::useAnyUnicode() set fonts for "roman" and "sans" in text- and math-mode with one call + - JKQTMathText::useAnyUnicodeForMathOnly() set fonts for "roman" and "sans" in math-mode only with one call, leaves text-mode fonts as is + - JKQTMathText::useAnyUnicodeForTextOnly() set fonts for "roman" and "sans" in text-mode only with one call, leaves math-mode fonts as is + - JKQTMathText::setFontRomanAndMath() set "roman" font in text- and math-mode + - JKQTMathText::setFontRomanOrSpecial() use an object of type JKQTMathTextFontSpecifier or a special string syntax (see struct documentation + of JKQTMathTextFontSpecifier) to define the text- and math-mode "roman" fonts + . + + Here are some examples of using different, widely available, fonts: + - using "Arial" JKQTMathText::setFontRomanAndMath("Arial"): \image html jkqtmathtext/jkqtmathtext_arial.png + - using "Courier New" JKQTMathText::setFontRomanAndMath("Courier New"): \image html jkqtmathtext/jkqtmathtext_couriernew.png + - using "Comic Sans MS" JKQTMathText::setFontRomanAndMath("Comic Sans MS"): \image html jkqtmathtext/jkqtmathtext_comicsans.png + - using "Old English Text" JKQTMathText::setFontRomanAndMath("Old English Text"): \image html jkqtmathtext/jkqtmathtext_OldEnglish.png + - using "Computer Modern" JKQTMathText::setFontRomanAndMath("CMU Serif"): \image html jkqtmathtext/jkqtmathtext_computermodern.png + - using "Fira" JKQTMathText::setFontRoman("Fira Sans"); setFontMathRoman("Fira Math"): \image html jkqtmathtext/jkqtmathtext_fira.png + - using "MS Segoe UI" (the default Win 10/11 GUI font) JKQTMathText::setFontRomanAndMath("MS Segoe UI"): \image html jkqtmathtext/jkqtmathtext_mssegoeui.png + - using "DejaVu Sans" JKQTMathText::setFontRomanAndMath("DejaVu Sans"): \image html jkqtmathtext/jkqtmathtext_DejaVuSans.png + - using "DejaVu Serif" JKQTMathText::setFontRomanAndMath("DejaVu Serif"): \image html jkqtmathtext/jkqtmathtext_DejaVuSerif.png + - using "XITS" JKQTMathText::useXITS(false): \image html jkqtmathtext/jkqtmathtext_xits_all.png + . + + Math-mode is activated by enclosing your equation in \c $...$ or \c \\[...\\] . + This mode is optimized for mathematical equations. Here is an example of the difference: + - math-mode: + - use fonts MTEmathRoman and MTEmathSans + - whitespaces are mostly not drawn directly + - symbol spacing is different + - an example: \image html jkqtmathtext/schreq_mathmode.png + . + - text-mode: + - use fonts MTEroman and MTEsans + - whitespaces are evaluated directly + - an example: \image html jkqtmathtext/schreq_normalmode.png + . + + Font Lookup for symbols works as follows in JKQTMathTextSymbolNode: + - if a character is found in the current (or to be used) font, it is taken from there + - if the character is not found, it is looked for in the fallback fonts MTEFallbackSymbols + - as a last resort, some symbols can be created otherwise, so if neither of the two options above + contain the required symbol, the symbol might be synthesized otherwise, or a rectangle with the size of "X" is drawn instead + . + + 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: + - "blackboard", the options are defined by setBlackboardFontMode(). See JKQTMathTextBlackboradDrawingMode + . + +*/ diff --git a/doc/images/jkqtmathtext/jkqtmathtext_comicsans_mathonly.png b/doc/images/jkqtmathtext/jkqtmathtext_comicsans_mathonly.png new file mode 100644 index 0000000000000000000000000000000000000000..d3a02251f793e67a9a0e2486e558c1536a119103 GIT binary patch literal 5950 zcmbVwcQjjn{C-+3EvmKEYMa)sy*IU5Ge)ftGip}Ftlg?zR1vEvDvH`8R?wOuR#lbM zPClp@p|aZbMNck_iH`R>xqXL>fE4arv`yQH=aD!Gy#DwEdl46 z*C>I#EnbEI9In53Y~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U~pBKQc}mY{^1a{^|cr`=8+HbQI85go{DhNE$4Vtxz%Xu zD-RG6&3 literal 0 HcmV?d00001 diff --git a/doc/images/jkqtmathtext/jkqtmathtext_stix.png b/doc/images/jkqtmathtext/jkqtmathtext_stix.png index 3e70e7bec94d171c45ebb836ac017d97011630be..2a0e629c36be3c801c70856850515160dbb0b5bc 100644 GIT binary patch literal 7377 zcmb`Mhc{eb)b~f!sEG{GgXoOji58vc#1PSYjot~-jXru8LbNC|f*=yndpClJ8Vu1p z@Ab>G-u3(e&su|7cRBZ*d-lHjyT6|kqotulginPJ0)dEBl;w3mpnJ){_h)!G!0%%R zejnh^eK%#O2M9!5c=v;WyM#UhfoQ^2bWHw#sGv7M@v>iC{5M?v5fX1wM7pA6Efo14Y%hVir=k$Uef znz+1~CM#z9i2gH}C9p;wWj@UeEHfT6J3HI$cuW6Pn?D(_2(!7>Bx}m*>S`#iHZ+}& zmp6274$2lArpy%fR4IWzOPySgP8(bobm{%7BbYX}`0K`@`9#@^=$@6WQwg8lcg1YV zEUB4!c_xoAZy#w&zO8&&`@6bn@mt&JqA{=lqE531ZEbB10senVGo}Z--kEdU2lle; z-kauE6x7tunMg4}lT%aB{L60yJcVUtIH1wR#e@;5%c@_h@0a#^4i5N{PILD_6f`tl zH`kXBVTu?a(~I$p2Y6T@kV_MFaL1DrCNe!7n`>TC(P%?1oL?FN7u%+{u^rcFSA~Xp z0YXb+Ahf#6zLIoK^T?qiiHw1WiwpmSI-cPDxQ{web-AJkHwPIVz>^l&)$ySNWFN$G zV>U>+wJw}>k_3mUWpKld!I99HcX1~h92_KcaCFqx*Dt+zYGcHb@WbM4*Qdjnl)1j9 zhM45pkyiGU09@7F+#Ca!gpR9)aPXq2t&O(Hb&0!)g0P{+49E@+uu6*C{%-~4ly`X& zJ|AzQ8=aiIZzd>km^TCqEzhk^mK7=XBA0UCw)t6>(ni?%C~fg zvD->F(OtCO{rB*ZOM6kpY(OOB8Ixs9O!BB`uh(;2zik}Kf)%`YU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4s-tC+DJyv`6iJ@zyWWB!t5GW$DxQq& zXM#ApK=CE((rtV*KbQb>`5oZp1soQe=&!uX-5PFRS^xk-{#Nu09BNtue)sNOJt$Pb zp+bj)DR%Efy;(D&E)9tk`V-^P&BA*Ih_2~L0byYhd3BZe zo0@y3#l%zDX5e$@A=SrdpoC}6HLo`Gt zCh8N-&_M-54Eaa@8MvPkD*&Q=f4XM{nt>D$^-M6xWKjbyw)(*|fbgo~r~ga4fIHRm zr<%edBwh?Vv__%H3=9rZNZuq_`QgQ9gSdJCv$ct3|;ad}*<|^x})Et}b2n06Sn_6PU`gp>1?-L)ID9 z3SO%C|Fgp%eDITsd5-dhB8yy<;}pk}~qcI#&S zC7id8VA{*Zn)6rH)>`=aAtaH&2h+3w0OKZZ6MRtKawSGWLh^fPh^S>Y#tq*;V!)Q) zj}UVwE7Bq(Cnryv$MFHxrl;#nK%akS0vLAW7ZebHj%Nb{k$Gl1ghob2z-$8a0q7dU wlz~B(roq2C(tl$tFEZ@^uYuP8bsn}C$nrOrCOTbh{NET5EDw<@lQI4HKh5<)F8}}l diff --git a/doc/jkqtmathtext_docimages_specialfonts.jkmt b/doc/jkqtmathtext_docimages_specialfonts.jkmt index 6e027e250b..74c624b732 100644 --- a/doc/jkqtmathtext_docimages_specialfonts.jkmt +++ b/doc/jkqtmathtext_docimages_specialfonts.jkmt @@ -11,6 +11,10 @@ jkqtmathtext_comicsans_textonly.png --fontroman=Comic Sans MS --sizeincrease=10 Schrödinger's equation: $\left[-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}+V\right]\Psi(x)=\mathrm{i}\hbar\frac{\partial}{\partial t}\Psi(x)$ --- +jkqtmathtext_comicsans_mathonly.png +--fontmathroman=Comic Sans MS --sizeincrease=10 +Schrödinger's equation: $\left[-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}+V\right]\Psi(x)=\mathrm{i}\hbar\frac{\partial}{\partial t}\Psi(x)$ +--- jkqtmathtext_couriernew.png --fontroman=Courier New --fontmathroman=Courier New --sizeincrease=10 Schrödinger's equation: $\left[-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}+V\right]\Psi(x)=\mathrm{i}\hbar\frac{\partial}{\partial t}\Psi(x)$ @@ -56,5 +60,5 @@ jkqtmathtext_xits.png Schrödinger's equation: $\left[-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}+V\right]\Psi(x)=\mathrm{i}\hbar\frac{\partial}{\partial t}\Psi(x),\ \ x\in\mathbb{R}, \Psi(x)\in\mathbb{C}$ --- jkqtmathtext_stix.png ---fontmathroman=STIX Two Math --fontroman=STIX Two Text --sizeincrease=10 +--fontmathroman=STIX Two Math --sizeincrease=10 Schrödinger's equation: $\left[-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}+V\right]\Psi(x)=\mathrm{i}\hbar\frac{\partial}{\partial t}\Psi(x),\ \ x\in\mathbb{R}, \Psi(x)\in\mathbb{C}$ diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index 5cabaf2f23..7fb3339ce4 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include @@ -294,7 +293,7 @@ bool JKQTMathText::parse(const QString &markup, DefaultParserTypes markuptType, return false; } -bool JKQTMathText::useSTIX(bool mathModeOnly) { +bool JKQTMathText::useSTIX(bool mathModeOnly, bool useAsFallbackSymbol) { const JKQTMathTextFontSpecifier stixs=JKQTMathTextFontSpecifier::getSTIXFamilies(); bool res=false; @@ -305,18 +304,18 @@ bool JKQTMathText::useSTIX(bool mathModeOnly) { } if (!stixs.mathFontName().isEmpty()) { setFontMathRoman(stixs.mathFontName(), MTFEUnicode); - setFallbackFontSymbols(stixs.mathFontName(), MTFEUnicode); + if (useAsFallbackSymbol) setFallbackFontSymbols(stixs.fallbackSymbolsFontName(), MTFEUnicode); res=true; } else if (!stixs.fontName().isEmpty()) { setFontMathRoman(stixs.fontName(), MTFEUnicode); - setFallbackFontSymbols(stixs.fontName(), MTFEUnicode); + if (useAsFallbackSymbol) setFallbackFontSymbols(stixs.fallbackSymbolsFontName(), MTFEUnicode); res=true; } return res; } -bool JKQTMathText::useXITS(bool mathModeOnly) +bool JKQTMathText::useXITS(bool mathModeOnly, bool useAsFallbackSymbol) { const JKQTMathTextFontSpecifier xits=JKQTMathTextFontSpecifier::getXITSFamilies(); @@ -324,32 +323,32 @@ bool JKQTMathText::useXITS(bool mathModeOnly) if (!mathModeOnly && !xits.fontName().isEmpty()) { setFontRoman(xits.fontName(), MTFEUnicode); - setFallbackFontSymbols(xits.fontName(), MTFEUnicode); + if (useAsFallbackSymbol) setFallbackFontSymbols(xits.fallbackSymbolsFontName(), MTFEUnicode); res=true; } if (!xits.mathFontName().isEmpty()) { setFontMathRoman(xits.mathFontName(), MTFEUnicode); - setFallbackFontSymbols(xits.mathFontName(), MTFEUnicode); + if (useAsFallbackSymbol) setFallbackFontSymbols(xits.fallbackSymbolsFontName(), MTFEUnicode); res=true; } return res; } -bool JKQTMathText::useASANA(bool mathModeOnly) +bool JKQTMathText::useASANA(bool mathModeOnly, bool useAsFallbackSymbol) { - const JKQTMathTextFontSpecifier asana=JKQTMathTextFontSpecifier::getXITSFamilies(); + const JKQTMathTextFontSpecifier asana=JKQTMathTextFontSpecifier::getASANAFamilies(); bool res=false; if (!mathModeOnly && !asana.fontName().isEmpty()) { setFontRoman(asana.fontName(), MTFEUnicode); - setFallbackFontSymbols(asana.fontName(), MTFEUnicode); + if (useAsFallbackSymbol) setFallbackFontSymbols(asana.fallbackSymbolsFontName(), MTFEUnicode); res=true; } if (!asana.mathFontName().isEmpty()) { setFontMathRoman(asana.mathFontName(), MTFEUnicode); - setFallbackFontSymbols(asana.mathFontName(), MTFEUnicode); + if (useAsFallbackSymbol) setFallbackFontSymbols(asana.fallbackSymbolsFontName(), MTFEUnicode); res=true; } @@ -487,20 +486,13 @@ void JKQTMathText::setFontRomanOrSpecial(const QString &__value, JKQTMathTextFon void JKQTMathText::setFontRomanOrSpecial(const JKQTMathTextFontSpecifier &fontName, JKQTMathTextFontEncoding encoding) { if (!fontName.hasMathFontName()) { - if (fontName.fontName().toUpper()=="XITS") useXITS(false); - else if (fontName.fontName().toUpper()=="STIX") useSTIX(false); - else if (fontName.fontName().toUpper()=="ASANA") useASANA(false); - else { - setFontRoman(fontName.fontName(), encoding); - setFontMathRoman(fontName.fontName(), encoding); - } - } else { - if (fontName.mathFontName().toUpper()=="XITS") useXITS(true); - else if (fontName.mathFontName().toUpper()=="STIX") useSTIX(true); - else if (fontName.mathFontName().toUpper()=="ASANA") useASANA(true); - else setFontMathRoman(fontName.mathFontName(), encoding); setFontRoman(fontName.fontName(), encoding); + setFontMathRoman(fontName.fontName(), encoding); + } else { + setFontRoman(fontName.fontName(), encoding); + setFontMathRoman(fontName.mathFontName(), encoding); } + if (fontName.hasFallbcakSymbolFontName()) setFallbackFontSymbols(fontName.fallbackSymbolsFontName(), encoding); } void JKQTMathText::setFontRoman(const QString &__value, JKQTMathTextFontEncoding encoding) @@ -510,6 +502,12 @@ void JKQTMathText::setFontRoman(const QString &__value, JKQTMathTextFontEncoding fontDefinitions[MTEroman].fontEncoding = f.second; } +void JKQTMathText::setFontRomanAndMath(const QString &fontName, JKQTMathTextFontEncoding encoding) +{ + setFontRoman(fontName, encoding); + setFontMathRoman(fontName, encoding); +} + QString JKQTMathText::getFontRoman() const { return fontDefinitions[MTEroman].fontName; diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h index f580743195..2a72b7e8d0 100644 --- a/lib/jkqtmathtext/jkqtmathtext.h +++ b/lib/jkqtmathtext/jkqtmathtext.h @@ -61,10 +61,14 @@ class JKQTMathTextVerticalListNode; // forward . 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! + on an installed LaTeX for the rendering! See \ref jkqtmathtext_supportedlatex for a description of the supported LaTeX subset. - \see See \ref jkqtmathtext_supportedlatex for a description of the supported LaTeX subset - and \ref jkqtmathtext_renderingmodel for a description of the rendering model of JKQTMathTextLatexParser. + More generally these pages describe how the class renders math markup: + - \ref jkqtmathtext_renderingmodel for a description of the rendering model of JKQTMathTextLatexParser + - \ref jkqtmathtext_fonthandling for a description of the font handling in JKQTMathTextLatexParser + (which is modelled after LaTeX, but with tweaks especially for use in the context of GUI code) + - \ref jkqtmathtext_supportedlatex for a description of the supported LaTeX subset + . \section JKQTMathTextUsage Usage @@ -171,49 +175,6 @@ class JKQTMathTextVerticalListNode; // forward . - \section JKQTMathTextInternalDetails Implementation Details - \subsection JKQTMathTextSuppoertedFonts Font Handling - - Several fonts are defined as properties to the class: - - A "roman" (MTEroman / MTEmathRoman) font used as the standard font ( setFontRoman() and for use in math mode setFontMathRoman() ) - - A "sans-serif" (MTEsans / MTEmathSans) font which may be activated with \c \\sf ... ( setFontSans() and for use in math mode setFontMathSans() ) - - A "typewriter" (MTEtypewriter) font which may be activated with \c \\tt ... ( setFontTypewriter() ) - - A "script" (MTEscript) font which may be activated with \c \\script ... ( setFontScript() ) - - A "math-roman" (MTEmathRoman) font used as the standard font in math mode ( setFontMathRoman() ) - - A "math-sans-serif" (MTEmathSans) used as sans serif font in math mode ( setFontMathSans() ) - - A "blackboard" (MTEblackboard) font used to display double stroked characters ( setFontBlackboard() ) - - A "caligraphic" (MTEcaligraphic) font used to display caligraphic characters ( setFontCaligraphic() ) - - A "fraktur" (MTEfraktur) font used to display fraktur characters ( setFontFraktur() ) - - A fallback font MTEFallbackSymbols for (math) symbols, greek letters ... (if the symbols are not present in the currently used font). ( setFallbackFontSymbols() ) - . - - These fonts are generic font classes, which font is actually used can be configured in JKQTMathText class with the \c set...() functions mentioned above. You can also use these functions to set the fonts used for math rendering in math-mode: - - useSTIX() use the STIX fonts from https://www.stixfonts.org/ in math-mode
\image html jkqtmathtext/jkqtmathtext_stix.png - - useXITS() use the XITS fonts from https://github.com/alif-type/xits in math-mode. These are included by default in this library and also activated by default.
\image html jkqtmathtext/jkqtmathtext_xits.png - - useASANA() use the ASANA fonts from https://ctan.org/tex-archive/fonts/Asana-Math/ in math-mode
\image html jkqtmathtext/jkqtmathtext_asana.png - - useAnyUnicode() 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.
using "Times New Roman": \image html jkqtmathtext/jkqtmathtext_timesnewroman.png -
using "Arial": \image html jkqtmathtext/jkqtmathtext_arial.png -
using "Courier New": \image html jkqtmathtext/jkqtmathtext_couriernew.png -
using "Comic Sans MS": \image html jkqtmathtext/jkqtmathtext_comicsans.png -
using "Old English Text": \image html jkqtmathtext/jkqtmathtext_OldEnglish.png -
using "Computer Modern": \image html jkqtmathtext/jkqtmathtext_computermodern.png -
using "Fira": \image html jkqtmathtext/jkqtmathtext_fira.png -
using "MS Segoe UI": \image html jkqtmathtext/jkqtmathtext_mssegoeui.png -
using "DejaVu Sans": \image html jkqtmathtext/jkqtmathtext_DejaVuSans.png -
using "DejaVu Serif": \image html jkqtmathtext/jkqtmathtext_DejaVuSerif.png - . - - Math-mode is activated by enclosing your equation in \c $...$ or \c \\[...\\] . This mode is optimized for mathematical equations. Here is an example of the difference: - - math-mode (MTEmathRoman and MTEmathSans, whitespaces are mostly not drawn directly, symbol spacing is different) \c $...$:
\image html jkqtmathtext/schreq_mathmode.png - - normal mode (MTEroman and MTEsans is used, whitespaces are evaluated directly):
\image html jkqtmathtext/schreq_normalmode.png - . - - Font Lookup for symbols works as follows in JKQTMathTextSymbolNode: - - if a character is found in the current (or to be used) font, it is taken from there - - if the character is not found, it is looked for in the fallback fonts MTEFallbackSymbols - - as a last resort, some symbols can be created otherwise, so if neither of the two options above - contain the required symbol, the symbol might be synthesized otherwise, or a rectangle with the size of "X" is drawn instead - . */ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { @@ -230,10 +191,10 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { JKQTMathText(QObject * parent = nullptr); /** \brief class destructor */ ~JKQTMathText(); - /** \brief load the object settings from the given QSettings object with the given name prefix */ - void loadSettings(const QSettings& settings, const QString& group=QString("mathtext/")); - /** \brief store the object settings to the given QSettings object with the given name prefix */ - void saveSettings(QSettings& settings, const QString& group=QString("mathtext/")) const; + + +/** @name Parsing Math Markup */ +/**@{*/ /** \brief options for parse() */ enum ParseOption { AddSpaceBeforeAndAfter = 0x01, /*!< \brief If set, a little bit of space is added before and after the text. */ @@ -271,7 +232,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { std::unique_ptr p=std::unique_ptr(new TParser(this)); if (parsedNode) delete parsedNode; parsedNode=nullptr; - clearErrorList(); + clearErrorList(); parsedNode=p->parse(markup, options); return parsedNode!=nullptr; } @@ -279,6 +240,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { JKQTMathTextNode* getNodeTree() ; /** \copydoc parsedNode */ const JKQTMathTextNode *getNodeTree() const; +/**@}*/ + + +/** @name Determine the Size of the Output */ +/**@{*/ /** \brief get the size of the drawn representation. returns an invalid size if no text has been parsed. */ QSizeF getSize(QPainter& painter); @@ -292,6 +258,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { void getSizeDetail(QPainter& painter, double& width, double& ascent, double& descent, double& strikeoutPos); /** \brief return the detailes sizes of the text */ JKQTMathTextNodeSize getSizeDetail(QPainter& painter); +/**@}*/ + + +/** @name Rendering */ +/**@{*/ + /** \brief draw a representation to the object at the specified position \a x , \a y * * \param painter the QPainter to use for drawing @@ -356,8 +328,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \brief convert LaTeX to HTML. returns \c ok=true on success and \c ok=false else. */ QString toHtml(bool* ok=nullptr, double fontPointSize=10); +/**@}*/ - /** \copydoc fontColor */ +/** @name Font Handling */ +/**@{*/ + /** \copydoc fontColor */ void setFontColor(const QColor & __value); /** \copydoc fontColor */ QColor getFontColor() const; @@ -377,6 +352,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \brief 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 setFontSizePixels(), fontSize, fontSizeUnits */ double getFontSizePixels() const; + + /** \brief 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. @@ -404,36 +381,70 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \brief retrieve the font and encoding to be used for \a font, which might optionally be typeset inside a math environment, specified by in_math_environment, possibly for the given font subclass \a subclass */ QPair getFontData(JKQTMathTextEnvironmentFont font, bool in_math_environment=false) const; - /*! \brief calls setFontRoman(), or calls useXITS() if \a __value \c =="XITS". calls useSTIX() if \a __value \c =="STIX", ... - - \see setFontRoman(), useXITS(), useSTIX() for more information */ + /*! \brief 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 + * \code + * setFontRomanOrSpecial(JKQTMathTextFontSpecifier::fromFontSpec(fontName), encoding); + * \endcode + * + * \see JKQTMathTextFontSpecifier, setFontRoman(), setFontMathRoman(), \ref jkqtmathtext_fonthandling + */ void setFontRomanOrSpecial(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); - /*! \brief calls setFontRoman(), or calls useXITS() if \a __value \c =="XITS". calls useSTIX() if \a __value \c =="STIX", ... - - \see setFontRoman(), useXITS(), useSTIX() for more information */ + /*! \brief set the font by an instance of JKQTMathTextFontSpecifier + * + * This allows to set the text-mode and math-mode roman fonts. + * + * \see JKQTMathTextFontSpecifier, setFontRoman(), setFontMathRoman(), \ref jkqtmathtext_fonthandling + */ void setFontRomanOrSpecial(const JKQTMathTextFontSpecifier & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); - /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEroman */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEroman + * + * \see \ref jkqtmathtext_fonthandling + */ void setFontRoman(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text and math, i.e. the logical font MTEroman and MTEmathRoman + * + * \see \ref jkqtmathtext_fonthandling + */ + void setFontRomanAndMath(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for text in the logical font MTEroman */ QString getFontRoman() const; - /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEsans */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEsans + * + * \see \ref jkqtmathtext_fonthandling + */ void setFontSans(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for text in the logical font MTEsans */ QString getFontSans() const; - /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEtypewriter */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEtypewriter + * + * \see \ref jkqtmathtext_fonthandling + */ void setFontTypewriter(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for text in the logical font MTEtypewriter */ QString getFontTypewriter() const; - /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEscript */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEscript + * + * \see \ref jkqtmathtext_fonthandling + */ void setFontScript(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for text in the logical font MTEscript */ QString getFontScript() const; - /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEfraktur */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEfraktur + * + * \see \ref jkqtmathtext_fonthandling + */ void setFontFraktur(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for text in the logical font MTEfraktur */ QString getFontFraktur() const; - /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEcaligraphic */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEcaligraphic + * + * \see \ref jkqtmathtext_fonthandling + */ void setFontCaligraphic(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for text in the logical font MTEcaligraphic */ QString getFontCaligraphic() const; @@ -449,7 +460,10 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \brief retrieves the font to be used for text in the logical font MTEblackboard \see blackboradFontMode */ QString getFontBlackboard() const; - /** \brief set the font \a fontName and it's encoding \a encoding to be used for symbols in the logical font \a font */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for symbols in the logical font \a font + * + * \see \ref jkqtmathtext_fonthandling + */ void setFallbackFontSymbols(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for symbols in the logical font \a font */ QString getFallbackFontSymbols() const; @@ -472,11 +486,17 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { JKQTMathTextFontEncoding getFontEncodingCaligraphic() const; - /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEmathRoman */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEmathRoman + * + * \see \ref jkqtmathtext_fonthandling + */ void setFontMathRoman(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for text in the logical font MTEroman */ QString getFontMathRoman() const; - /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEmathSans */ + /** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEmathSans + * + * \see \ref jkqtmathtext_fonthandling + */ void setFontMathSans(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard); /** \brief retrieves the font to be used for text in the logical font MTEsans */ QString getFontMathSans() const; @@ -488,15 +508,26 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \brief 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 \a mathModeOnly \c ==false ) + * + * If \c useAsFallbackSymbol is set \c ==true then the XITS fonts are also used as MTEFallbackSymbols * * \image html jkqtmathtext/jkqtmathtext_stix.png + * + * 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 \ref jkqtmathtext_fonthandling */ - bool useSTIX(bool mathModeOnly=true); + bool useSTIX(bool mathModeOnly=true, bool useAsFallbackSymbol=true); /** \brief configures the class to use the XITS fonts in mathmode * - * use XITS fonts from https://github.com/alif-type/xits in math-mode. - * These are included by default in this library and also activated by default. + * use XITS fonts from https://github.com/alif-type/xits in math-mode + * or in math and text-mode (if \a mathModeOnly \c ==false ). + * + * If \c useAsFallbackSymbol is set \c ==true then the XITS fonts are also used as MTEFallbackSymbols * * \image html jkqtmathtext/jkqtmathtext_xits.png * @@ -504,16 +535,31 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { * 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 \ref jkqtmathtext_fonthandling */ - bool useXITS(bool mathModeOnly=true); + bool useXITS(bool mathModeOnly=true, bool useAsFallbackSymbol=true); /** \brief 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 \a mathModeOnly \c ==false ) + * + * If \c useAsFallbackSymbol is set \c ==true then the XITS fonts are also used as MTEFallbackSymbols * * \image html jkqtmathtext/jkqtmathtext_asana.png + * + * 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 \ref jkqtmathtext_fonthandling */ - bool useASANA(bool mathModeOnly=true); + bool useASANA(bool mathModeOnly=true, bool useAsFallbackSymbol=true); /** \brief sets \a timesFont (with its encoding \a encodingTimes ) for serif-text and \a sansFont (with its encoding \a encodingSans ) for both mathmode and textmode fonts * @@ -521,11 +567,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { * You should use fonts that contain as many of the mathematical symbols as possible * to ensure good rendering results. * - * useAnyUnicode("Times New Roman", "Times New Roman"):
\image html jkqtmathtext/jkqtmathtext_timesnewroman.png

- * useAnyUnicode("Arial", "Arial"):
\image html jkqtmathtext/jkqtmathtext_arial.png

- * useAnyUnicode("Courier New", "Courier New"):
\image html jkqtmathtext/jkqtmathtext_couriernew.png

+ * * useAnyUnicode("Comic Sans MS", "Comic Sans MS"):
\image html jkqtmathtext/jkqtmathtext_comicsans.png

* useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");:
\image html jkqtmathtext/jkqtmathtext_comicsans_textonly.png + * useAnyUnicodeForMathOnly("Comic Sans MS", "Comic Sans MS");:
\image html jkqtmathtext/jkqtmathtext_comicsans_mathonly.png + * + * \see useAnyUnicodeForMathOnly(), useAnyUnicodeForTextOnly(), \ref jkqtmathtext_fonthandling */ void useAnyUnicode(QString timesFont, const QString& sansFont, JKQTMathTextFontEncoding encodingTimes=JKQTMathTextFontEncoding::MTFEUnicode, JKQTMathTextFontEncoding encodingSans=JKQTMathTextFontEncoding::MTFEUnicode); /** \brief sets \a timesFont (with its encoding \a encodingTimes ) for serif-text and \a sansFont (with its encoding \a encodingSans ) for mathmode fonts only @@ -533,19 +580,31 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { * \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. * - * \see useAnyUnicodeForTextOnly(), useAnyUnicode() + * useAnyUnicode("Comic Sans MS", "Comic Sans MS"):
\image html jkqtmathtext/jkqtmathtext_comicsans.png

+ * useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");:
\image html jkqtmathtext/jkqtmathtext_comicsans_textonly.png + * useAnyUnicodeForMathOnly("Comic Sans MS", "Comic Sans MS");:
\image html jkqtmathtext/jkqtmathtext_comicsans_mathonly.png + * + * \see useAnyUnicodeForTextOnly(), useAnyUnicode(), \ref jkqtmathtext_fonthandling */ void useAnyUnicodeForMathOnly(QString timesFont, const QString& sansFont, JKQTMathTextFontEncoding encodingTimes=JKQTMathTextFontEncoding::MTFEUnicode, JKQTMathTextFontEncoding encodingSans=JKQTMathTextFontEncoding::MTFEUnicode); /** \brief sets \a timesFont (with its encoding \a encodingTimes ) for serif-text and \a sansFont (with its encoding \a encodingSans ) for both mathmode fonts only - * - * \see useAnyUnicodeForMathOnly(), useAnyUnicode() * * useAnyUnicode("Comic Sans MS", "Comic Sans MS"):
\image html jkqtmathtext/jkqtmathtext_comicsans.png

* useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");:
\image html jkqtmathtext/jkqtmathtext_comicsans_textonly.png + * useAnyUnicodeForMathOnly("Comic Sans MS", "Comic Sans MS");:
\image html jkqtmathtext/jkqtmathtext_comicsans_mathonly.png + * + * \see useAnyUnicodeForMathOnly(), useAnyUnicode(), \ref jkqtmathtext_fonthandling */ void useAnyUnicodeForTextOnly(QString timesFont, const QString& sansFont, JKQTMathTextFontEncoding encodingTimes=JKQTMathTextFontEncoding::MTFEUnicode, JKQTMathTextFontEncoding encodingSans=JKQTMathTextFontEncoding::MTFEUnicode); +/**@}*/ +/** @name (Defining) Rendering Details */ +/**@{*/ + /** \brief load the object settings from the given QSettings object with the given name prefix */ + void loadSettings(const QSettings& settings, const QString& group=QString("mathtext/")); + /** \brief store the object settings to the given QSettings object with the given name prefix */ + void saveSettings(QSettings& settings, const QString& group=QString("mathtext/")) const; /** \copydoc brace_factor */ void setBraceFactor(double __value); @@ -607,7 +666,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { void setUnderbraceFactor(double __value); /** \copydoc underbrace_factor */ double getUnderbraceFactor() const; - /** \copydoc underbrace_separation_xfactor */ + /** \copydoc underbrace_separation_xfactor */ void setUnderbraceSeparationXFactor(double __value); /** \copydoc underbrace_separation_xfactor */ double getUnderbraceSeparationXFactor() const; @@ -647,7 +706,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \copydoc decoration_separation_factor */ double getDecorationSeparationFactor() const; /** \copydoc decoration_width_reduction_Xfactor */ - void setDecorationWidthReductionFactor(double __value); + void setDecorationWidthReductionFactor(double __value); /** \copydoc decoration_width_reduction_Xfactor */ double getDecorationWidthReductionXFactor() const; @@ -693,8 +752,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { double getMatrixYPaddingFactor(); /** \copydoc matrix_yPadding_factor */ void setMatrixYPaddingFactor(double factor); +/**@}*/ +/** @name Error Handling */ +/**@{*/ /** \copydoc error_list */ QStringList getErrorList() const; /** \brief returns \c true when errors were registered in the system \see error_list */ @@ -706,6 +768,22 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ void clearErrorList(); + /** \brief 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 getErrorList(), hadErrors() and addToErrorList() + * + */ + QStringList error_list; +/**@}*/ + + /** \brief the syntax tree of JKQTMathTextNode's that was created by the last parse() call */ + JKQTMathTextNode* parsedNode; + /** \brief table with font replacements to use (e.g. if it is known that a certain font is not good for rendering, you can add @@ -741,7 +819,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { * - MTBBDMunicodeCharactersOrSimulate: \image html jkqtmathtext/jkqtmathtext_bb_unicode_or_simulate.png using \c JKQTMathText::setFontBlackboard("Arial") * . * - * \see setFontBlackboard() setBlackboardFontMode() + * \see JKQTMathTextBlackboradDrawingMode, setFontBlackboard(), setBlackboardFontMode(), \ref jkqtmathtext_fonthandling */ JKQTMathTextBlackboradDrawingMode blackboradFontMode; @@ -923,21 +1001,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ double matrix_yPadding_factor; - /** \brief 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 getErrorList(), hadErrors() and addToErrorList() - * - */ - QStringList error_list; - - /** \brief the syntax tree of JKQTMathTextNode's that was created by the last parse() call */ - JKQTMathTextNode* parsedNode; - }; diff --git a/lib/jkqtmathtext/jkqtmathtexttools.cpp b/lib/jkqtmathtext/jkqtmathtexttools.cpp index 6c4cffcf0b..be82831173 100644 --- a/lib/jkqtmathtext/jkqtmathtexttools.cpp +++ b/lib/jkqtmathtext/jkqtmathtexttools.cpp @@ -45,14 +45,16 @@ void initJKQTMathTextResources() JKQTMathTextFontSpecifier::JKQTMathTextFontSpecifier(): m_fontName(""), - m_mathFontName("") + m_mathFontName(""), + m_transformOnOutput(true) { } JKQTMathTextFontSpecifier::JKQTMathTextFontSpecifier(const QString &_fontName, const QString &_mathFontName): m_fontName(_fontName), - m_mathFontName(_mathFontName) + m_mathFontName(_mathFontName), + m_transformOnOutput(true) { } @@ -90,15 +92,28 @@ QString JKQTMathTextFontSpecifier::getFontSpec() const QString JKQTMathTextFontSpecifier::fontName() const { - return transformFontName(m_fontName); + if (m_transformOnOutput) return transformFontNameAndDecodeSpecialFonts(m_fontName, false); + else return m_fontName; } QString JKQTMathTextFontSpecifier::mathFontName() const { - return transformFontName(m_mathFontName); + if (m_transformOnOutput) return transformFontNameAndDecodeSpecialFonts(m_mathFontName, true); + else return m_mathFontName; } -QString JKQTMathTextFontSpecifier::transformFontName(const QString &fontName) +QString JKQTMathTextFontSpecifier::fallbackSymbolsFontName() const +{ + if (m_transformOnOutput) return transformFontNameAndDecodeSpecialFonts(m_fallbackSymbolFont, true); + else return m_fallbackSymbolFont; +} + +void JKQTMathTextFontSpecifier::setFallbackSymbolsFontName(const QString &name) +{ + m_fallbackSymbolFont=name; +} + +QString JKQTMathTextFontSpecifier::transformFontName(const QString &fontName, bool mathmode) { const QString fnt=fontName.trimmed().toLower(); QFont testFnt; @@ -168,17 +183,20 @@ QString JKQTMathTextFontSpecifier::transformFontName(const QString &fontName) return fontName; } -QString JKQTMathTextFontSpecifier::transformFontNameAndDecodeSpecialFonts(const QString &fontName) +QString JKQTMathTextFontSpecifier::transformFontNameAndDecodeSpecialFonts(const QString &fontName, bool mathmode) { const QString fnt=fontName.toLower().trimmed(); if (fnt=="xits") { - return getXITSFamilies().fontName(); + if (mathmode) return getXITSFamilies().mathFontName(); + else return getXITSFamilies().fontName(); } else if (fnt=="asana") { - return getASANAFamilies().fontName(); + if (mathmode) return getASANAFamilies().mathFontName(); + else return getASANAFamilies().fontName(); } else if (fnt=="stix") { - return getSTIXFamilies().fontName(); + if (mathmode) return getSTIXFamilies().mathFontName(); + else return getSTIXFamilies().fontName(); } - return transformFontName(fontName); + return transformFontName(fontName, mathmode); } bool JKQTMathTextFontSpecifier::hasFontName() const @@ -191,6 +209,11 @@ bool JKQTMathTextFontSpecifier::hasMathFontName() const return !m_mathFontName.isEmpty(); } +bool JKQTMathTextFontSpecifier::hasFallbcakSymbolFontName() const +{ + return !m_fallbackSymbolFont.isEmpty(); +} + JKQTMathTextFontSpecifier JKQTMathTextFontSpecifier::getXITSFamilies() { #if (QT_VERSION