fixed: JKQTMathText added a little whitespace before and after the LaTeX-string. This was removed as it disturbed the layout of text in plots

This commit is contained in:
jkriege2 2022-06-02 23:24:41 +02:00
parent f33838f187
commit 285814f2e6
4 changed files with 8 additions and 5 deletions

View File

@ -17,6 +17,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
<li>fixed issue described in <a href="https://github.com/jkriege2/JKQtPlotter/pull/62">#62: Fix custom labels draw, because giving exactly two label-strings did not display all of them</a>, thanks to <a href="https://github.com/FalsinSoft">user:FalsinSoft</a></li>
<li>fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/70">#70: Typo in jkqtplotter/CMakeLists.txt</a>, thanks to <a href="https://github.com/tedlinlab">user:tedlinlab</a></li>
<li>fixed: styling was not properly applied to coordinate axes of colorbars outside the plot</li>
<li>fixed: JKQTMathText added a little whitespace before and after the LaTeX-string. This was removed as it disturbed the layout of text in plots</li>
<li>improved: high-dpr-support in JKQTMathText</li>
<li>improved: QT6-compatibility by removing deprecated warnings</li>
<li>NEW: JKQTPFilledCurveXGraph and JKQTPFilledCurveYGraph can now plot wiggle plots with different fill styles above and below the baseline (feature request <a href="https://github.com/jkriege2/JKQtPlotter/issues/68">#68 Wiggle Plots</a> from <a href="https://github.com/xichaoqiang">user:xichaoqiang</a> </li>

View File

@ -4538,8 +4538,10 @@ QRectF JKQTMathText::getTightBoundingRect(const QFont &fm, const QString &text,
bool JKQTMathText::parse(QString text){
QString ntext=QString("\\;")+text+QString("\\;");
bool JKQTMathText::parse(const QString& text, bool addSpaceBeforeAndAfter){
QString ntext;
if (addSpaceBeforeAndAfter) ntext=QString("\\;")+text+QString("\\;");
else ntext=text;
ntext=ntext.remove("\\limits");
if (parsedNode && parseString==ntext) return true;

View File

@ -303,8 +303,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
void loadSettings(const QSettings& settings, const QString& group=QString("mathtext/"));
/** \brief store the object settings to the given QSettings object with the given name prefix */
void saveSettings(QSettings& settings, const QString& group=QString("mathtext/")) const;
/** \brief parse the given enhanced string. Returns \c true on success. */
bool parse(QString text);
/** \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);
/** \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 */

View File

@ -129,7 +129,7 @@ void JKQTPGeoText::draw(JKQTPEnhancedPainter& painter) {
parent->getMathText()->setFontRomanOrSpecial(getTextFontName());
parent->getMathText()->setFontSize(getTextFontSize()*parent->getFontSizeMultiplier());
parent->getMathText()->setFontColor(getTextColor());
parent->getMathText()->parse(text);
parent->getMathText()->parse("\\;"+text);
parent->getMathText()->draw(painter, transformX(x), transformY(y), parent->getCurrentPlotterStyle().debugShowTextBoxes);
}