2015-07-11 18:56:02 +08:00
/*
2022-06-08 21:38:26 +08:00
Copyright ( c ) 2008 - 2022 Jan W . Krieger ( < jan @ jkrieger . de > )
2018-12-14 05:33:42 +08:00
with contributions from : Razi Alavizadeh
2015-07-11 18:56:02 +08:00
2015-07-12 22:34:27 +08:00
2015-07-11 18:56:02 +08:00
This software is free software : you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License ( LGPL ) as published by
2019-02-08 00:24:46 +08:00
the Free Software Foundation , either version 2.1 of the License , or
2015-07-11 18:56:02 +08:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Lesser General Public License ( LGPL ) for more details .
You should have received a copy of the GNU Lesser General Public License ( LGPL )
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# ifndef JKQTMATHTEXT_H
# define JKQTMATHTEXT_H
# include <QObject>
# include <QSettings>
# include <QPainter>
# include <QString>
# include <QSet>
# include <QFile>
2019-06-22 20:21:32 +08:00
# include "jkqtmathtext/jkqtmathtext_imexport.h"
2022-06-08 21:38:26 +08:00
# include "jkqtmathtext/jkqtmathtexttools.h"
2015-07-11 18:56:02 +08:00
# include <QWidget>
# include <QLabel>
# include <QHash>
2018-12-03 01:30:12 +08:00
2022-06-08 21:38:26 +08:00
class JKQTMathTextNode ; // forward
2022-06-03 03:02:23 +08:00
2019-01-26 20:00:40 +08:00
/*! \brief this class parses a LaTeX string and can then draw the contained text/equation onto a <a href="http://doc.qt.io/qt-5/qpainter.html">QPainter</a>
2022-06-20 04:36:38 +08:00
\ ingroup jkqtmathtext_render
2015-07-11 18:56:02 +08:00
2019-01-19 16:40:52 +08:00
2019-01-20 17:49:29 +08:00
JKQTMathText is a self - contained LaTeX - renderer for Qt . It is used to renderer
2019-01-20 23:15:10 +08:00
labels in JKQTPlotter / JKQTBasePlotter , but can be used independently .
2019-01-19 23:54:31 +08:00
The class does not depend on any library , except Qt .
In particular it actually parses a LaTeX string and draws it in pure C + + . It does NOT rely
on an installed LaTeX for the rendering !
2019-01-20 17:49:29 +08:00
\ section JKQTMathTextUsage Usage
\ subsection JKQTMathTextUsageDirect Direct Usage
2019-01-19 23:54:31 +08:00
This small piece of C + + code may serve as an example of the usage and capabilities of the class :
2019-01-19 16:40:52 +08:00
\ code
2019-01-20 17:49:29 +08:00
// create a JKQTMathText object.
JKQTMathText mathText ;
2019-01-19 16:40:52 +08:00
// configure its properties to influence the rendering (e.g. fonts to use, font size, ...)
mathText . useXITS ( ) ;
2019-01-26 03:16:04 +08:00
mathText . setFontSize ( 20 ) ;
2019-01-19 16:40:52 +08:00
// parse some LaTeX code (the Schroedinger's equation)
mathText . parse ( " $ \\ left[- \\ frac{ \\ hbar^2}{2m} \\ frac{ \\ partial^2}{ \\ partial x^2}+V(x) \\ right] \\ Psi(x)= \\ mathrm{i} \\ hbar \\ frac{ \\ partial}{ \\ partial t} \\ Psi(x)$ " ) ;
// use the draw() methods to draw the equation using a QPainter (here onto a QPixmap)
QPainter painter ;
QPixmap pix ( 600 , 400 ) ;
painter . begin ( & pix ) ;
mathText . draw ( painter , Qt : : AlignCenter , QRectF ( 0 , 0 , pix . width ( ) , pix . height ( ) ) , false ) ;
painter . end ( ) ;
\ endcode
2019-01-19 23:54:31 +08:00
2019-01-20 17:49:29 +08:00
\ subsection JKQTMathTextSizing Determining the size of an equation
2019-01-19 23:54:31 +08:00
In addition there are also functions that allow to calculate the size of the equation , before drawing it ( just like the functions in < a href = " http://doc.qt.io/qt-5/qfontmetrics.html " > QFontMetrics < / a > and < a href = " http://doc.qt.io/qt-5/qfontmetricsf.html " > QFontMetricsF < / a > ) :
- getSizeDetail ( )
- getSize ( )
- getAscent ( ) , getDescent ( )
.
2019-01-20 17:49:29 +08:00
\ subsection JKQTMathTextErrorHandling Error Handling
2019-01-19 23:54:31 +08:00
The class is designed to be as robust as possible and will still return some output , even if the equation contains some errors .
2019-01-26 20:00:40 +08:00
Nevertheless , several errors are detected while parsing . You can get a list of error messages using getErrorList ( ) after calling parse ( ) .
2019-01-19 23:54:31 +08:00
Also parse ( ) will return \ c false if an error occured while parsing .
2019-01-20 17:49:29 +08:00
\ subsection JKQTMathTextUsageQLabel Usage within a QLabel class JKQTMathTextLabel
2019-01-19 23:54:31 +08:00
2019-01-20 17:49:29 +08:00
Finally , there is also a QLabel - derived class JKQTMathTextLabel which can be used for drawing a LaTeX string onto a Qt form .
2019-01-19 23:54:31 +08:00
2019-01-20 17:49:29 +08:00
\ see JKQTMathTextLabel
2019-01-19 23:54:31 +08:00
2019-01-20 17:49:29 +08:00
\ section JKQTMathTextExamples Examples
2019-01-19 23:54:31 +08:00
Examples for the usage of this class can be found here :
2019-01-20 17:49:29 +08:00
- \ ref JKQTMathTextSimpleExample
2019-01-19 23:54:31 +08:00
.
2019-01-20 17:49:29 +08:00
\ section JKQTMathTextSuppoertedLaTeX Supported LaTeX Subset
2019-01-20 23:15:10 +08:00
\ subsection JKQTMathTextSuppoertedLaTeXSimple Simple Instructions
2015-07-11 18:56:02 +08:00
The supported LaTeX subset is listes below . Please note that some commands are used differently than in actual LaTeX .
For example \ c \ \ bf is just a renamed form of \ c \ \ textbf and used as \ c \ \ bf { . . . } and NOT as \ c { \ \ bf . . . } .
- \ c $ : enter / leave math mode
2022-06-09 20:42:25 +08:00
- \ c \ \ bf { . . . } \ c \ \ textbf { . . . } \ c \ \ mathbf { . . . } : draw the contained text in bold face \ image html jkqtmathtext / jkqtmathtext_bold . png
- \ c \ \ it { . . . } \ c \ \ textit { . . . } \ c \ \ mathit { . . . } : draw the contained text in italic face \ image html jkqtmathtext / jkqtmathtext_italic . png
- \ c \ \ rm { . . . } \ c \ \ textrm { . . . } \ c \ \ mathrm { . . . } \ c \ \ mbox { . . . } : draw the contained text in normal upright roman font face \ image html jkqtmathtext / jkqtmathtext_fonts . png
- \ c \ \ sf { . . . } \ c \ \ textsf { . . . } \ c \ \ mathsf { . . . } : draw the contained text in normal upright sans - serif font face \ image html jkqtmathtext / jkqtmathtext_fonts . png
- \ c \ \ script { . . . } \ c \ \ textscript { . . . } \ c \ \ mathscript { . . . } : draw the contained text in a script font face \ image html jkqtmathtext / jkqtmathtext_fonts . png
- \ c \ \ sc { . . . } : draw the text in small caps \ image html jkqtmathtext / jkqtmathtext_sc . png
- \ c \ \ ul { . . . } \ c \ \ underline { . . . } \ c \ \ underlined { . . . } : draw the text with underlining \ image html jkqtmathtext / jkqtmathtext_ul . png
- \ c \ \ sout { . . . } : strike out the text \ image html jkqtmathtext / MTDstrike . png
- \ c \ \ cancel { . . . } : slanted strike out the text \ image html jkqtmathtext / MTDcancel . png
- \ c \ \ bcancel { . . . } : back - strike out the text \ image html jkqtmathtext / MTDbcancel . png
- \ c \ \ xcancel { . . . } : x - strike out the text \ image html jkqtmathtext / MTDxcancel . png
- \ c \ \ ol { . . . } \ c \ \ overline { . . . } \ c \ \ overlined { . . . } : draw the text with overlining \ image html jkqtmathtext / jkqtmathtext_ol . png
- \ c \ \ tt { . . . } \ c \ \ texttt { . . . } \ c \ \ mathtt { . . . } : draw text in typewriter font \ image html jkqtmathtext / jkqtmathtext_fonts . png
- \ c \ \ textcolor { color } { . . . } \ c \ \ color { color } \ c \ \ mathcolor { color } { . . . } : draw colored text \ image html jkqtmathtext / jkqtmathtext_colored . png
2022-07-25 04:31:38 +08:00
- \ c \ \ userfont { font } { . . . } : draw text in a user - specific font , available on the system \ image html jkqtmathtext / jkqtmathtext_userfont . png ( generated by < code > default , \ \ userfont { Arial } { Arial } , \ \ userfont { Comic Sans MS } { Comic Sans MS } < / code > )
2022-06-09 20:42:25 +08:00
- \ c \ \ boxed { . . . } : draw text with a box around it \ image html jkqtmathtext / jkqtmathtext_boxed . png
2022-07-09 05:15:42 +08:00
- \ c \ \ doublebox { . . . } : draw text with a rounded box around it \ image html jkqtmathtext / jkqtmathtext_doublebox . png
2022-07-24 20:50:28 +08:00
- \ c \ \ ovalbox { . . . } : draw text with a rounded box around it \ image html jkqtmathtext / jkqtmathtext_ovalboxed . png
2022-07-09 05:15:42 +08:00
- \ c \ \ Ovalbox { . . . } : draw a thick oval box \ image html jkqtmathtext / jkqtmathtext_oovalbox . png
2022-07-24 20:50:28 +08:00
- \ c \ \ ovaldoublebox { . . . } : draw a double oval box \ image html jkqtmathtext / jkqtmathtext_doubleovalbox . png
2022-07-09 05:15:42 +08:00
- \ c \ \ colorbox { bordercolor } { . . . } : draw a colored box \ image html jkqtmathtext / jkqtmathtext_colorbox . png
- \ c \ \ shaded { backgroundcolor } { . . . } : draw a filled box \ image html jkqtmathtext / jkqtmathtext_shaded . png
- \ c \ \ fcolorbox { bordercolor } { backgroundcolor } { . . . } : draw a colored , filled box \ image html jkqtmathtext / jkqtmathtext_fcolorbox . png
2022-06-09 20:42:25 +08:00
- \ c \ \ colorbox { color } { . . . } : draw a colored box around text \ image html jkqtmathtext / jkqtmathtext_colorbox . png
- \ c \ \ alpha . . . : display the according greek letter \ image html jkqtmathtext / jkqtmathtext_greek . png
2022-08-01 19:55:34 +08:00
- \ c \ \ charDECIMAL and \ c \ \ char \ " HEX and \ c \\ char \' OCTAL : draws a unicode character from its 32-bit codepoint \ image html jkqtmathtext/jkqtmathtext_char.png (generated by <code>A: \\ char65, circonflex: \\ char \" 109 accent: \\ char \' 351</code>)
2022-07-27 04:27:16 +08:00
- \ c \ \ unicode { HEX } and \ c \ \ usym { HEX } : draws a unicode character from its 32 - bit codepoint \ image html jkqtmathtext / jkqtmathtext_unicode . png ( generated by < code > star : \ \ unicode { 2605 } , circonflex : \ \ unicode { 109 } emoticons : \ \ usym { 1F 440 } \ \ usym { 1F 929 } < / code > )
- \ c \ \ utfeight { HEX } : draws a unicode character from its UTF - 8 encoding \ image html jkqtmathtext / jkqtmathtext_utf8 . png ( generated by < code > star : \ \ utfeight { e29885 } emoticons \ \ utfeight { F09F9881 } \ \ utfeight { f09f98bb } < / code > )
2022-06-09 20:42:25 +08:00
- \ c ^ { . . . } \ c _ { . . . } : display the contents of braces in superscript / subscript \ image html jkqtmathtext / jkqtmathtext_supersub . png
< br > Special subscript / superscript typesetting applies , when the sub / super follows \ c \ \ sum \ c \ \ Prod . . . : \ image html jkqtmathtext / jkqtmathtext_specialsubsuper . png
2015-07-11 18:56:02 +08:00
- \ c \ \ { / \ \ } : display opening / closing brace
- \ c \ \ _ : display underscore
- \ c \ \ sum \ c \ \ prod \ c \ \ int . . . : plot special symbol . Note that depending on the fontEncoding the available
symbols may differ ( there are not all symbols defined in the MS Windows Symbol
font ! ) . Best coverage should be given by Unicode font encoding with a good
2022-06-09 20:42:25 +08:00
unicode font installed ! < br > \ image html jkqtmathtext / jkqtmathtext_symbols . png
2022-08-01 17:44:38 +08:00
- \ c - : draw a hyphen \ image html jkqtmathtext / jkqtmathtext_hyphen . png
- \ c - - : draw an en - dash \ image html jkqtmathtext / jkqtmathtext_endash . png
- \ c - - - : draw an em - dash \ image html jkqtmathtext / jkqtmathtext_emdash . png
2022-07-11 04:01:11 +08:00
- < code > \ \ vec { x } \ \ dot { x } \ \ ddot { x } \ \ overline { x } \ \ underline { x } \ \ hat { x } \ \ tilde { x } \ \ uul { x } \ \ ool { x } \ \ bar { x } \ \ arrow { x } \ \ widehat { x } \ \ widetilde { x } . . . < / code > : Decorations over / under symbols \ image html jkqtmathtext / jkqtmathtext_mathdeco . png
2022-06-09 20:42:25 +08:00
- < code > \ \ verb { don ' t parse this _aaa \ \ LaTeX } < / code > : interpret enclosed text as verbose \ image html jkqtmathtext / jkqtmathtext_verb . png
2015-07-11 18:56:02 +08:00
.
2019-01-20 23:15:10 +08:00
\ subsection JKQTMathTextSuppoertedLaTeXBraces Braces . . .
2015-07-11 18:56:02 +08:00
Braces in math mode are adjusted in size , so they are a small bit ( factor \ c brace_factor ) larger than the contents .
To enable this you have to write braces with \ c \ \ left and \ c \ \ right . These types of braces are defined ( slight
differences to LaTeX standard ) :
2022-06-09 20:42:25 +08:00
- \ c \ \ left ( \ c \ \ right ) : default meaning ( ) , \ image html jkqtmathtext / jkqtmathtext_brace_round . png
- \ c \ \ left [ \ c \ \ right ] : default meaning [ ] , \ image html jkqtmathtext / jkqtmathtext_brace_rect . png
- \ c \ \ left \ \ { \ c \ \ right \ \ } : default meaning { } , \ image html jkqtmathtext / jkqtmathtext_brace_curly . png
- \ c \ \ left < \ c \ \ right > : " averaging " braces , \ image html jkqtmathtext / jkqtmathtext_brace_tri . png
- \ c \ c \ \ left \ \ lfloor \ c \ \ right \ \ rfloor : floor braces , \ image html jkqtmathtext / jkqtmathtext_brace_floor . png
- \ c \ \ left ~ \ c \ \ right ~ \ c \ \ left \ \ lceil \ c \ \ right \ \ rceil : ceil braces , \ image html jkqtmathtext / jkqtmathtext_brace_ceil . png
- \ c \ \ left | \ c \ \ right | : absolute value braces | | , \ image html jkqtmathtext / jkqtmathtext_brace_oneline . png
2022-07-31 13:28:28 +08:00
- \ c \ \ left \ \ | \ c \ \ right \ \ | \ endcode : norm braces | | | | , \ image html jkqtmathtext / jkqtmathtext_brace_dblline . png
2019-01-20 23:15:10 +08:00
- You can use \ c \ \ left . or \ c \ \ right . to have only right or only left brace
.
2022-06-28 18:00:20 +08:00
\ subsection JKQTMathTextSuppoertedLaTeXRoots Roots
There are also instructions that allow to write roots :
- < code > $ \ \ sqrt { 1 + \ \ sqrt { 1 + x } } $ < / code > \ image html jkqtmathtext / jkqtmathtext_sqrt . png
- < code > $ \ \ sqrt [ 3 ] { 1 + \ \ sqrt [ 3 ] { 1 + x } } $ < / code > \ image html jkqtmathtext / jkqtmathtext_cbrt . png
.
2019-01-20 23:15:10 +08:00
\ subsection JKQTMathTextSuppoertedLaTeXUnderOver Undersetting , Oversetting , Underbraces , Overbraces . . .
There are also instructions that allow to under / overset braces , arrows , . . . :
2022-06-09 20:42:25 +08:00
- < code > $ \ \ underbrace { x + x + . . . + x } { k \ \ \ \ mathrm { times } } $ < / code > \ image html jkqtmathtext / jkqtmathtext_brace_underbrace . png
- < code > $ \ \ overbrace { x + x + . . . + x } { k \ \ \ \ mathrm { times } } $ < / code > \ image html jkqtmathtext / jkqtmathtext_brace_overbrace . png
2022-06-28 16:15:54 +08:00
- < code > $ \ \ underbracket { x + x + . . . + x } { k \ \ \ \ mathrm { times } } $ < / code > \ image html jkqtmathtext / MTFMunderbracket . png
- < code > $ \ \ overbracket { x + x + . . . + x } { k \ \ \ \ mathrm { times } } $ < / code > \ image html jkqtmathtext / MTFMoverbracket . png
2022-06-09 20:42:25 +08:00
- < code > $ \ \ overset { main } { over } $ < / code > \ image html jkqtmathtext / jkqtmathtext_brace_overset . png
- < code > $ \ \ underset { main } { under } $ < / code > \ image html jkqtmathtext / jkqtmathtext_brace_underset . png
2019-01-20 23:15:10 +08:00
.
2022-07-31 13:28:28 +08:00
\ subsection JKQTMathTextSuppoertedLaTeXFrac Fraction Type Instructions
2019-01-20 23:15:10 +08:00
Several Matrix / Array - typed LaTeX instructions are supported :
2022-07-31 13:28:28 +08:00
- < code > $ \ \ frac { . . . } { . . . } $ < / code > \ image html jkqtmathtext / MTFMfrac . png
- < code > $ \ \ tfrac { . . . } { . . . } $ < / code > ( 70 % smaller font ) \ image html jkqtmathtext / MTFMtfrac . png
- < code > $ \ \ dfrac { . . . } { . . . } $ < / code > \ image html jkqtmathtext / MTFMdfrac . png
2022-06-09 20:42:25 +08:00
- < code > $ \ \ sfrac { . . . } { . . . } $ < / code > \ image html jkqtmathtext / MTFMsfrac . png
- < code > $ \ \ stfrac { . . . } { . . . } $ < / code > ( 70 % smaller font ) \ image html jkqtmathtext / MTFMstfrac . png
2022-07-31 13:28:28 +08:00
.
\ subsection JKQTMathTextSuppoertedLaTeXMatrix Matrix / Array Type Instructions
Several Matrix / Array - typed LaTeX instructions are supported :
2022-06-09 20:42:25 +08:00
- < code > $ \ \ stackrel { . . . } { . . . } $ $ \ \ binom { . . . } { . . . } $ < / code > \ image html jkqtmathtext / jkqtmathtext_brace_stackrel . png
- < code > $ \ \ begin { cases } . . . & . . . \ \ \ \ . . . & . . . \ \ end { cases } $ < / code > \ image html jkqtmathtext / jkqtmathtext_brace_begincases . png
- < code > $ \ \ begin { array } a & b & . . . \ \ \ \ c & d & . . . \ \ end { array } $ < / code > < code > $ \ \ begin { matrix } a & b & . . . \ \ \ \ c & d & . . . \ \ end { matrix } $ < / code > \ image html jkqtmathtext / jkqtmathtext_array . png
- < code > $ \ \ begin { pmatrix } a & b & . . . \ \ \ \ c & d & . . . \ \ end { pmatrix } $ < / code > \ image html jkqtmathtext / jkqtmathtext_pmatrix . png
- < code > $ \ \ begin { bmatrix } a & b & . . . \ \ \ \ c & d & . . . \ \ end { bmatrix } $ < / code > \ image html jkqtmathtext / jkqtmathtext_bmatrix . png
- < code > $ \ \ begin { Bmatrix } a & b & . . . \ \ \ \ c & d & . . . \ \ end { Bmatrix } $ < / code > \ image html jkqtmathtext / jkqtmathtext_bbmatrix . png
- < code > $ \ \ begin { vmatrix } a & b & . . . \ \ \ \ c & d & . . . \ \ end { vmatrix } $ < / code > \ image html jkqtmathtext / jkqtmathtext_vmatrix . png
- < code > $ \ \ begin { Vmatrix } a & b & . . . \ \ \ \ c & d & . . . \ \ end { Vmatrix } $ < / code > \ image html jkqtmathtext / jkqtmathtext_vvmatrix . png
2022-07-31 13:28:28 +08:00
- < code > $ \ \ substack [ lrc ] { . . . \ \ \ \ . . . } $ < / code > \ image html jkqtmathtext / jkqtmathtext_substack . png
- < code > $ \ \ lsubstack { . . . \ \ \ \ . . . } $ < / code > \ image html jkqtmathtext / jkqtmathtext_lsubstack . png
- < code > $ \ \ rsubstack { . . . \ \ \ \ . . . } $ < / code > \ image html jkqtmathtext / jkqtmathtext_rsubstack . png
2015-07-11 18:56:02 +08:00
.
2022-07-31 14:17:45 +08:00
\ subsection JKQTMathTextSuppoertedLaTeXTextAlignment Environments for Multi - line text
2022-07-31 13:56:13 +08:00
Several environments are supported that allow to layout text with linebreaks and different alignemnts :
- < code > $ \ \ begin { document } . . . \ \ \ \ . . . \ \ end { document } $ < / code > \ image html jkqtmathtext / jkqtmathtext_beginflushleft . png
- < code > $ \ \ begin { flushleft } . . . \ \ \ \ . . . \ \ end { flushleft } $ < / code > \ image html jkqtmathtext / jkqtmathtext_beginflushleft . png
- < code > $ \ \ begin { flushright } . . . \ \ \ \ . . . \ \ end { flushright } $ < / code > \ image html jkqtmathtext / jkqtmathtext_beginflushright . png
- < code > $ \ \ begin { center } . . . \ \ \ \ . . . \ \ end { center } $ < / code > \ image html jkqtmathtext / jkqtmathtext_begincenter . png
2022-07-31 14:17:45 +08:00
- < code > $ \ \ begin { framed } . . . \ \ \ \ . . . \ \ end { framed } $ < / code > \ image html jkqtmathtext / jkqtmathtext_beginframed . png
- < code > $ \ \ begin { shaded } . . . \ \ \ \ . . . \ \ end { shaded } $ < / code > \ image html jkqtmathtext / jkqtmathtext_beginshaded . png
- < code > $ \ \ begin { snugshade } . . . \ \ \ \ . . . \ \ end { snugshade } $ < / code > \ image html jkqtmathtext / jkqtmathtext_beginsnugshade . png
2022-07-31 13:56:13 +08:00
.
2019-01-20 17:49:29 +08:00
\ section JKQTMathTextSuppoertedFonts Font Handling
2019-01-19 23:54:31 +08:00
2015-07-11 18:56:02 +08:00
Several fonts are defined as properties to the class :
2022-07-04 02:30:12 +08:00
- 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 ( ) )
2022-07-06 04:03:08 +08:00
- A fallback font MTEFallbackSymbols for ( math ) symbols , greek letters . . . ( if the symbols are not present in the currently used font ) . ( setFallbackFontSymbols ( ) )
2015-07-11 18:56:02 +08:00
.
2022-07-04 02:30:12 +08:00
2019-01-26 20:00:40 +08:00
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 :
2022-07-24 20:50:28 +08:00
- useSTIX ( ) use the STIX fonts from < a href = " https://www.stixfonts.org/ " > https : //www.stixfonts.org/</a> in math-mode<br>\image html jkqtmathtext/jkqtmathtext_stix.png
- useXITS ( ) use the XITS fonts from < a href = " https://github.com/alif-type/xits " > https : //github.com/alif-type/xits</a> in math-mode. These are included by default in this library and also activated by default.<br>\image html jkqtmathtext/jkqtmathtext_xits.png
- 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<br>\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 . < br > using " Times New Roman " : \ image html jkqtmathtext / jkqtmathtext_timesnewroman . png
< br > using " Arial " : \ image html jkqtmathtext / jkqtmathtext_arial . png
< br > using " Courier New " : \ image html jkqtmathtext / jkqtmathtext_couriernew . png
< br > using " Comic Sans MS " : \ image html jkqtmathtext / jkqtmathtext_comicsans . png
< br > using " Old English Text " : \ image html jkqtmathtext / jkqtmathtext_OldEnglish . png
2019-01-19 23:24:19 +08:00
.
2019-01-19 16:40:52 +08:00
2019-01-19 23:54:31 +08:00
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 :
2022-07-04 02:30:12 +08:00
- < b > math - mode ( MTEmathRoman and MTEmathSans , whitespaces are mostly not drawn directly , symbol spacing is different ) < / b > \ c $ . . . $ : < br > \ image html jkqtmathtext / schreq_mathmode . png
- < b > normal mode ( MTEroman and MTEsans is used , whitespaces are evaluated directly ) < / b > : < br > \ image html jkqtmathtext / schreq_normalmode . png
2019-01-19 23:54:31 +08:00
.
2022-07-04 02:30:12 +08:00
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
2022-07-06 04:03:08 +08:00
- if the character is not found , it is looked for in the fallback fonts MTEFallbackSymbols
2022-07-04 02:30:12 +08:00
- 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
2019-01-19 23:54:31 +08:00
2019-01-19 16:40:52 +08:00
2019-01-20 17:49:29 +08:00
\ section JKQTMathTextToHTML Convert to HTML
2019-01-19 23:54:31 +08:00
2015-07-11 18:56:02 +08:00
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 !
*/
2019-06-22 20:21:32 +08:00
class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
2015-07-11 18:56:02 +08:00
Q_OBJECT
public :
2019-02-08 00:24:46 +08:00
/** \brief minimum linewidth allowed in a JKQTMathText (given in pt) */
static const double ABS_MIN_LINEWIDTH ;
2022-06-03 03:02:23 +08:00
2015-07-11 18:56:02 +08:00
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTMathText ( QObject * parent = nullptr ) ;
2015-07-11 18:56:02 +08:00
/** \brief class destructor */
2019-01-20 17:49:29 +08:00
~ JKQTMathText ( ) ;
2015-07-11 18:56:02 +08:00
/** \brief load the object settings from the given QSettings object with the given name prefix */
2019-02-08 00:24:46 +08:00
void loadSettings ( const QSettings & settings , const QString & group = QString ( " mathtext/ " ) ) ;
2015-07-11 18:56:02 +08:00
/** \brief store the object settings to the given QSettings object with the given name prefix */
2019-02-08 00:24:46 +08:00
void saveSettings ( QSettings & settings , const QString & group = QString ( " mathtext/ " ) ) const ;
2022-06-03 05:24:41 +08:00
/** \brief parse the given enhanced string. If \c addSpaceBeforeAndAfter==true a little bit of space is added before and after the text. Returns \c true on success. */
bool parse ( const QString & text , bool addSpaceBeforeAndAfter = false ) ;
2015-07-11 18:56:02 +08:00
/** \brief get the size of the drawn representation. returns an invalid size if no text has been parsed. */
QSizeF getSize ( QPainter & painter ) ;
/** \brief return the descent, i.e. the distance from the baseline to the lowest part of the representation */
double getDescent ( QPainter & painter ) ;
/** \brief return the ascentt, i.e. the distance from the baseline to the highest part of the representation */
double getAscent ( QPainter & painter ) ;
/** \brief return the detailes sizes of the text */
void getSizeDetail ( QPainter & painter , double & width , double & ascent , double & descent , double & strikeoutPos ) ;
2022-07-04 03:30:12 +08:00
/** \brief draw a representation to the object at the specified position \a x , \a y
*
* \ param painter the < a href = " http://doc.qt.io/qt-5/qpainter.html " > QPainter < / a > to use for drawing
* \ param x position of the left border of the text / expression to be drawn ( see sketch below )
* \ param drawBoxes if \ c true boxes defining the size of each node are drawn , example output : \ image html jkqtmathtext / jkqtmathtext_drawboxes . png
*
* Here is an illustration of the geometry of the drawn text / expression :
* \ image html jkqtmathtext / jkqtmathtext_node_geo . png
*/
void draw ( QPainter & painter , QPointF x , bool drawBoxes = false ) ;
/** \brief draw a representation to the object at the specified position \a x , \a y
*
* \ param painter the < a href = " http://doc.qt.io/qt-5/qpainter.html " > QPainter < / a > to use for drawing
* \ param x x - position of the left border of the text / expression to be drawn ( see sketch below )
* \ param y y - position of the baseline of the text / expression to be drawn ( see sketch below )
* \ param drawBoxes if \ c true boxes defining the size of each node are drawn , example output : \ image html jkqtmathtext / jkqtmathtext_drawboxes . png
*
* Here is an illustration of the geometry of the drawn text / expression :
* \ image html jkqtmathtext / jkqtmathtext_node_geo . png
*/
2015-07-11 18:56:02 +08:00
void draw ( QPainter & painter , double x , double y , bool drawBoxes = false ) ;
2022-07-04 03:30:12 +08:00
/** \brief draw into a rectangle \a rect with alignment defined in \a flags (see below)
*
* \ param painter the < a href = " http://doc.qt.io/qt-5/qpainter.html " > QPainter < / a > to use for drawing
* \ param rect rectangle to draw the text / expression into ( see sketch below )
2022-07-24 20:50:28 +08:00
* \ param flags alignment within \ a rect ( see below ) , use e . g . < tt > Qt : : AlignHCenter | Qt : : AlignVCenter < / tt > to center the expression inside \ a rect
2022-07-04 03:30:12 +08:00
* \ param drawBoxes if \ c true boxes defining the size of each node are drawn , example output : \ image html jkqtmathtext / jkqtmathtext_drawboxes . png
2015-07-11 18:56:02 +08:00
*
2022-07-04 03:30:12 +08:00
* These options are interpreted for \ a flags ( dark - red is the rectangle \ a rect ) :
* \ image html jkqtmathtext / jkqtmathtext_draw_flags . png
2015-07-11 18:56:02 +08:00
*/
2019-05-01 20:58:19 +08:00
void draw ( QPainter & painter , unsigned int flags , QRectF rect , bool drawBoxes = false ) ;
2015-07-11 18:56:02 +08:00
2019-06-30 23:34:41 +08:00
/** \brief convert LaTeX to HTML. returns \c ok=true on success and \c ok=false else. */
QString toHtml ( bool * ok = nullptr , double fontPointSize = 10 ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc fontColor */
2019-06-30 23:34:41 +08:00
void setFontColor ( const QColor & __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc fontColor */
2019-06-30 23:34:41 +08:00
QColor getFontColor ( ) const ;
2022-07-05 03:02:43 +08:00
/** \copydoc setFontPointSize() */
2019-06-30 23:34:41 +08:00
void setFontSize ( double __value ) ;
2022-07-05 03:02:43 +08:00
/** \brief set the default font size in points
* \ see getFontSize ( ) , fontSize , fontSizeUnits */
void setFontPointSize ( double __value ) ;
/** \brief set the default font soze in pixels
* \ see getFontSizePixels ( ) , fontSize , fontSizeUnits */
void setFontSizePixels ( double __value ) ;
/** \brief 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 setFontSize ( ) , fontSize , fontSizeUnits */
double getFontPointSize ( ) const ;
/** \copydoc getFontPointSize() */
2019-06-30 23:34:41 +08:00
double getFontSize ( ) const ;
2022-07-05 03:02:43 +08:00
/** \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 ;
2019-06-30 23:34:41 +08:00
/** \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 .
* These are automatically applied , when setting a new font name !
*
* \ param nonUseFont the font not to use
* \ param useFont replacement 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 !
*/
void addReplacementFont ( const QString & nonUseFont , const QString & useFont ) ;
/** \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 .
* These are automatically applied , when setting a new font name !
*
* \ param nonUseFont the font not to use
* \ param useFont replacement font for nonUseFont
* \ param useFontEncoding encoding of the replacement font
*/
2022-06-08 21:38:26 +08:00
void addReplacementFont ( const QString & nonUseFont , const QString & useFont , JKQTMathTextFontEncoding useFontEncoding ) ;
2019-06-30 23:34:41 +08:00
/** \brief retrieves a replacement for the given font name \a nonUseFont, including its encoding. Returns the given default values \a defaultFont and/or \a defaultFontEncoding if one of the two is not found */
2022-06-08 21:38:26 +08:00
QPair < QString , JKQTMathTextFontEncoding > getReplacementFont ( const QString & nonUseFont , const QString & defaultFont , JKQTMathTextFontEncoding defaultFontEncoding ) const ;
2019-06-30 23:34:41 +08:00
/** \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 */
2022-07-04 02:30:12 +08:00
QPair < QString , JKQTMathTextFontEncoding > getFontData ( JKQTMathTextEnvironmentFont font , bool in_math_environment = false ) const ;
2019-06-30 23:34:41 +08:00
/*! \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 */
2022-06-08 21:38:26 +08:00
void setFontRomanOrSpecial ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2022-06-03 03:02:23 +08:00
/*! \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 */
2022-06-08 21:38:26 +08:00
void setFontRomanOrSpecial ( const JKQTMathTextFontSpecifier & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2019-06-30 23:34:41 +08:00
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEroman */
2022-06-08 21:38:26 +08:00
void setFontRoman ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEroman */
2019-06-30 23:34:41 +08:00
QString getFontRoman ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEsans */
2022-06-08 21:38:26 +08:00
void setFontSans ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEsans */
2019-06-30 23:34:41 +08:00
QString getFontSans ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEtypewriter */
2022-06-08 21:38:26 +08:00
void setFontTypewriter ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEtypewriter */
2019-06-30 23:34:41 +08:00
QString getFontTypewriter ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEscript */
2022-06-08 21:38:26 +08:00
void setFontScript ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEscript */
2019-06-30 23:34:41 +08:00
QString getFontScript ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEfraktur */
2022-06-08 21:38:26 +08:00
void setFontFraktur ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEfraktur */
2019-06-30 23:34:41 +08:00
QString getFontFraktur ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEcaligraphic */
2022-06-08 21:38:26 +08:00
void setFontCaligraphic ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEcaligraphic */
2019-06-30 23:34:41 +08:00
QString getFontCaligraphic ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEblackboard */
2022-06-08 21:38:26 +08:00
void setFontBlackboard ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief blackboard font is simulated by using roman with outlines only */
2019-06-30 23:34:41 +08:00
void setFontBlackboardSimulated ( bool doSimulate ) ;
2020-09-21 19:47:54 +08:00
/** \brief is blackboard font simulated by using roman with outlines only */
2019-06-30 23:34:41 +08:00
bool isFontBlackboardSimulated ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEblackboard */
2019-06-30 23:34:41 +08:00
QString getFontBlackboard ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for symbols in the logical font \a font */
2022-07-04 02:30:12 +08:00
void setFallbackFontSymbols ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for symbols in the logical font \a font */
2022-07-04 02:30:12 +08:00
QString getFallbackFontSymbols ( ) const ;
2019-06-30 23:34:41 +08:00
2022-07-04 02:30:12 +08:00
/** \brief retrieves the encoding used for the symbol font to be used for symbols */
JKQTMathTextFontEncoding getFontEncodingFallbackFontSymbols ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the script font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingScript ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the Fraktur font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingFraktur ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the typewriter font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingTypewriter ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the sans-serif font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingSans ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the roman font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingRoman ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the blackboard font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingBlackboard ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the caligraphic font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingCaligraphic ( ) const ;
2019-06-30 23:34:41 +08:00
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEmathRoman */
2022-06-08 21:38:26 +08:00
void setFontMathRoman ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEroman */
2019-06-30 23:34:41 +08:00
QString getFontMathRoman ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEmathSans */
2022-06-08 21:38:26 +08:00
void setFontMathSans ( const QString & fontName , JKQTMathTextFontEncoding encoding = JKQTMathTextFontEncoding : : MTFEStandard ) ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the font to be used for text in the logical font MTEsans */
2019-06-30 23:34:41 +08:00
QString getFontMathSans ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the math-mode sans-serif font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingMathSans ( ) const ;
2020-09-21 19:47:54 +08:00
/** \brief retrieves the encoding used for the math-mode roman font */
2022-06-08 21:38:26 +08:00
JKQTMathTextFontEncoding getFontEncodingMathRoman ( ) const ;
2019-06-30 23:34:41 +08:00
2019-01-19 16:40:52 +08:00
/** \brief configures the class to use the STIX fonts in mathmode
*
* use STIX ( 1. x / 2. x ) fonts from < a href = " https://www.stixfonts.org/ " > https : //www.stixfonts.org/</a> in math-mode
*
2022-07-24 20:50:28 +08:00
* \ image html jkqtmathtext / jkqtmathtext_stix . png
2019-01-19 16:40:52 +08:00
*/
2019-06-30 23:34:41 +08:00
bool useSTIX ( bool mathModeOnly = true ) ;
2015-07-11 18:56:02 +08:00
2019-01-19 16:40:52 +08:00
/** \brief configures the class to use the XITS fonts in mathmode
*
* use XITS fonts from < a href = " https://github.com/alif-type/xits " > https : //github.com/alif-type/xits</a> in math-mode.
* These are included by default in this library and also activated by default .
*
2022-07-24 20:50:28 +08:00
* \ image html jkqtmathtext / jkqtmathtext_xits . png
2020-06-28 15:49:20 +08:00
*
* \ note The XITS fonts can be compiled into JKQTPlotter , when the CMake - option \ c 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 .
2019-01-19 16:40:52 +08:00
*/
2019-06-30 23:34:41 +08:00
bool useXITS ( bool mathModeOnly = true ) ;
2015-07-11 18:56:02 +08:00
2019-01-19 16:40:52 +08:00
/** \brief configures the class to use the ASANA fonts in mathmode
*
* 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
*
2022-07-24 20:50:28 +08:00
* \ image html jkqtmathtext / jkqtmathtext_asana . png
2019-01-19 16:40:52 +08:00
*/
2019-06-30 23:34:41 +08:00
bool useASANA ( bool mathModeOnly = true ) ;
2015-07-11 18:56:02 +08:00
2019-06-30 23:34:41 +08:00
/** \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
2019-01-19 16:40:52 +08:00
*
2022-07-05 03:02:43 +08:00
* \ 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 .
2019-01-19 16:40:52 +08:00
*
2022-07-24 20:50:28 +08:00
* < code > useAnyUnicode ( " Times New Roman " , " Times New Roman " ) < / code > : < br > \ image html jkqtmathtext / jkqtmathtext_timesnewroman . png < br > < br >
* < code > useAnyUnicode ( " Arial " , " Arial " ) < / code > : < br > \ image html jkqtmathtext / jkqtmathtext_arial . png < br > < br >
* < code > useAnyUnicode ( " Courier New " , " Courier New " ) < / code > : < br > \ image html jkqtmathtext / jkqtmathtext_couriernew . png < br > < br >
* < code > useAnyUnicode ( " Comic Sans MS " , " Comic Sans MS " ) < / code > : < br > \ image html jkqtmathtext / jkqtmathtext_comicsans . png < br > < br >
* < code > useAnyUnicodeForTextOnly ( " Comic Sans MS " , " Comic Sans MS " ) ; < / code > : < br / > \ image html jkqtmathtext / jkqtmathtext_comicsans_textonly . png
2019-01-19 16:40:52 +08:00
*/
2022-07-05 03:02:43 +08:00
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
*
* \ 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 ( )
*/
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 ( )
2022-07-06 04:03:08 +08:00
*
2022-07-24 20:50:28 +08:00
* < code > useAnyUnicode ( " Comic Sans MS " , " Comic Sans MS " ) < / code > : < br > \ image html jkqtmathtext / jkqtmathtext_comicsans . png < br > < br >
* < code > useAnyUnicodeForTextOnly ( " Comic Sans MS " , " Comic Sans MS " ) ; < / code > : < br / > \ image html jkqtmathtext / jkqtmathtext_comicsans_textonly . png
2022-07-05 03:02:43 +08:00
*/
void useAnyUnicodeForTextOnly ( QString timesFont , const QString & sansFont , JKQTMathTextFontEncoding encodingTimes = JKQTMathTextFontEncoding : : MTFEUnicode , JKQTMathTextFontEncoding encodingSans = JKQTMathTextFontEncoding : : MTFEUnicode ) ;
2015-07-11 18:56:02 +08:00
2020-09-21 19:47:54 +08:00
/** \copydoc brace_factor */
2019-06-30 23:34:41 +08:00
void setBraceFactor ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc brace_factor */
2019-06-30 23:34:41 +08:00
double getBraceFactor ( ) const ;
2022-06-26 06:28:49 +08:00
/** \copydoc subsuper_size_factor */
2019-06-30 23:34:41 +08:00
void setSubsuperSizeFactor ( double __value ) ;
2022-06-26 06:28:49 +08:00
/** \copydoc subsuper_size_factor */
2019-06-30 23:34:41 +08:00
double getSubsuperSizeFactor ( ) const ;
2022-06-26 06:28:49 +08:00
/** \copydoc subsuper_mode_selection_by_size_factor */
void setSubsuperModeSelectionBySizeFactor ( double __value ) ;
/** \copydoc subsuper_mode_selection_by_size_factor */
double getSubsuperModeSelectionBySizeFactor ( ) const ;
/** \copydoc italic_correction_factor */
2019-06-30 23:34:41 +08:00
void setItalicCorrectionFactor ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc italic_correction_factor */
2019-06-30 23:34:41 +08:00
double getItalicCorrectionFactor ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc operatorsubsuper_size_factor */
2019-06-30 23:34:41 +08:00
void setOperatorsubsuperSizeFactor ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc operatorsubsuper_size_factor */
2019-06-30 23:34:41 +08:00
double getOperatorsubsuperSizeFactor ( ) const ;
2022-06-26 06:28:49 +08:00
/** \copydoc operatorsubsuper_distance_factor */
void setOperatorsubsuperDistanceFactor ( double __value ) ;
/** \copydoc operatorsubsuper_distance_factor */
double getOperatorsubsuperDistanceFactor ( ) const ;
/** \copydoc operatorsubsuper_extraspace_factor */
void setOperatorsubsuperExtraSpaceFactor ( double __value ) ;
/** \copydoc operatorsubsuper_extraspace_factor */
double getOperatorsubsuperExtraSpaceFactor ( ) const ;
/** \copydoc mathoperator_width_factor */
2019-06-30 23:34:41 +08:00
void setMathoperatorWidthFactor ( double __value ) ;
2022-06-26 06:28:49 +08:00
/** \copydoc mathoperator_width_factor */
2019-06-30 23:34:41 +08:00
double getMathoperatorWidthFactor ( ) const ;
2022-06-28 04:57:49 +08:00
/** \copydoc intsubsuper_xcorrection_factor */
void setIntSubSuperXCorrectionFactor ( double __value ) ;
/** \copydoc intsubsuper_xcorrection_factor */
double getIntSubSuperXCorrectionFactor ( ) const ;
/** \copydoc intsubbesides_xcorrection_xfactor */
void setIntSubBesidesXCorrectionXFactor ( double __value ) ;
/** \copydoc intsubbesides_xcorrection_xfactor */
double getIntSubBesidesXCorrectionXFactor ( ) const ;
2022-06-26 06:28:49 +08:00
/** \copydoc bigmathoperator_font_factor */
void setBigMathoperatorFontFactor ( double __value ) ;
/** \copydoc bigmathoperator_font_factor */
double getBigMathoperatorFontFactor ( ) const ;
/** \copydoc super_shift_factor */
2019-06-30 23:34:41 +08:00
void setSuperShiftFactor ( double __value ) ;
2022-06-26 06:28:49 +08:00
/** \copydoc super_shift_factor */
2019-06-30 23:34:41 +08:00
double getSuperShiftFactor ( ) const ;
2022-06-26 06:28:49 +08:00
/** \copydoc sub_shift_factor */
2019-06-30 23:34:41 +08:00
void setSubShiftFactor ( double __value ) ;
2022-06-26 06:28:49 +08:00
/** \copydoc sub_shift_factor */
2019-06-30 23:34:41 +08:00
double getSubShiftFactor ( ) const ;
2022-06-26 06:28:49 +08:00
/** \copydoc special_super_shift_factor */
void setSpecialSuperShiftFactor ( double __value ) ;
/** \copydoc special_super_shift_factor */
double getSpecialSuperShiftFactor ( ) const ;
/** \copydoc special_sub_shift_factor */
void setSpecialSubShiftFactor ( double __value ) ;
/** \copydoc special_sub_shift_factor */
double getSpecialSubShiftFactor ( ) const ;
/** \copydoc brace_shrink_factor */
2019-06-30 23:34:41 +08:00
void setBraceShrinkFactor ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc brace_shrink_factor */
2019-06-30 23:34:41 +08:00
double getBraceShrinkFactor ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc underbrace_factor */
2019-06-30 23:34:41 +08:00
void setUnderbraceFactor ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc underbrace_factor */
2019-06-30 23:34:41 +08:00
double getUnderbraceFactor ( ) const ;
2022-06-28 03:09:22 +08:00
/** \copydoc underbrace_separation_xfactor */
void setUnderbraceSeparationXFactor ( double __value ) ;
/** \copydoc underbrace_separation_xfactor */
double getUnderbraceSeparationXFactor ( ) const ;
/** \copydoc underbrace_bracesize_xfactor */
void setUnderbraceBraceSizeXFactor ( double __value ) ;
/** \copydoc underbrace_bracesize_xfactor */
double getUnderbraceBraceSizeXFactor ( ) const ;
2022-07-24 20:50:28 +08:00
/** \copydoc underset_factor */
2019-06-30 23:34:41 +08:00
void setUndersetFactor ( double __value ) ;
2022-07-24 20:50:28 +08:00
/** \copydoc underset_factor */
2019-06-30 23:34:41 +08:00
double getUndersetFactor ( ) const ;
2022-06-09 05:52:22 +08:00
/** \copydoc frac_factor */
2019-06-30 23:34:41 +08:00
void setFracFactor ( double __value ) ;
2022-06-09 05:52:22 +08:00
/** \copydoc frac_factor */
2019-06-30 23:34:41 +08:00
double getFracFactor ( ) const ;
2022-06-09 05:52:22 +08:00
/** \copydoc frac_nested_factor */
void setFracNestedFactor ( double __value ) ;
/** \copydoc frac_nested_factor */
double getFracNestedFactor ( ) const ;
/** \copydoc frac_shift_factor */
2019-06-30 23:34:41 +08:00
void setFracShiftFactor ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc frac_shift_factor */
2019-06-30 23:34:41 +08:00
double getFracShiftFactor ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc brace_y_shift_factor */
2019-06-30 23:34:41 +08:00
void setBraceYShiftFactor ( double __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc brace_y_shift_factor */
2019-06-30 23:34:41 +08:00
double getBraceYShiftFactor ( ) const ;
2022-06-07 05:24:05 +08:00
/** \copydoc decoration_height_factor */
2019-06-30 23:34:41 +08:00
void setDecorationHeightFactor ( double __value ) ;
2022-06-07 05:24:05 +08:00
/** \copydoc decoration_height_factor */
2019-06-30 23:34:41 +08:00
double getDecorationHeightFactor ( ) const ;
2022-06-29 05:14:31 +08:00
/** \copydoc decoration_separation_factor */
void setDecorationSeparationXFactor ( double __value ) ;
/** \copydoc decoration_separation_factor */
double getDecorationSeparationFactor ( ) const ;
2022-06-07 05:24:05 +08:00
/** \copydoc decoration_width_reduction_Xfactor */
2022-06-29 05:14:31 +08:00
void setDecorationWidthReductionFactor ( double __value ) ;
2022-06-07 05:24:05 +08:00
/** \copydoc decoration_width_reduction_Xfactor */
double getDecorationWidthReductionXFactor ( ) const ;
2022-06-28 18:00:20 +08:00
/** \copydoc sqrt_width_Xfactor */
void setSqrtWidthXFactor ( double __value ) ;
/** \copydoc sqrt_width_Xfactor */
double getSqrtWidthXFactor ( ) const ;
/** \copydoc sqrt_height_factor */
void setSqrtHeightFactor ( double __value ) ;
/** \copydoc sqrt_height_factor */
double getSqrtHeightFactor ( ) const ;
/** \copydoc sqrt_smallfont_factor */
void setSqrtSmallFontFactor ( double __value ) ;
/** \copydoc sqrt_smallfont_factor */
double getSqrtSmallFontFactor ( ) const ;
2020-09-21 19:47:54 +08:00
/** \copydoc useUnparsed */
2019-06-30 23:34:41 +08:00
void setUseUnparsed ( bool __value ) ;
2020-09-21 19:47:54 +08:00
/** \copydoc useUnparsed */
2019-06-30 23:34:41 +08:00
bool isUsingUnparsed ( ) const ;
2022-06-08 21:38:26 +08:00
/** \copydoc error_list */
2019-06-30 23:34:41 +08:00
QStringList getErrorList ( ) const ;
2022-06-08 21:38:26 +08:00
/** \copydoc error_list */
void addToErrorList ( const QString & error ) ;
2015-07-11 18:56:02 +08:00
protected :
2019-05-06 01:31:20 +08:00
/** \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
* an alternative using addReplacementFont ( ) . These are automatically applied , when setting a new font name ! */
QMap < QString , QString > fontReplacements ;
2019-06-30 23:34:41 +08:00
/** \brief 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! */
2022-06-08 21:38:26 +08:00
QMap < QString , JKQTMathTextFontEncoding > fontEncodingReplacements ;
2015-07-11 18:56:02 +08:00
/** \brief font color */
2019-01-10 04:23:24 +08:00
QColor fontColor ;
2022-07-05 03:02:43 +08:00
/** \brief base font size in the units defined in fontSizeUnits \see fontSizeUnits */
2019-01-10 04:23:24 +08:00
double fontSize ;
2022-07-05 03:02:43 +08:00
/** \brief unit of fontSize */
JKQTMathTextEnvironment : : FontSizeUnit fontSizeUnits ;
2019-06-30 23:34:41 +08:00
/** \brief stores information about the different fonts used by LaTeX markup */
2022-06-08 21:38:26 +08:00
QHash < JKQTMathTextEnvironmentFont , JKQTMathTextFontDefinition > fontDefinitions ;
2019-06-30 23:34:41 +08:00
/** \brief if enabled, the blackboard-characters are simulated by using font outlines only */
bool blackboardSimulated ;
2015-07-11 18:56:02 +08:00
/** \brief resizing factor for braces in math mode */
2019-01-10 04:23:24 +08:00
double brace_factor ;
2015-07-11 18:56:02 +08:00
/** \brief shrinking the width of braces in math mode 0: reduce to 0 pixel width, 1: leave unchanged*/
2019-01-10 04:23:24 +08:00
double brace_shrink_factor ;
2015-07-11 18:56:02 +08:00
/** \brief resizing factor for font size in sub-/superscript */
2019-01-10 04:23:24 +08:00
double subsuper_size_factor ;
2022-06-26 06:28:49 +08:00
/** \brief 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 \ c > = subsuper_mode_selection_by_size_factor * ascent ( currentFont )
* or \ c < = 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 :
*
* < b > Default mode : < / b >
* \ image html jkqtmathtext_superscriptnode_getSizeInternal . png
* \ image html jkqtmathtext_subscriptnode_getSizeInternal . png
*
* < b > Special mode : < / b >
*
*
* This method fixes problems with characters that are significantyl larger that normal text character of the fonst , such as generated
* by \ c \ \ sum , \ \ int , . . . .
*/
double subsuper_mode_selection_by_size_factor ;
2015-07-11 18:56:02 +08:00
/** \brief fraction of a whitespace by which to shift a sub-/superscript left/right when the previous text is italic */
2019-01-10 04:23:24 +08:00
double italic_correction_factor ;
2022-06-26 06:28:49 +08:00
/** \brief like subsuper_size_factor, but for operators (\c \\sum , \c \\int , ...) where the text is placed above/below the symbol */
2019-01-10 04:23:24 +08:00
double operatorsubsuper_size_factor ;
2022-06-26 06:28:49 +08:00
/** \brief for operators (\c \\sum , \c \\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
*
* \ image html jkqtmathtext_subsuper_with_limits . png
*/
double operatorsubsuper_distance_factor ;
/** \brief for operators (\c \\sum , \c \\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
*
* \ image html jkqtmathtext_subsuper_with_limits . png
*/
double operatorsubsuper_extraspace_factor ;
2022-06-28 04:57:49 +08:00
/** \brief for integrals (\c \\int , \c \\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 , . . .
*/
double intsubsuper_xcorrection_factor ;
/** \brief for integrals (\c \\int , \c \\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 , . . .
*/
double intsubbesides_xcorrection_xfactor ;
2022-06-20 18:17:32 +08:00
/** \brief 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 :
*
2022-07-24 20:50:28 +08:00
* \ image html jkqtmathtext / jkqtmathtext_mathoperator_width_factor . png
2022-06-20 18:17:32 +08:00
*/
2019-01-10 04:23:24 +08:00
double mathoperator_width_factor ;
2022-06-26 06:28:49 +08:00
/** \brief factor, used to increase the font size for big math operators, such as \c \\sum , \c \\prod , ...
*
*/
double bigmathoperator_font_factor ;
2015-07-11 18:56:02 +08:00
/** \brief relative shift of text in superscript to normal text:
2022-06-20 18:17:32 +08:00
* 0 = baseline kept , 1 : baseline shifted to top of normal text
*
* \ image html jkqtmathtext_superscriptnode_getSizeInternal . png
*/
2019-01-10 04:23:24 +08:00
double super_shift_factor ;
2015-07-11 18:56:02 +08:00
/** \brief relative shift of text in subscript to normal text:
2022-06-20 18:17:32 +08:00
* 0 = baseline kept , 1 : baseline shifted to bottom of normal text
*
* \ image html jkqtmathtext_subscriptnode_getSizeInternal . png
*/
2019-01-10 04:23:24 +08:00
double sub_shift_factor ;
2022-06-26 06:28:49 +08:00
/** \brief 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
*
* \ image html jkqtmathtext_specialsuperscriptnode_getSizeInternal . png
*/
double special_super_shift_factor ;
/** \brief 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
*
* \ image html jkqtmathtext_specialsubscriptnode_getSizeInternal . png
*/
double special_sub_shift_factor ;
2019-06-30 23:34:41 +08:00
2022-06-20 18:17:32 +08:00
/** \brief scaling factor for font size of nominator and denominator of a fraction
*
2022-07-24 20:50:28 +08:00
* \ image html jkqtmathtext / jkqtmathtext_frac_factor . png
2022-06-20 18:17:32 +08:00
*/
2019-01-10 04:23:24 +08:00
double frac_factor ;
2022-06-20 18:17:32 +08:00
/** \brief scaling factor for font size of nominator and denominator of a nested fraction
*
2022-07-24 20:50:28 +08:00
* \ image html jkqtmathtext / jkqtmathtext_frac_factor . png
2022-06-20 18:17:32 +08:00
*/
2022-06-09 05:52:22 +08:00
double frac_nested_factor ;
2022-06-20 18:17:32 +08:00
/** \brief shift of denominator/nummerator away from central line of a frac
*
* \ image html jkqtmathtext_fracnode_geo . png
*/
2019-01-10 04:23:24 +08:00
double frac_shift_factor ;
2015-07-11 18:56:02 +08:00
/** \brief scaling factor for font of underbrace/overbrace text */
2019-01-10 04:23:24 +08:00
double underbrace_factor ;
2015-07-11 18:56:02 +08:00
/** \brief scaling factor for font of underset/overset text */
2022-06-20 18:17:32 +08:00
double underset_factor ;
2022-06-28 03:09:22 +08:00
/** \brief additional space between the main text to the curly brace and the brace to underbrace/overbrace, multiplied with height("x") */
double underbrace_separation_xfactor ;
/** \brief height of the brace in underbrace/overbrace, multiplied with ascent */
double underbrace_bracesize_xfactor ;
2015-07-11 18:56:02 +08:00
/** \brief fraction of the brace ascent that the brace is shifted downwards, when scaled */
2019-01-10 04:23:24 +08:00
double brace_y_shift_factor ;
2022-06-29 05:14:31 +08:00
/** \brief size of the decorations (dot, tilde, ...), as fraction of the ascent
2022-06-07 05:24:05 +08:00
*
2022-06-09 20:42:25 +08:00
* \ image html jkqtmathtext / decoration_sizing . png
2022-06-07 05:24:05 +08:00
*/
2019-01-10 04:23:24 +08:00
double decoration_height_factor ;
2022-06-29 05:14:31 +08:00
/** \brief separation between the text and the decorations (dot, tilde, ...), as fraction of the ascent
*
* \ image html jkqtmathtext / decoration_sizing . png
*/
double decoration_separation_factor ;
2022-06-07 05:24:05 +08:00
/** \brief a decoration has a size, which is slightly smaller than the text- width. the width is reduced by \c decoration_width_reduction_Xfactor*width("X") and the position is centered around the child-box. Also an italic correction is applied:
*
2022-06-09 20:42:25 +08:00
* \ image html jkqtmathtext / decoration_sizing . png
2022-06-07 05:24:05 +08:00
*/
double decoration_width_reduction_Xfactor ;
2022-06-28 18:00:20 +08:00
/** \brief scaling factor for the small font used to indicate the degree of the sqrt */
double sqrt_smallfont_factor ;
/** \brief width of the sqrt-symbol, as factor to width("X") */
double sqrt_width_Xfactor ;
/** \brief height-increase of the sqrt-symbol, as factor of the child's height */
double sqrt_height_factor ;
2015-07-11 18:56:02 +08:00
/** \brief a list that will be filled with error messages while parsing, if any error occur */
QStringList error_list ;
/** \brief the result of parsing the last string supplied to the object via parse() */
2022-06-08 21:38:26 +08:00
JKQTMathTextNode * parsedNode ;
2015-07-11 18:56:02 +08:00
/** \brief a tree containing the unparsed text as a single node */
2022-06-08 21:38:26 +08:00
JKQTMathTextNode * unparsedNode ;
2015-07-11 18:56:02 +08:00
/** \brief if true, the unparsedNode is drawn */
bool useUnparsed ;
2022-06-20 18:17:32 +08:00
/** \brief returns the syntax tree of JKQTMathTextNode's that was created by the last parse call */
JKQTMathTextNode * getNodeTree ( ) const ;
2015-07-11 18:56:02 +08:00
/** \brief the token types that may arrise in the string */
enum tokenType {
2022-06-19 21:11:06 +08:00
MTTnone , /*!< \brief no token */
MTTtext , /*!< \brief a piece of general text */
2022-07-31 14:32:36 +08:00
MTTinstruction , /*!< \brief an instruction, started by \c "\", e.g. \c "\\textbf", ... */
MTTinstructionNewline , /*!< \brief a newline instruction \c "\\" */
2022-06-20 18:17:32 +08:00
MTTunderscore , /*!< \brief the character \c "_" */
MTThat , /*!< \brief the character \c "^" */
MTTdollar , /*!< \brief the character \c "$" */
MTTopenbrace , /*!< \brief the character \c "{" */
MTTclosebrace , /*!< \brief the character \c "}" */
MTTopenbracket , /*!< \brief the character \c "[" */
MTTclosebracket , /*!< \brief the character \c "]" */
2022-06-19 21:11:06 +08:00
MTTwhitespace , /*!< \brief some whitespace */
2022-07-31 05:30:47 +08:00
MTTampersand , /*!< \brief the character \c "&" */
2022-08-01 17:44:38 +08:00
MTThyphen , /*!< \brief the single hyphen character \c "-" in text-mode \note MTTendash and MTTemdash take precedence over MTThypen */
MTTendash , /*!< \brief the en-dash character sequence \c "--" in text-mode */
MTTemdash , /*!< \brief the em-dash character sequence \c "---" in text-mode */
2015-07-11 18:56:02 +08:00
} ;
/** \brief tokenizer for the LaTeX parser */
tokenType getToken ( ) ;
2022-06-19 21:11:06 +08:00
/** \brief parse a LaTeX string
*
* \ param get if \ c true this calls getToken ( )
* \ param quitOnClosingBrace if unequal MTBTAny , this returns if the given closing brace is found
2022-07-24 20:50:28 +08:00
* \ param quitOnEnvironmentEnd wuit if \ c \ \ end { quitOnEnvironmentEnd } is found
2022-06-19 21:11:06 +08:00
* \ param quitOnClosingBracket if \ c true , quits on encountering a MTTclosebracket token
*/
JKQTMathTextNode * parseLatexString ( bool get , JKQTMathTextBraceType quitOnClosingBrace = JKQTMathTextBraceType : : MTBTAny , const QString & quitOnEnvironmentEnd = QString ( " " ) , bool quitOnClosingBracket = false ) ;
2022-07-09 05:15:42 +08:00
/** \brief parses a list of string-arguments, i.e. \c {p1}{p2}{...}
*
* \ param get call getToken ( ) at the start , otherwise it is expected that currentToken = = MTTopenbrace
* \ param Nparams the number of parameters to expect
* \ param [ out ] foundError will be set to \ c true if an error occured ( unexpected token ) or \ c false otherwise
* \ return the list of parameter strings with Nparam entries or an empty or partial list on error
*/
QStringList parseStringParams ( bool get , size_t Nparams , bool * foundError = nullptr ) ;
2022-07-31 05:30:47 +08:00
/** \brief parses a string, i.e. a sequence of text and whitespaces. returns after any other token was found */
QString parseSingleString ( bool get ) ;
2022-07-09 05:15:42 +08:00
/** \brief parses a single instruction (including it's parameters)
*
* \ param [ out ] _foundError will be set to \ c true if an error occured ( unexpected token ) or \ c false otherwise
* \ param [ out ] getNew returns \ c true if the parser has to call getToken ( ) to go on
* \ return the instruction node or \ c nullptr on error ( then also \ a _foundError is set \ c true )
* \ note This method expects the current token currentToken to be MTTinstruction
*/
JKQTMathTextNode * parseInstruction ( bool * _foundError = nullptr , bool * getNew = nullptr ) ;
2015-07-11 18:56:02 +08:00
/** \brief parse a LaTeX math environment */
2022-06-08 21:38:26 +08:00
JKQTMathTextNode * parseMath ( bool get ) ;
2015-07-11 18:56:02 +08:00
/** \brief used by the tokenizer. type of the current token */
tokenType currentToken ;
2022-07-07 04:44:02 +08:00
/** \brief the JKQTMathTextBraceType associated with the last \c \\right command the parser encountered */
JKQTMathTextBraceType lastRightBraceType ;
2015-07-11 18:56:02 +08:00
/** \brief used by the tokenizer. Name of the current token, id applicable */
QString currentTokenName ;
/** \brief used by the tokenizer. Points to the currently read character in parseString */
int currentTokenID ;
/** \brief used by the tokenizer. The string to be parsed */
QString parseString ;
/** \brief used by the parser. indicates whether we are in a math environment */
bool parsingMathEnvironment ;
public :
2020-09-21 19:47:54 +08:00
/** \copydoc parsedNode */
2022-06-08 21:38:26 +08:00
JKQTMathTextNode * getParsedNode ( ) const ;
2015-07-11 18:56:02 +08:00
} ;
# endif // JKQTMATHTEXT_H