JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
jkqtmathtexttools.h
1/*
2 Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
3 with contributions from: Razi Alavizadeh
4
5
6
7 This software is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License (LGPL) as published by
9 the Free Software Foundation, either version 2.1 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License (LGPL) for more details.
16
17 You should have received a copy of the GNU Lesser General Public License (LGPL)
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21
22/*
23 Name: jkqtmathtext.h
24 Copyright: (c) 2010-2019
25 Author: Jan krieger <jan@jkrieger.de>, http://www.jkrieger.de/
26*/
27
28
29
30#ifndef JKQTMATHTEXTTOOLS_H
31#define JKQTMATHTEXTTOOLS_H
32
33#include <QObject>
34#include <QSettings>
35#include <QPainter>
36#include <QString>
37#include <QSet>
38#include <QFile>
39#include "jkqtmathtext/jkqtmathtext_imexport.h"
40#include <QWidget>
41#include <QLabel>
42#include <QHash>
43#include <QPainterPath>
44#include <QtMath>
45#include <QFontMetrics>
46#include <QFontMetricsF>
47class JKQTMathText; // forward
48
49
50
51/** \brief initialized Qt-ressources necessary for JKQTMathText
52 * \ingroup jkqtmathtext_tools
53 */
55
56
57/*! \brief represents a font specifier for JKQTMathText. The font consists of two parts: the actual font and the font used for math output (which may be empty)
58 \ingroup jkqtmathtext_tools
59
60 \section JKQTMathTextFontSpecifier_specialSyntax Font Definition Syntax
61 JKQTMathTextFontSpecifier::fromFontSpec() defines a special syntax that when parsed allows to seth the font,
62 a math-mode alternative:
63 - \c FONTNAME : set the text-mode font only
64 - \c FONTNAME+MATH_FONTNAME : set the text- and math-mode fonts
65
66
67
68
69 \section JKQTMathTextFontSpecifier_specialNames Special Font Names
70 This object also implements replacing special font names with actual fonts. Supported special font names are:
71 - \c default / \c app / \c application - the applications default font
72 - \c application-sf - a font for "sans", based on the application font
73 - \c times / \c serif - a general serif font
74 - \c sans-serif - a general sans-serif font
75 - \c typewriter - a general typewrter/monospaced font
76 - \c cursive
77 - \c decorative
78 - \c fantasy
79 - \c monospace
80 - \c system
81 .
82
83 If copiled with Qt>5.3 you can also use these:
84 - \c fixed
85 - \c smallest_readable
86 - \c title
87 - \c general
88 .
89
90 Also some sepcial fonts are defined:
91 - xits XITS fonts
92 - stix STIX fonts
93 - asana ASANA fonts
94 - fira Fira fonts
95*/
98 JKQTMathTextFontSpecifier(const QString& fontName, const QString& mathFontName);
99 /** \brief construct a JKQTMathTextFontSpecifier, by parsing a \a fontSpec string as defined in the struct description, see \ref JKQTMathTextFontSpecifier_specialNames . */
100 static JKQTMathTextFontSpecifier fromFontSpec(const QString& fontSpec);
101
102 /** \brief initialises the object with values from parsing a \a fontSpec string as defined in the struct description, see \ref JKQTMathTextFontSpecifier_specialNames . */
103 void setFontSpec(const QString& fontSpec);
104
105 /** \brief returns the object's constents as a fontSpec string with the form \c "FONT_NAME[+MATH_FONT_NAME]". */
106 QString getFontSpec() const;
107 /** \copydoc m_fontName */
108 QString fontName() const;
109 /** \copydoc m_mathFontName */
110 QString mathFontName() const;
111 /** \copydoc m_fallbackSymbolFont */
112 QString fallbackSymbolsFontName() const;
113
114 /** \copydoc m_fontName */
115 void setFontName(const QString& name);
116 /** \copydoc m_mathFontName */
117 void setmathFontName(const QString& name);
118 /** \copydoc fallbackSymbolsFontName */
119 void setFallbackSymbolsFontName(const QString& name);
120 /** \brief finds actual fonts for some predefined special font names, as listed in \ref JKQTMathTextFontSpecifier_specialNames */
121 static QString transformFontName(const QString& fontName, bool mathmode=false);
122 /** \brief same as transformFontName(), but also finds the actual name for XITS, STIX, ASANA,... */
123 static QString transformFontNameAndDecodeSpecialFonts(const QString& fontName, bool mathmode=false);
124 /** \brief leiefert \c true, wenn ein fontName() verfügbar ist */
125 bool hasFontName() const;
126 /** \brief leiefert \c true, wenn ein mathFontName() verfügbar ist */
127 bool hasMathFontName() const;
128 /** \brief leiefert \c true, wenn ein fallbcakSymbolsFontName() verfügbar ist */
130
131 /** \brief initialize with the font-families from the XITS package for text and math */
133
134 /** \brief initialize with the font-families from the XITS package for text and math */
136
137 /** \brief initialize with the font-families from the STIX package for text and math */
139
140 /** \brief initialize with the font-families from the Fira (Math) package for text and math */
142
143 /** \brief initialize with the default app font-families for "roman" text and math and tries to find a matching fallback-font. This may be used to initialize serif-fonts
144 *
145 * This method encodes some pre-coded knowledge of suitable combinations of fonts for different systems.
146 * e.g. on newer windows systems, the font "Segoe UI" is used for the GUI... a suitable math
147 * font with symbols is "Segoe UI Symbol" ...
148 */
150 /** \brief initialize with the default app font-families for "sans-serif" text and math and tries to find a matching fallback-font. This may be used to initialize sans-serif-fonts
151 *
152 * This method encodes some pre-coded knowledge of suitable combinations of fonts for different systems.
153 *
154 * This function e.g. checks whether the default app font is sans-serif and then looks for a serif
155 * font for the "sans" font class (so the two can be distinguished) and vice-versa.
156 */
158private:
159 /** \brief specifies the main font name */
160 QString m_fontName;
161 /** \brief specifies the math font to use in addition to fontName */
163 /** \brief specifies a font to be used for fallbackSymbols */
165 /** \brief if set \c true the fonts are transformed when fontname() or mathFontName() is called by calling transformFontNameAndDecodeSpecialFonts() */
167
168
169};
170
171
172/** \brief used to specify the font encoding used for drawing
173 * \ingroup jkqtmathtext_tools
174*/
176 MTFEWinSymbol=0, /*!< \brief This assumes that symbols shall be taken from a MS Windows style Symbol font */
177 MTFEUnicode=1, /*!< \brief This assumes that symbols shall be taken from a Unicode font, which ideally offers full symbol support (e.g. the XITS fonts, STIX fonts from <a href="http://www.stixfonts.org/">http://www.stixfonts.org/</a>)*/
178 MTFELatin1=2, /*!< \brief the encoding of a standard Latin1 TTF font (i.e. we can only expect letters,number and not many special characters) */
181
182/** \brief this function tries to determine the JKQTMathTextFontEncoding of a given font (HEURISTICS!!!)
183 * \ingroup jkqtmathtext_tools
184*/
186
187
188/** \brief used to specify how blackboard-fonts are drawn
189 * \ingroup jkqtmathtext_tools
190 *
191 * \see JKQTMathTextBlackboradDrawingMode2String(), String2JKQTMathTextBlackboradDrawingMode()
192*/
194 MTBBDMfontDirectly=0, /*!< \brief draw using the font specified by JKQTMathText::setFontBlackboard() \image html jkqtmathtext/jkqtmathtext_bb_font_directly.png */
195 MTBBDMsimulate, /*!< \brief simulate a blackboard font (i.e. draw the characters' outline only), based on the font specified by JKQTMathText::setFontBlackboard() (e.g. Arial or another sans-serif font is a good choice) \image html jkqtmathtext/jkqtmathtext_bb_simulate.png */
196 MTBBDMunicodeCharactersOrFontDirectly, /*!< \brief use the currently set font and look for special unicode-characters in it, uses the fallbackSymbolFont as fallback, use MTBBDMfontDirectly for characters that are not available \image html jkqtmathtext/jkqtmathtext_bb_unicode_or_font_directly.png */
197 MTBBDMunicodeCharactersOrSimulate, /*!< \brief use the currently set font and look for special unicode-characters in it, uses the fallbackSymbolFont as fallback, use MTBBDMsimulate for characters that are not available \image html jkqtmathtext/jkqtmathtext_bb_unicode_or_simulate.png */
198 MTBBDMdefault=MTBBDMunicodeCharactersOrFontDirectly /*!< \brief default drawing mode, same as MTBBDMunicodeCharactersOrFontDirectly */
200
201/** \brief this converts a JKQTMathTextBlackboradDrawingMode into a string
202 * \ingroup jkqtmathtext_tools
203 * \see String2JKQTMathTextBlackboradDrawingMode(), JKQTMathTextBlackboradDrawingMode
204*/
206/** \brief this converts a QString into a JKQTMathTextBlackboradDrawingMode
207 * \ingroup jkqtmathtext_tools
208 * \see JKQTMathTextBlackboradDrawingMode2String(), JKQTMathTextBlackboradDrawingMode
209*/
211
212
213
214/** \brief convert MTfontEncoding to a string
215 * \ingroup jkqtmathtext_tools
216 */
218
219/** \brief types of available braces
220 * \ingroup jkqtmathtext_tools
221 */
223 MTBTParenthesis=0, /*!< \brief parantheses () \image html jkqtmathtext/jkqtmathtext_brace_round.png */
224 MTBTSquareBracket, /*!< \brief brackets [] \image html jkqtmathtext/jkqtmathtext_brace_rect.png */
225 MTBTCurlyBracket, /*!< \brief curly braces {} \image html jkqtmathtext/jkqtmathtext_brace_curly.png */
226 MTBTAngleBracket, /*!< \brief angle backets <> \image html jkqtmathtext/jkqtmathtext_brace_tri.png */
227 MTBTCeilBracket, /*!< \brief ceil brackets \image html jkqtmathtext/jkqtmathtext_brace_ceil.png */
228 MTBTFloorBracket, /*!< \brief floor brackets \image html jkqtmathtext/jkqtmathtext_brace_floor.png */
229 MTBTDoubleLine, /*!< \brief double-line brackets (norm ||...||) \image html jkqtmathtext/jkqtmathtext_brace_dblline.png */
230 MTBTSingleLine, /*!< \brief single-line brackets (abs |...|) \image html jkqtmathtext/jkqtmathtext_brace_oneline.png */
231 MTBTTopCorner, /*!< \brief top-corner brackets \image html jkqtmathtext/jkqtmathtext_brace_ucorner.png */
232 MTBTBottomCorner, /*!< \brief bottom-corner brackets \image html jkqtmathtext/jkqtmathtext_brace_lcorner.png */
233 MTBTNone, /*!< \brief no bracket */
234 MTBTAny, /*!< \brief any bracket, used by JKQTMathText::parseLatexString() */
235 MTBTUnknown /*!< \brief an unknown tokenName presented to TokenName2JKQTMathTextBraceType() */
237/** \brief convert a JKQTMathTextBraceType into a string
238 * \ingroup jkqtmathtext_tools
239 */
241/** \brief convert a string \a tokenName describing a LaTeX Token or Instruction into an opening or closing JKQTMathTextBraceType
242 * \ingroup jkqtmathtext_tools
243 */
244JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceType TokenName2JKQTMathTextBraceType(const QString& tokenName, bool *isOpening=nullptr);
245/** \brief convert a string \a tokenName describing a LaTeX Instruction into an opening JKQTMathTextBraceType
246 * \ingroup jkqtmathtext_tools
247 *
248 * This returns a JKQTMathTextBraceType for which isPrintableJKQTMathTextBraceType() is \c true, or MTBTUnknown,
249 * never MTBTNone or MTBTAny.
250 */
252/** \brief convert a string \a tokenName describing a LaTeX Instruction into an opening or closing JKQTMathTextBraceType
253 * \ingroup jkqtmathtext_tools
254 *
255 * This returns a JKQTMathTextBraceType for which isPrintableJKQTMathTextBraceType() is \c true, or MTBTUnknown,
256 * never MTBTNone or MTBTAny.
257 */
259/** \brief return \c true if \a type represents a printable type of brace (including MTBTNone), basically \c true
260 * for any JKQTMathTextBraceType that can be used as parameter to JKQTMathTextBraceNode
261 * \ingroup jkqtmathtext_tools
262 */
264/** \brief returns true, if the given token/instruction-Name \a token ("{", "(", ..., "lceil", ".", ...) matches the given \a type (returns true, when \a type == MTBTAny )
265 * \ingroup jkqtmathtext_tools
266 *
267 * This accepts TokenName2JKQTMathTextBraceType(toke)==MTBTNone for any \a type, iff \a acceptMTBTNone \a ==true.
268 *
269 * Optionally returns in \a tokenEqualsNone whether \a token was encoding for MTBTNone .
270 */
271JKQTMATHTEXT_LIB_EXPORT bool TokenNameMatchesJKQTMathTextBraceType(const QString &token, JKQTMathTextBraceType type, bool acceptMTBTNone, bool *tokenEqualsNone=nullptr);
272/** \brief returns true, if the given instruction-Name \a token ("|", "{", ..., "lceil", ".", ...) matches the given \a type (returns true, when \a type == MTBTAny )
273 * \ingroup jkqtmathtext_tools
274 *
275 * This accepts TokenName2JKQTMathTextBraceType(toke)==MTBTNone for any \a type, iff \a acceptMTBTNone \a ==true.
276 *
277 * Optionally returns in \a tokenEqualsNone whether \a token was encoding for MTBTNone .
278 */
279JKQTMATHTEXT_LIB_EXPORT bool InstructionNameMatchesJKQTMathTextBraceType(const QString &token, JKQTMathTextBraceType type, bool acceptMTBTNone, bool *tokenEqualsNone=nullptr);
280
281/** \brief the available logical fonts (default is MTEroman)
282 * \ingroup jkqtmathtext_tools
283 */
285 MTEroman, /*!< \brief roman font, e.g. <code>\\rm{}</code> */
286 MTEsans, /*!< \brief sans-serif font, e.g. <code>\\sf{}</code> */
287 MTEmathRoman, /*!< \brief math-mode roman font, e.g. <code>\\mathrm{}</code> */
288 MTEmathSans, /*!< \brief math-mode sans-serif font, e.g. <code>\\mathsf{}</code> */
289 MTEtypewriter, /*!< \brief typewriter font, e.g. <code>\\tt{},\\mathtt{}</code> */
290 MTEscript, /*!< \brief script font, e.g. <code>\\script{},\\mathscript{}</code> */
291 MTEblackboard, /*!< \brief blackboard font, e.g. <code>\\mathbb{}</code> */
292 MTEcaligraphic, /*!< \brief caligraphic font, e.g. <code>\\mathcal{}</code> */
293 MTEfraktur, /*!< \brief fraktur font, e.g. <code>\\mathfrak{}</code> */
294 MTEFallbackSymbols, /*!< \brief symbol font */
295
296 MTECurrentFont, /*!< \brief internal enum value that specifies that the currently set font shall be used \internal */
297 MTECustomFont, /*!< \brief internal enum value that specifies that a custom font specified elsewhere shall be used \internal */
298};
299
300
301/** \brief describes the current drawing environment (base fontname ...)
302 * \ingroup jkqtmathtext_tools
303 */
305 /** \brief units for the property JKQTMathTextEnvironment::fontSize (Points/PT or Pixels) */
308 PIXELS
309 };
310 /** \brief convert a FontSizeUnit to a string \see FontSizeUnit,String2FontSizeUnit() */
311 static QString FontSizeUnit2String(FontSizeUnit unit);
312 /** \brief convert a string into a FontSizeUnit \see FontSizeUnit,FontSizeUnit2String() */
313 static FontSizeUnit String2FontSizeUnit(QString unit);
314
316 /** \brief current font color */
317 QColor color;
318 /** \brief current font */
320 /** \brief custom font, when font==MTECustomFont */
322 /** \brief current font size the unit is determined by fontSizeUnit */
323 double fontSize;
324 /** \brief the unit of the font size fontSize */
326
327 /** \brief is the text currently bold? */
328 bool bold;
329 /** \brief is the text currently italic? */
330 bool italic;
331 /** \brief is the text currently in small caps? */
332 QFont::Capitalization capitalization;
333 /** \brief is the text currently underlined? */
335 /** \brief is the text currently overlined? */
337 /** \brief is the text currently stroke through? */
338 bool strike;
339 /** \brief is the text currently are we inside a math environment? */
341 /** \brief if \a insideMath \c ==true and this is \c true (the default), then digits are forced to be typeset in upright, otherwise they are typeset as defined by the other properties */
343 /** \brief if \c true the commands like \c \\frac{}{} are executes as \c \\tfrac{}{} . This implements \c \\textstyle or if \c false \c \\displaystyle
344 *
345 * \image html jkqtmathtext/jkqtmathtext_mathstyle.png
346 */
348 /** \brief sets insideMath \c =true and insideMathForceDigitsUpright \c =true and \c insideMathUseTextStyle=!displaystyle*/
349 void beginMathMode(bool displaystyle=true);
350 /** \brief sets insideMath \c =false */
352 /** \brief determines whether to use displaystyle or textstyle for math-instructions like \c \\frace{}{} or \c \\int_x
353 *
354 * \image html jkqtmathtext/jkqtmathtext_mathstyle.png
355 */
356 bool isMathDisplayStyle() const;
357 /** \brief determines whether to use displaystyle or textstyle for math-instructions like \c \\frace{}{} or \c \\int_x
358 *
359 * \image html jkqtmathtext/jkqtmathtext_mathstyle.png
360 */
361 bool isMathTextStyle() const;
362
363
364 /** \brief build a <a href="https://doc.qt.io/qt-5/qfont.html">QFont</a> object from the settings in this object */
365 QFont getFont(const JKQTMathText *parent) const;
366 /** \brief return a copy of this object with the font exchanged for \a font */
368 /** \brief return a copy of this object with the font exchanged for the matching roman font */
370 /** \brief return the encoding of the given Font */
372 /** \brief generate a HTML prefix that formats the text after it according to the settings in this object
373 *
374 * \param defaultEv environment before applying the current object (to detect changes)
375 * \param parentMathText the JKQTMathText object currently in use (used to e.g. look up font names)
376 *
377 * \see toHtmlAfter()
378 */
379 QString toHtmlStart(JKQTMathTextEnvironment defaultEv, JKQTMathText *parentMathText) const;
380 /** \brief generate a HTML postfix that formats the text in front of it according to the settings in this object
381 *
382 * \param defaultEv environment before applying the current object (to detect changes)
383 * \param parentMathText the JKQTMathText object currently in use (used to e.g. look up font names)
384 *
385 * \see toHtmlAfter()
386 */
387 QString toHtmlAfter(JKQTMathTextEnvironment defaultEv, JKQTMathText *parentMathText) const;
388};
389
390/** \brief beschreibt die Größe(n) eines Knotens
391 * \ingroup jkqtmathtext_tools
392 */
394 JKQTMathTextNodeSize(double width=0, double baselineHeight=0, double overallHeight=0, double strikeoutPos=0, double baselineXCorrection=0,double topXCorrection=0);
395 /** \brief width of whole block */
396 double width;
397 /** \brief baselineHeight of whole block, i.e. the ascent */
399 /** \brief overallHeight of whole block */
401 /** \brief strikeoutPos of whole block, i.e. distance of the strikeout position from the baseline */
403 /** \brief x-correction (<0 = move to the left) for subscripts, i.e. approximately at the height of the baseline
404 *
405 * \image html jkqtmathtext/jkqtmathtext_doc_subsuper_italiccorrection.png
406 *
407 * \image html jkqtmathtext/jkqtmathtext_doc_subsuper_italiccorrection_boxes.png
408 */
410 /** \brief x-correction (>0 = move to the right) for superscripts, i.e. approximately at the top of the box */
412 /** \brief calculate the descent (overallHeight-baselineHeight) */
413 inline double getDescent() const { return overallHeight-baselineHeight; }
414 /** \brief calculate the ascent (=baselineHeight), for convenience and naming */
415 inline double getAscent() const { return baselineHeight; }
416 /** \brief calculate the height (=baselineHeight), for convenience and naming */
417 inline double getHeight() const { return overallHeight; }
418 /** \brief calculate the overall size in floating-point precision */
419 inline QSizeF getSize() const { return QSizeF(width, overallHeight); }
420 /** \brief calculate the overall size in floating-point precision */
421 inline QSize getIntSize() const { return QSize(qCeil(width+1.0), qCeil(overallHeight+1.0)); }
422 /** \brief helper function, which generates a copy of this object, used to suppress slicing warning due to GSL E.63: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-slice */
423 inline JKQTMathTextNodeSize sliceToNodeSize() const { return *this; }
424};
425
426/** \brief summarizes all information available on a font for a specific MTenvironmentFont
427 * \ingroup jkqtmathtext_tools
428 * \see fontDefinitions
429 */
432 /** \brief name of the font */
433 QString fontName;
434 /** \brief specifies the encoding of the font (default is \c MTFEwinSymbol ) */
436};
437
438
439/** \brief create a QPainterPath for drawing horizontal braces, use QPainter::fillPath() with a vanishing line-width to draw this
440 * \ingroup jkqtmathtext_tools
441 *
442 * \image html jkqtmathtext/JKQTMathTextMakeHBracePath.png
443 *
444 * \param x x-center-position of the brace
445 * \param ybrace y-center-position of the brace
446 * \param width with of the overall brace
447 * \param bw height of the brace
448 * \param lineWidth linewidth when drawing, used for correcting so the brace exactly fills the rectangle and not overshoots it
449 * \param cubicshrink
450 * \param cubiccontrolfac
451 * \param lineWidthShrinkFactor the width of the tips is lineWidth reduced by this factor
452 * \param lineWidthGrowFactor the width of the horizontal bars is increased by this factor from lineWidth
453 */
454JKQTMATHTEXT_LIB_EXPORT QPainterPath JKQTMathTextMakeHBracePath(double x, double ybrace, double width, double bw, double lineWidth, double cubicshrink=0.5, double cubiccontrolfac=0.3, double lineWidthShrinkFactor=0.6, double lineWidthGrowFactor=0.9);
455
456
457/** \brief create a QPainterPath for drawing horizontal arrows
458 * \ingroup jkqtmathtext_tools
459 *
460 * \image html jkqtmathtext/JKQTMathTextMakeArrow.png
461 */
462JKQTMATHTEXT_LIB_EXPORT QPainterPath JKQTMathTextMakeArrow(double x, double y, double width, double arrowW, bool left=false, bool right=true);
463
464
465/** \brief create a QPainterPath for drawing horizontal double arrows
466 * \ingroup jkqtmathtext_tools
467 *
468 * \image html jkqtmathtext/JKQTMathTextMakeDArrow.png
469 */
470JKQTMATHTEXT_LIB_EXPORT QPainterPath JKQTMathTextMakeDArrow(double x, double y, double width, double arrowW, bool left=false, bool right=true);
471
472/** \brief draw a given \a txt in the font \a f using additional informaion (but not currentEv::getFont() ) from \a currentEv at (\a x , \a y ) using the given \a painter
473 *
474 * This function implements drawing of synthesized fonts, e.g. MTEblackboard when JKQTMathText::isFontBlackboardSimulated() is \c true .
475 *
476 * example output:
477 * \image html jkqtmathtext/jkqtmathtext_bb_unicode_or_simulate.png
478 */
479JKQTMATHTEXT_LIB_EXPORT void JKQTMathTextDrawStringSimBlackboard(QPainter& painter, const QFont& f, const QColor &color, double x, double y, const QString& txt);
480
481
482
483/** \brief calculates the tight bounding rectangle around \a text
484 * (from <a href="https://doc.qt.io/qt/qfontmetricsf.html#tightBoundingRect">QFontMetricsF::tightBoundingRect()</a>),
485 * uses internal (thread-local) hashing to not redo a calculation that has already been performed
486 * \ingroup jkqtmathtext_tools
487 *
488 * \param fm font the text should be set in
489 * \param text the text of which the properties are calculated
490 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
491 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
492 *
493 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
494 */
495JKQTMATHTEXT_LIB_EXPORT QRectF JKQTMathTextGetTightBoundingRect(const QFont &fm, const QString& text, QPaintDevice *pd);
496
497/** \brief calculates the bounding rectangle around \a text
498 * (from (using <a href="https://doc.qt.io/qt/qfontmetricsf.html#boundingRect">QFontMetricsF::boundingRect()</a>),
499 * uses internal hashing to not redo a calculation that has already been performed
500 * \ingroup jkqtmathtext_tools
501 *
502 * \param fm font the text should be set in
503 * \param text the text of which the properties are calculated
504 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
505 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
506 *
507 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
508 */
509JKQTMATHTEXT_LIB_EXPORT QRectF JKQTMathTextGetBoundingRect(const QFont &fm, const QString& text, QPaintDevice *pd);
510
511/** \brief calculates the horizontal advance of \a text
512 * (from <a href="https://doc.qt.io/qt/qfontmetricsf.html#horizontalAdvance">QFontMetricsF::horizontalAdvance()</a>
513 * or \c QFontMetricsF::width() if it is not yet available in your Qt version),
514 * uses internal hashing to not redo a calculation that has already been performed
515 * \ingroup jkqtmathtext_tools
516 *
517 * \param fm font the text should be set in
518 * \param text the text of which the properties are calculated
519 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
520 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
521 *
522 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
523 */
524JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetHorAdvance(const QFont &fm, const QString& text, QPaintDevice *pd);
525
526/** \brief calculates the left bearing of \a text
527 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#leftBearing">QFontMetricsF::leftBearing()</a>),
528 * uses internal hashing to not redo a calculation that has already been performed
529 * \ingroup jkqtmathtext_tools
530 *
531 * \param fm font the text should be set in
532 * \param text the character of which the properties are calculated
533 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
534 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
535 *
536 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
537 */
538JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetLeftBearing(const QFont &fm, const QChar& text, QPaintDevice *pd);
539
540/** \brief calculates the right bearing of \a text
541 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#rightBearing">QFontMetricsF::rightBearing()</a>),
542 * uses internal hashing to not redo a calculation that has already been performed
543 * \ingroup jkqtmathtext_tools
544 *
545 * \param fm font the text should be set in
546 * \param text the character of which the properties are calculated
547 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
548 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
549 *
550 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
551 */
552JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetRightBearing(const QFont &fm, const QChar& text, QPaintDevice *pd);
553
554
555/** \brief calculates the strikeout-pos of \a font
556 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#strikeoutPos">QFontMetricsF::strikeoutPos()</a>),
557 * uses internal hashing to not redo a calculation that has already been performed
558 * \ingroup jkqtmathtext_tools
559 *
560 * \param fm font for which to calculate
561 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
562 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
563 *
564 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
565 */
566JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontStrikoutPos(const QFont &fm, QPaintDevice *pd);
567
568/** \brief calculates the line width of \a font
569 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#lineWidth">QFontMetricsF::lineWidth()</a>),
570 * uses internal hashing to not redo a calculation that has already been performed
571 * \ingroup jkqtmathtext_tools
572 *
573 * \param fm font for which to calculate
574 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
575 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
576 *
577 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
578 */
579JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontLineWidth(const QFont &fm, QPaintDevice *pd);
580
581/** \brief calculates the ascent of \a font
582 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#ascent">QFontMetricsF::ascent()</a>),
583 * uses internal hashing to not redo a calculation that has already been performed
584 * \ingroup jkqtmathtext_tools
585 *
586 * \param fm font for which to calculate
587 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
588 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
589 *
590 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
591 */
592JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontAscent(const QFont &fm, QPaintDevice *pd);
593
594/** \brief calculates the descent of \a font
595 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#descent">QFontMetricsF::descent()</a>),
596 * uses internal hashing to not redo a calculation that has already been performed
597 * \ingroup jkqtmathtext_tools
598 *
599 * \param fm font for which to calculate
600 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
601 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
602 *
603 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
604 */
605JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontDescent(const QFont &fm, QPaintDevice *pd);
606
607
608/** \brief calculates the height of \a font
609 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#height">QFontMetricsF::height()</a>),
610 * uses internal hashing to not redo a calculation that has already been performed
611 * \ingroup jkqtmathtext_tools
612 *
613 * \param fm font for which to calculate
614 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
615 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
616 *
617 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
618 */
619JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontHeight(const QFont &fm, QPaintDevice *pd);
620
621/** \brief calculates the leading of \a font
622 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#leading">QFontMetricsF::leading()</a>),
623 * uses internal hashing to not redo a calculation that has already been performed
624 * \ingroup jkqtmathtext_tools
625 *
626 * \param fm font for which to calculate
627 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
628 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
629 *
630 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
631 */
632JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontLeading(const QFont &fm, QPaintDevice *pd);
633
634/** \brief calculates the line spacing of \a font
635 * (from <a href="https://doc.qt.io/qt-6/qfontmetricsf.html#lineSpacing">QFontMetricsF::lineSpacing()</a>),
636 * uses internal hashing to not redo a calculation that has already been performed
637 * \ingroup jkqtmathtext_tools
638 *
639 * \param fm font for which to calculate
640 * \param pd (or \c nullptr) the currently used <a href="https://doc.qt.io/qt-6/qpaintdevice.html">QPaintDevice</a>
641 * (e.g. from <a href="https://doc.qt.io/qt/qpainter.html#device">QPainter::device()</a> )
642 *
643 * \note This function is thread-safe and uses the same cache for all threads (so they profit from eachother)
644 */
645JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontLineSpacing(const QFont &fm, QPaintDevice *pd);
646
647
648/** \brief returns a copy of \a f, but with the italic-property set to \c false
649 * \ingroup jkqtmathtext_tools
650 */
652
653
654/** \brief types of horizontal alignment
655 * \ingroup jkqtmathtext_tools
656 *
657 * \image html jkqtmathtext_horizontalalignment.png
658 *
659 * \see JKQTMathTextVerticalOrientation2String(), String2JKQTMathTextVerticalOrientation(), JKQTMathTextVerticalListNode
660 */
662 MTHALeft, /*!< \brief align left */
663 MTHACentered, /*!< \brief align centered */
664 MTHARight, /*!< \brief align right */
665};
666/** \brief convert a JKQTMathTextHorizontalAlignment into a string
667 * \ingroup jkqtmathtext_tools
668 */
670/** \brief convert a string \a tokenName into a JKQTMathTextHorizontalAlignment
671 * \ingroup jkqtmathtext_tools
672 */
674
675/** \brief type of ffractions represented by JKQTMathTextFracNode
676 * \ingroup jkqtmathtext_tools
677 *
678 * \image html jkqtmathtext_verticalorientation.png
679 *
680 * \see JKQTMathTextVerticalOrientation2String(), String2JKQTMathTextVerticalOrientation(), JKQTMathTextVerticalListNode, JKQTMathTextVerbatimNode
681 */
683 MTVOTop, /*!< \brief baseline of the whole block is at the top of the first */
684 MTVOFirstLine, /*!< \brief baseline of the whole block is at the baseline of the first line */
685 MTVOCentered, /*!< \brief baseline of the whole block is at the center of all lines */
686 MTVOLastLine, /*!< \brief baseline of the whole block is at the baseline of the last line */
687 MTVOBottom, /*!< \brief baseline of the whole block is at the bottom of the last line */
688};
689
690/** \brief convert a JKQTMathTextVerticalOrientation into a QString
691 * \ingroup jkqtmathtext_tools
692 *
693 * \see JKQTMathTextVerticalOrientation2String(), String2JKQTMathTextVerticalOrientation(), JKQTMathTextVerticalListNode, JKQTMathTextVerbatimNode
694 */
696
697/** \brief returns the JKQTMathTextVerticalOrientation corresponding to \a instructionName
698 * \ingroup jkqtmathtext_tools
699 *
700 * \see JKQTMathTextVerticalOrientation2String(), String2JKQTMathTextVerticalOrientation(), JKQTMathTextVerticalListNode, JKQTMathTextVerbatimNode
701 */
703
704
705/** \brief defines, how lines are beeing spaced by the node
706 * \ingroup jkqtmathtext_tool
707 *
708 * \image html jkqtmathtext_verticallist.png
709 *
710 * \see JKQTMathTextLineSpacingMode2String(), String2JKQTMathTextLineSpacingMode(), JKQTMathTextVerticalListNode
711 */
712enum JKQTMathTextLineSpacingMode {
713 MTSMDefaultSpacing, /*!< space the lines with equilibrated spacing, i.e. the baselines are at least \c QFontMetricsF::lineSpacing()*JKQTMathTextVerticalListNode::lineSpacingFactor apart, but even more, if the height of the text bloxk is larger than the the font's ascent+descent */
714 MTSMMinimalSpacing /*!< space the lines as tight as possible, i.e. each line is separated by \c QFontMetricsF::leading()*JKQTMathTextVerticalListNode::lineSpacingFactor from the next line. This is a s compact as possible */
715};
716/** \brief convert a SpacingMode to a String
717 * \ingroup jkqtmathtext_tools
718 *
719 * \see JKQTMathTextLineSpacingMode2String(), String2JKQTMathTextLineSpacingMode(), JKQTMathTextVerticalListNode
720 */
721JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextLineSpacingMode2String(JKQTMathTextLineSpacingMode mode);
722/** \brief convert a String to a SpacingMode
723 * \ingroup jkqtmathtext_tools
724 *
725 * \see JKQTMathTextLineSpacingMode2String(), String2JKQTMathTextLineSpacingMode(), JKQTMathTextVerticalListNode
726 */
727JKQTMATHTEXT_LIB_EXPORT JKQTMathTextLineSpacingMode String2JKQTMathTextLineSpacingMode(QString mode);
728
729#endif // JKQTMATHTEXTTOOLS_H
730
731
732
733
734
735
736
737
738
this class parses a mathematical markup string and can then draw the contained text/equation onto a Q...
Definition jkqtmathtext.h:192
#define JKQTMATHTEXT_LIB_EXPORT
Definition jkqtmathtext_imexport.h:108
JKQTMathTextVerticalOrientation
type of ffractions represented by JKQTMathTextFracNode
Definition jkqtmathtexttools.h:682
JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBlackboradDrawingMode String2JKQTMathTextBlackboradDrawingMode(QString mode)
this converts a QString into a JKQTMathTextBlackboradDrawingMode
JKQTMATHTEXT_LIB_EXPORT QPainterPath JKQTMathTextMakeHBracePath(double x, double ybrace, double width, double bw, double lineWidth, double cubicshrink=0.5, double cubiccontrolfac=0.3, double lineWidthShrinkFactor=0.6, double lineWidthGrowFactor=0.9)
create a QPainterPath for drawing horizontal braces, use QPainter::fillPath() with a vanishing line-w...
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetRightBearing(const QFont &fm, const QChar &text, QPaintDevice *pd)
calculates the right bearing of text (from QFontMetricsF::rightBearing()), uses internal hashing to n...
JKQTMATHTEXT_LIB_EXPORT bool isPrintableJKQTMathTextBraceType(JKQTMathTextBraceType type)
return true if type represents a printable type of brace (including MTBTNone), basically true for any...
JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextLineSpacingMode2String(JKQTMathTextLineSpacingMode mode)
convert a SpacingMode to a String
JKQTMATHTEXT_LIB_EXPORT QPainterPath JKQTMathTextMakeDArrow(double x, double y, double width, double arrowW, bool left=false, bool right=true)
create a QPainterPath for drawing horizontal double arrows
JKQTMATHTEXT_LIB_EXPORT QFont JKQTMathTextGetNonItalic(const QFont &f)
returns a copy of f, but with the italic-property set to false
JKQTMathTextHorizontalAlignment
types of horizontal alignment
Definition jkqtmathtexttools.h:661
JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextBraceType2String(JKQTMathTextBraceType type)
convert a JKQTMathTextBraceType into a string
JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceType InstructionName2JKQTMathTextBraceType(const QString &tokenName)
convert a string tokenName describing a LaTeX Instruction into an opening or closing JKQTMathTextBrac...
JKQTMATHTEXT_LIB_EXPORT QRectF JKQTMathTextGetTightBoundingRect(const QFont &fm, const QString &text, QPaintDevice *pd)
calculates the tight bounding rectangle around text (from QFontMetricsF::tightBoundingRect()),...
JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextHorizontalAlignment2String(JKQTMathTextHorizontalAlignment type)
convert a JKQTMathTextHorizontalAlignment into a string
JKQTMathTextEnvironmentFont
the available logical fonts (default is MTEroman)
Definition jkqtmathtexttools.h:284
JKQTMATHTEXT_LIB_EXPORT QRectF JKQTMathTextGetBoundingRect(const QFont &fm, const QString &text, QPaintDevice *pd)
calculates the bounding rectangle around text (from (using QFontMetricsF::boundingRect()),...
JKQTMathTextBraceType
types of available braces
Definition jkqtmathtexttools.h:222
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetHorAdvance(const QFont &fm, const QString &text, QPaintDevice *pd)
calculates the horizontal advance of text (from QFontMetricsF::horizontalAdvance() or QFontMetricsF::...
JKQTMATHTEXT_LIB_EXPORT JKQTMathTextHorizontalAlignment String2JKQTMathTextHorizontalAlignment(QString tokenName)
convert a string tokenName into a JKQTMathTextHorizontalAlignment
JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextBlackboradDrawingMode2String(JKQTMathTextBlackboradDrawingMode mode)
this converts a JKQTMathTextBlackboradDrawingMode into a string
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetLeftBearing(const QFont &fm, const QChar &text, QPaintDevice *pd)
calculates the left bearing of text (from QFontMetricsF::leftBearing()), uses internal hashing to not...
JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceType TokenName2JKQTMathTextBraceType(const QString &tokenName, bool *isOpening=nullptr)
convert a string tokenName describing a LaTeX Token or Instruction into an opening or closing JKQTMat...
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontAscent(const QFont &fm, QPaintDevice *pd)
calculates the ascent of font (from QFontMetricsF::ascent()), uses internal hashing to not redo a cal...
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontLeading(const QFont &fm, QPaintDevice *pd)
calculates the leading of font (from QFontMetricsF::leading()), uses internal hashing to not redo a c...
JKQTMathTextBlackboradDrawingMode
used to specify how blackboard-fonts are drawn
Definition jkqtmathtexttools.h:193
JKQTMATHTEXT_LIB_EXPORT QPainterPath JKQTMathTextMakeArrow(double x, double y, double width, double arrowW, bool left=false, bool right=true)
create a QPainterPath for drawing horizontal arrows
JKQTMATHTEXT_LIB_EXPORT JKQTMathTextLineSpacingMode String2JKQTMathTextLineSpacingMode(QString mode)
convert a String to a SpacingMode
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontStrikoutPos(const QFont &fm, QPaintDevice *pd)
calculates the strikeout-pos of font (from QFontMetricsF::strikeoutPos()), uses internal hashing to n...
JKQTMATHTEXT_LIB_EXPORT bool TokenNameMatchesJKQTMathTextBraceType(const QString &token, JKQTMathTextBraceType type, bool acceptMTBTNone, bool *tokenEqualsNone=nullptr)
returns true, if the given token/instruction-Name token ("{", "(", ..., "lceil", "....
JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextVerticalOrientation2String(JKQTMathTextVerticalOrientation mode)
convert a JKQTMathTextVerticalOrientation into a QString
JKQTMATHTEXT_LIB_EXPORT void initJKQTMathTextResources()
initialized Qt-ressources necessary for JKQTMathText
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontDescent(const QFont &fm, QPaintDevice *pd)
calculates the descent of font (from QFontMetricsF::descent()), uses internal hashing to not redo a c...
JKQTMATHTEXT_LIB_EXPORT QString JKQTMathTextFontEncoding2String(JKQTMathTextFontEncoding e)
convert MTfontEncoding to a string
JKQTMATHTEXT_LIB_EXPORT bool InstructionNameMatchesJKQTMathTextBraceType(const QString &token, JKQTMathTextBraceType type, bool acceptMTBTNone, bool *tokenEqualsNone=nullptr)
returns true, if the given instruction-Name token ("|", "{", ..., "lceil", ".", .....
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontLineSpacing(const QFont &fm, QPaintDevice *pd)
calculates the line spacing of font (from QFontMetricsF::lineSpacing()), uses internal hashing to not...
JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBraceType InstructionName2OpeningJKQTMathTextBraceType(const QString &tokenName)
convert a string tokenName describing a LaTeX Instruction into an opening JKQTMathTextBraceType
JKQTMATHTEXT_LIB_EXPORT JKQTMathTextVerticalOrientation String2JKQTMathTextVerticalOrientation(QString mode)
returns the JKQTMathTextVerticalOrientation corresponding to instructionName
JKQTMathTextFontEncoding
used to specify the font encoding used for drawing
Definition jkqtmathtexttools.h:175
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontLineWidth(const QFont &fm, QPaintDevice *pd)
calculates the line width of font (from QFontMetricsF::lineWidth()), uses internal hashing to not red...
JKQTMATHTEXT_LIB_EXPORT qreal JKQTMathTextGetFontHeight(const QFont &fm, QPaintDevice *pd)
calculates the height of font (from QFontMetricsF::height()), uses internal hashing to not redo a cal...
JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFontEncoding estimateJKQTMathTextFontEncoding(QFont font)
this function tries to determine the JKQTMathTextFontEncoding of a given font (HEURISTICS!...
@ MTVOCentered
baseline of the whole block is at the center of all lines
Definition jkqtmathtexttools.h:685
@ MTVOLastLine
baseline of the whole block is at the baseline of the last line
Definition jkqtmathtexttools.h:686
@ MTVOBottom
baseline of the whole block is at the bottom of the last line
Definition jkqtmathtexttools.h:687
@ MTVOTop
baseline of the whole block is at the top of the first
Definition jkqtmathtexttools.h:683
@ MTVOFirstLine
baseline of the whole block is at the baseline of the first line
Definition jkqtmathtexttools.h:684
@ MTHALeft
align left
Definition jkqtmathtexttools.h:662
@ MTHACentered
align centered
Definition jkqtmathtexttools.h:663
@ MTHARight
align right
Definition jkqtmathtexttools.h:664
@ MTEmathSans
math-mode sans-serif font, e.g. \mathsf{}
Definition jkqtmathtexttools.h:288
@ MTECustomFont
internal enum value that specifies that a custom font specified elsewhere shall be used
Definition jkqtmathtexttools.h:297
@ MTEscript
script font, e.g. \script{},\mathscript{}
Definition jkqtmathtexttools.h:290
@ MTEfraktur
fraktur font, e.g. \mathfrak{}
Definition jkqtmathtexttools.h:293
@ MTEsans
sans-serif font, e.g. \sf{}
Definition jkqtmathtexttools.h:286
@ MTEroman
roman font, e.g. \rm{}
Definition jkqtmathtexttools.h:285
@ MTEFallbackSymbols
symbol font
Definition jkqtmathtexttools.h:294
@ MTEtypewriter
typewriter font, e.g. \tt{},\mathtt{}
Definition jkqtmathtexttools.h:289
@ MTEblackboard
blackboard font, e.g. \mathbb{}
Definition jkqtmathtexttools.h:291
@ MTEcaligraphic
caligraphic font, e.g. \mathcal{}
Definition jkqtmathtexttools.h:292
@ MTEmathRoman
math-mode roman font, e.g. \mathrm{}
Definition jkqtmathtexttools.h:287
@ MTECurrentFont
internal enum value that specifies that the currently set font shall be used
Definition jkqtmathtexttools.h:296
@ MTBTAny
any bracket, used by JKQTMathText::parseLatexString()
Definition jkqtmathtexttools.h:234
@ MTBTNone
no bracket
Definition jkqtmathtexttools.h:233
@ MTBTFloorBracket
floor brackets
Definition jkqtmathtexttools.h:228
@ MTBTSquareBracket
brackets []
Definition jkqtmathtexttools.h:224
@ MTBTUnknown
an unknown tokenName presented to TokenName2JKQTMathTextBraceType()
Definition jkqtmathtexttools.h:235
@ MTBTDoubleLine
double-line brackets (norm ||...||)
Definition jkqtmathtexttools.h:229
@ MTBTAngleBracket
angle backets <>
Definition jkqtmathtexttools.h:226
@ MTBTCeilBracket
ceil brackets
Definition jkqtmathtexttools.h:227
@ MTBTSingleLine
single-line brackets (abs |...|)
Definition jkqtmathtexttools.h:230
@ MTBTBottomCorner
bottom-corner brackets
Definition jkqtmathtexttools.h:232
@ MTBTCurlyBracket
curly braces {}
Definition jkqtmathtexttools.h:225
@ MTBTParenthesis
parantheses ()
Definition jkqtmathtexttools.h:223
@ MTBTTopCorner
top-corner brackets
Definition jkqtmathtexttools.h:231
@ MTBBDMsimulate
simulate a blackboard font (i.e. draw the characters' outline only), based on the font specified by J...
Definition jkqtmathtexttools.h:195
@ MTBBDMunicodeCharactersOrSimulate
use the currently set font and look for special unicode-characters in it, uses the fallbackSymbolFont...
Definition jkqtmathtexttools.h:197
@ MTBBDMfontDirectly
draw using the font specified by JKQTMathText::setFontBlackboard()
Definition jkqtmathtexttools.h:194
@ MTBBDMunicodeCharactersOrFontDirectly
use the currently set font and look for special unicode-characters in it, uses the fallbackSymbolFont...
Definition jkqtmathtexttools.h:196
@ MTBBDMdefault
default drawing mode, same as MTBBDMunicodeCharactersOrFontDirectly
Definition jkqtmathtexttools.h:198
@ MTFELatin1
the encoding of a standard Latin1 TTF font (i.e. we can only expect letters,number and not many speci...
Definition jkqtmathtexttools.h:178
@ MTFEStandard
Definition jkqtmathtexttools.h:179
@ MTFEUnicode
This assumes that symbols shall be taken from a Unicode font, which ideally offers full symbol suppor...
Definition jkqtmathtexttools.h:177
@ MTFEWinSymbol
This assumes that symbols shall be taken from a MS Windows style Symbol font.
Definition jkqtmathtexttools.h:176
describes the current drawing environment (base fontname ...)
Definition jkqtmathtexttools.h:304
QColor color
current font color
Definition jkqtmathtexttools.h:317
bool insideMathUseTextStyle
if true the commands like \frac{}{} are executes as \tfrac{}{} . This implements \textstyle or if fal...
Definition jkqtmathtexttools.h:347
FontSizeUnit
units for the property JKQTMathTextEnvironment::fontSize (Points/PT or Pixels)
Definition jkqtmathtexttools.h:306
@ POINTS
Definition jkqtmathtexttools.h:307
static FontSizeUnit String2FontSizeUnit(QString unit)
convert a string into a FontSizeUnit
bool italic
is the text currently italic?
Definition jkqtmathtexttools.h:330
bool overline
is the text currently overlined?
Definition jkqtmathtexttools.h:336
bool bold
is the text currently bold?
Definition jkqtmathtexttools.h:328
bool insideMathForceDigitsUpright
if insideMath ==true and this is true (the default), then digits are forced to be typeset in upright,...
Definition jkqtmathtexttools.h:342
bool isMathTextStyle() const
determines whether to use displaystyle or textstyle for math-instructions like \frace{}{} or \int_x
JKQTMathTextFontEncoding getFontEncoding(JKQTMathText *parent) const
return the encoding of the given Font
QString toHtmlStart(JKQTMathTextEnvironment defaultEv, JKQTMathText *parentMathText) const
generate a HTML prefix that formats the text after it according to the settings in this object
bool underlined
is the text currently underlined?
Definition jkqtmathtexttools.h:334
QString toHtmlAfter(JKQTMathTextEnvironment defaultEv, JKQTMathText *parentMathText) const
generate a HTML postfix that formats the text in front of it according to the settings in this object
QFont::Capitalization capitalization
is the text currently in small caps?
Definition jkqtmathtexttools.h:332
bool strike
is the text currently stroke through?
Definition jkqtmathtexttools.h:338
void endMathMode()
sets insideMath =false
void beginMathMode(bool displaystyle=true)
sets insideMath =true and insideMathForceDigitsUpright =true and insideMathUseTextStyle=!...
JKQTMathTextEnvironment exchangedFontFor(JKQTMathTextEnvironmentFont font) const
return a copy of this object with the font exchanged for font
QFont getFont(const JKQTMathText *parent) const
build a QFont object from the settings in this object
JKQTMathTextEnvironmentFont font
current font
Definition jkqtmathtexttools.h:319
static QString FontSizeUnit2String(FontSizeUnit unit)
convert a FontSizeUnit to a string
bool isMathDisplayStyle() const
determines whether to use displaystyle or textstyle for math-instructions like \frace{}{} or \int_x
bool insideMath
is the text currently are we inside a math environment?
Definition jkqtmathtexttools.h:340
QString customFontName
custom font, when font==MTECustomFont
Definition jkqtmathtexttools.h:321
FontSizeUnit fontSizeUnit
the unit of the font size fontSize
Definition jkqtmathtexttools.h:325
double fontSize
current font size the unit is determined by fontSizeUnit
Definition jkqtmathtexttools.h:323
JKQTMathTextEnvironment exchangedFontForRoman() const
return a copy of this object with the font exchanged for the matching roman font
summarizes all information available on a font for a specific MTenvironmentFont
Definition jkqtmathtexttools.h:430
JKQTMathTextFontEncoding fontEncoding
specifies the encoding of the font (default is MTFEwinSymbol )
Definition jkqtmathtexttools.h:435
QString fontName
name of the font
Definition jkqtmathtexttools.h:433
represents a font specifier for JKQTMathText. The font consists of two parts: the actual font and the...
Definition jkqtmathtexttools.h:96
QString fontName() const
specifies the main font name
QString fallbackSymbolsFontName() const
specifies a font to be used for fallbackSymbols
static JKQTMathTextFontSpecifier fromFontSpec(const QString &fontSpec)
construct a JKQTMathTextFontSpecifier, by parsing a fontSpec string as defined in the struct descript...
static JKQTMathTextFontSpecifier getFIRAFamilies()
initialize with the font-families from the Fira (Math) package for text and math
QString m_fontName
specifies the main font name
Definition jkqtmathtexttools.h:160
bool hasFallbackSymbolFontName() const
leiefert true, wenn ein fallbcakSymbolsFontName() verfügbar ist
static JKQTMathTextFontSpecifier getXITSFamilies()
initialize with the font-families from the XITS package for text and math
void setFontName(const QString &name)
specifies the main font name
void setFallbackSymbolsFontName(const QString &name)
specifies a font to be used for fallbackSymbols
static JKQTMathTextFontSpecifier getASANAFamilies()
initialize with the font-families from the XITS package for text and math
QString getFontSpec() const
returns the object's constents as a fontSpec string with the form "FONT_NAME[+MATH_FONT_NAME]".
QString m_mathFontName
specifies the math font to use in addition to fontName
Definition jkqtmathtexttools.h:162
JKQTMathTextFontSpecifier(const QString &fontName, const QString &mathFontName)
static JKQTMathTextFontSpecifier getAppFontSFFamilies()
initialize with the default app font-families for "sans-serif" text and math and tries to find a matc...
bool hasFontName() const
leiefert true, wenn ein fontName() verfügbar ist
static QString transformFontName(const QString &fontName, bool mathmode=false)
finds actual fonts for some predefined special font names, as listed in Special Font Names
static JKQTMathTextFontSpecifier getSTIXFamilies()
initialize with the font-families from the STIX package for text and math
bool m_transformOnOutput
if set true the fonts are transformed when fontname() or mathFontName() is called by calling transfor...
Definition jkqtmathtexttools.h:166
static JKQTMathTextFontSpecifier getAppFontFamilies()
initialize with the default app font-families for "roman" text and math and tries to find a matching ...
QString m_fallbackSymbolFont
specifies a font to be used for fallbackSymbols
Definition jkqtmathtexttools.h:164
bool hasMathFontName() const
leiefert true, wenn ein mathFontName() verfügbar ist
void setmathFontName(const QString &name)
specifies the math font to use in addition to fontName
void setFontSpec(const QString &fontSpec)
initialises the object with values from parsing a fontSpec string as defined in the struct descriptio...
QString mathFontName() const
specifies the math font to use in addition to fontName
static QString transformFontNameAndDecodeSpecialFonts(const QString &fontName, bool mathmode=false)
same as transformFontName(), but also finds the actual name for XITS, STIX, ASANA,...
beschreibt die Größe(n) eines Knotens
Definition jkqtmathtexttools.h:393
double baselineXCorrection
x-correction (<0 = move to the left) for subscripts, i.e. approximately at the height of the baseline
Definition jkqtmathtexttools.h:409
double getHeight() const
calculate the height (=baselineHeight), for convenience and naming
Definition jkqtmathtexttools.h:417
QSizeF getSize() const
calculate the overall size in floating-point precision
Definition jkqtmathtexttools.h:419
QSize getIntSize() const
calculate the overall size in floating-point precision
Definition jkqtmathtexttools.h:421
double topXCorrection
x-correction (>0 = move to the right) for superscripts, i.e. approximately at the top of the box
Definition jkqtmathtexttools.h:411
double getDescent() const
calculate the descent (overallHeight-baselineHeight)
Definition jkqtmathtexttools.h:413
double overallHeight
overallHeight of whole block
Definition jkqtmathtexttools.h:400
double strikeoutPos
strikeoutPos of whole block, i.e. distance of the strikeout position from the baseline
Definition jkqtmathtexttools.h:402
JKQTMathTextNodeSize(double width=0, double baselineHeight=0, double overallHeight=0, double strikeoutPos=0, double baselineXCorrection=0, double topXCorrection=0)
double width
width of whole block
Definition jkqtmathtexttools.h:396
double baselineHeight
baselineHeight of whole block, i.e. the ascent
Definition jkqtmathtexttools.h:398
double getAscent() const
calculate the ascent (=baselineHeight), for convenience and naming
Definition jkqtmathtexttools.h:415
JKQTMathTextNodeSize sliceToNodeSize() const
helper function, which generates a copy of this object, used to suppress slicing warning due to GSL E...
Definition jkqtmathtexttools.h:423