JKQTMathText: added \c \\dashuline{X}, \c \\dotuline{X}, \c \\underleftarrow{X}, \c \\underrightarrow{X}, \c \\underleftrightarrow{X}, \c \\overleftarrow{X}, \c \\overrightarrow{X}, \c \\overleftrightarrow{X}

JKQTMathText: corrected linewidths for decorations
This commit is contained in:
jkriege2 2022-08-11 14:17:04 +02:00
parent 62e3b47d08
commit 331a67c5a8
33 changed files with 133 additions and 21 deletions

View File

@ -42,8 +42,10 @@
.
- \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 \\ul{...} , \c \\underline{...} , \c \\uline{...} \c \\underlined{...} : draw the text with underlining \image html jkqtmathtext/jkqtmathtext_ul.png
- \c \\uul{...} : draw the text with double-underlining \image html jkqtmathtext/jkqtmathtext_uul.png
- \c \\dashuline{...} : draw the text with dashed underlining \image html jkqtmathtext/jkqtmathtext_dashuline.png
- \c \\dotuline{...} : draw the text with dotted underlining \image html jkqtmathtext/jkqtmathtext_dotuline.png
- \c \\ol{...} \c \\overline{...} \c \\overlined{...} : draw the text with overlining \image html jkqtmathtext/jkqtmathtext_ol.png
- \c \\ool{...} : draw the text with double-overlining \image html jkqtmathtext/jkqtmathtext_ool.png
- \c \\tt{...} \c \\texttt{...} \c \\mathtt{...} : draw text in typewriter font \image html jkqtmathtext/jkqtmathtext_fonts.png

View File

@ -72,6 +72,8 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
<li>NEW: added \c \\snugshade{...} </li>
<li>NEW: added \c \\snugbox{...} </li>
<li>NEW: added \c \\acute{X}, \c \\grave{X}, \c \\acute{X}</li>
<li>NEW: added \c \\dashuline{X}, \c \\dotuline{X}</li>
<li>NEW: added \c \\underleftarrow{X}, \c \\underrightarrow{X}, \c \\underleftrightarrow{X}, \c \\overleftarrow{X}, \c \\overrightarrow{X}, \c \\overleftrightarrow{X}</li>
<li>NEW: added functions to set the font-size in pixels (as alternative to the existing functions that set them in points), implements request <a href="https://github.com/jkriege2/JKQtPlotter/issues/76">#76</a> from <a href="https://github.com/igormironchik">user:igormironchik</a> </li>
<li>NEW: added \c \\userfont{SystemFontName}{Text} instruction</li>
<li>NEW: added \c \\unicode{HEX} and \c \\utfeight{HEX} instruction to draw unicide characters by code</li>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -56,6 +56,30 @@ $\widehat{x}\widehat{i}\widehat{X}\widehat{\psi}\widehat{abc}$
MTDwidetilde.png
$\widetilde{x}\widetilde{i}\widetilde{X}\widetilde{\psi}\widetilde{abc}$
---
MTDoverleftarrow.png
$\overleftarrow{x}\overleftarrow{i}\overleftarrow{X}\overleftarrow{\psi}\overleftarrow{abc}$
---
MTDoverrightarrow.png
$\overrightarrow{x}\overrightarrow{i}\overrightarrow{X}\overrightarrow{\psi}\overrightarrow{abc}$
---
MTDoverleftrightarrow.png
$\overleftrightarrow{x}\overleftrightarrow{i}\overleftrightarrow{X}\overleftrightarrow{\psi}\overleftrightarrow{abc}$
---
MTDunderleftarrow.png
$\underleftarrow{x}\underleftarrow{i}\underleftarrow{X}\underleftarrow{\psi}\underleftarrow{abc}$
---
MTDunderrightarrow.png
$\underrightarrow{x}\underrightarrow{i}\underrightarrow{X}\underrightarrow{\psi}\underrightarrow{abc}$
---
MTDunderleftrightarrow.png
$\underleftrightarrow{x}\underleftrightarrow{i}\underleftrightarrow{X}\underleftrightarrow{\psi}\underleftrightarrow{abc}$
---
MTDunderlineDashed.png
\dashuline{dashed underlined}, math: $\dashuline{abc}$
---
MTDunderlineDotted.png
\dotuline{dotted underlined}, math: $\dotuline{abc}$
---
jkqtmathtext_mathdeco.png
$\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}\ ...$
---
@ -83,4 +107,8 @@ jkqtmathtext_mathaccents.png
{\backslash}uul\{A\}: & $\uul{A}\uul{a}$ & {\backslash}ool\{A\}: & $\ool{A}\ool{a}$ \\
{\backslash}ocirc\{A\}: & $\ocirc{A}\ocirc{a}$ & {\backslash}breve\{A\}: & $\breve{A}\breve{a}$ \\
{\backslash}arrow\{A\}: & $\arrow{A}\arrow{a} & & \\
{\backslash}overleftarrow\{A\}: & $\overleftarrow{A}\overleftarrow{a} & {\backslash}overrightarrow\{A\}: & $\overrightarrow{A}\overrightarrow{a} \\
{\backslash}overleftrightarrow\{A\}: & $\overleftrightarrow{A}\overleftrightarrow{a} & &\\
{\backslash}underleftarrow\{A\}: & $\underleftarrow{A}\underleftarrow{a} & {\backslash}underrightarrow\{A\}: & $\underrightarrow{A}\underrightarrow{a} \\
{\backslash}underleftrightarrow\{A\}: & $\underleftrightarrow{A}\underleftrightarrow{a} & &\\
\end{array}

View File

@ -43,6 +43,12 @@ jkqtmathtext_bb_unicode_or_simulate.png
jkqtmathtext_ol.png
{\backslash}ol: \ol{overlined text}
---
jkqtmathtext_dashuline.png
{\backslash}dashuline: \dashuline{underlined text}
---
jkqtmathtext_dotuline.png
{\backslash}dotuline: \dotuline{underlined text}
---
jkqtmathtext_ool.png
{\backslash}ool: \ool{double-overlined text}
---

View File

@ -86,6 +86,22 @@ QString JKQTMathTextDecoratedNode::DecorationType2String(JKQTMathTextDecoratedNo
return "xcancel";
case MTDstrike:
return "strike";
case MTDoverleftarrow:
return "overleftarrow";
case MTDoverrightarrow:
return "overrightarrow";
case MTDoverleftrightarrow:
return "overleftrightarrow";
case MTDunderleftarrow:
return "underleftarrow";
case MTDunderrightarrow:
return "underrightarrow";
case MTDunderleftrightarrow:
return "underleftrightarrow";
case MTDunderlineDashed:
return "underlineDashed";
case MTDunderlineDotted:
return "MTDunderlineDotted";
}
return "unknown";
}
@ -135,10 +151,12 @@ void JKQTMathTextDecoratedNode::getSizeInternal(QPainter& painter, JKQTMathTextE
double ascent=cbaselineHeight;
if (decoration==MTDbar) {
ascent=std::max<double>(baselineHeight+decoSeparation, decoAboveAscent_ypos)+linewidth/2.0;
} else if (decoration==MTDunderline) {
} else if (decoration==MTDunderline || decoration==MTDunderlineDashed || decoration==MTDunderlineDotted) {
descent=std::max<double>(decobelow_ypos, cDescent)+linewidth/2.0;
} else if (decoration==MTDdoubleunderline) {
descent=std::max<double>(decobelow_ypos, cDescent)+2.5*linewidth;
descent=std::max<double>(decobelow_ypos, cDescent)+3.5*linewidth;
} else if (decoration==MTDunderleftarrow || decoration==MTDunderrightarrow || decoration==MTDunderleftrightarrow) {
descent=std::max<double>(decobelow_ypos, cDescent)+0.5*linewidth+deco_height;
} else {
ascent=deco_ypos+deco_height;
}
@ -161,6 +179,8 @@ void JKQTMathTextDecoratedNode::fillInstructions()
instructions["underline"]=MTDunderline;
instructions["uline"]=MTDunderline;
instructions["ul"]=MTDunderline;
instructions["dashuline"]=MTDunderlineDashed;
instructions["dotuline"]=MTDunderlineDotted;
instructions["uuline"]=MTDdoubleunderline;
instructions["uul"]=MTDdoubleunderline;
instructions["ooline"]=MTDdoubleoverline;
@ -195,6 +215,13 @@ void JKQTMathTextDecoratedNode::fillInstructions()
instructions["strike"]=MTDstrike;
instructions["st"]=MTDstrike;
instructions["sout"]=MTDstrike;
instructions["overleftarrow"]=MTDoverleftarrow;
instructions["overrightarrow"]=MTDoverrightarrow;
instructions["overleftrightarrow"]=MTDoverleftrightarrow;
instructions["underleftarrow"]=MTDunderleftarrow;
instructions["underrightarrow"]=MTDunderrightarrow;
instructions["underleftrightarrow"]=MTDunderleftrightarrow;
}
double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv, const JKQTMathTextNodeSize* /*prevNodeSize*/) {
@ -210,6 +237,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
const double width_dot=fm.boundingRect(".").width()/2.0;
const double decoSeparation=parentMathText->getDecorationSeparationFactor()*fm.ascent();
const double linewidth=qMax(parentMathText->ABS_MIN_LINEWIDTH, fm.lineWidth());
const double linewidthArrow=linewidth*0.65;
const double deco_height=parentMathText->getDecorationHeightFactor()*fm.ascent();
const double decoAboveAscent_ypos=y-fm.ascent()-decoSeparation;
const double strike_ypos=y-cbaselineHeight/2.0;
@ -236,10 +264,16 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
QPen pold=painter.pen();
QPen p=pold;
p.setColor(ev.color);
p.setWidthF(linewidth*0.75);
p.setCapStyle(Qt::RoundCap);
p.setWidthF(linewidthArrow);
p.setCapStyle(Qt::SquareCap);
p.setJoinStyle(Qt::RoundJoin);
QPen pul=p;
pul.setWidthF(linewidth);
pul.setCapStyle(Qt::SquareCap);
double xnew=getChild()->draw(painter, x, y, ev);
auto fDrawFontAccent=[&](QChar aDirect=QChar(), QChar aFallback=QChar()) -> bool {
@ -289,32 +323,34 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
painter.drawPolyline(poly);
painter.setPen(pold);
} else if (decoration==MTDoverline) {
painter.setPen(p);
painter.setPen(pul);
const QLineF l(decotop_xstart, deco_ytopbot, decotop_xend, deco_ytopbot);
if (l.length()>0) painter.drawLine(l);
painter.setPen(pold);
} else if (decoration==MTDbar) {
painter.setPen(p);
painter.setPen(pul);
const QLineF l(decotop_xstart, decoAboveAscent_ypos, decotop_xend, decoAboveAscent_ypos);
if (l.length()>0) painter.drawLine(l);
painter.setPen(pold);
} else if (decoration==MTDdoubleoverline) {
painter.setPen(p);
painter.setPen(pul);
const QLineF l(decotop_xstart, deco_ytopbot, decotop_xend, deco_ytopbot);
if (l.length()>0) painter.drawLine(l);
const QLineF l2(decotop_xstart, deco_ytopbot-3.0*p.widthF(), decotop_xend, deco_ytopbot-3.0*p.widthF());
const QLineF l2(decotop_xstart, deco_ytopbot-2.5*pul.widthF(), decotop_xend, deco_ytopbot-2.5*pul.widthF());
if (l2.length()>0) painter.drawLine(l2);
painter.setPen(pold);
} else if (decoration==MTDunderline) {
painter.setPen(p);
} else if (decoration==MTDunderline || decoration==MTDunderlineDashed || decoration==MTDunderlineDotted) {
if (decoration==MTDunderlineDashed) pul.setStyle(Qt::DashLine);
if (decoration==MTDunderlineDotted) pul.setStyle(Qt::DotLine);
painter.setPen(pul);
const QLineF l(decobot_xstart, decobelow_ypos, decobot_xend, decobelow_ypos);
if (l.length()>0) painter.drawLine(l);
painter.setPen(pold);
} else if (decoration==MTDdoubleunderline) {
painter.setPen(p);
painter.setPen(pul);
const QLineF l(decobot_xstart, decobelow_ypos, decobot_xend, decobelow_ypos);
if (l.length()>0) painter.drawLine(l);
QLineF l2(decobot_xstart, decobelow_ypos+3.0*p.widthF(), decobot_xend, decobelow_ypos+3.0*p.widthF());
QLineF l2(decobot_xstart, decobelow_ypos+2.5*pul.widthF(), decobot_xend, decobelow_ypos+2.5*pul.widthF());
if (l2.length()>0) painter.drawLine(l2);
painter.setPen(pold);
} else if (decoration==MTDarrow) {
@ -325,6 +361,36 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
poly<<QPointF(decotop_xend-deco_vecwidth, deco_ytopbot)<<QPointF(decotop_xend, deco_ytopcenter)<<QPointF(decotop_xend-deco_vecwidth, deco_ytoptop);
painter.drawPolyline(poly);
painter.setPen(pold);
} else if (decoration==MTDoverrightarrow) {
painter.setPen(p);
const QPainterPath path=JKQTMathTextMakeArrow(decotop_xstart, deco_ytopcenter, deco_width, deco_height, false, true);
painter.drawPath(path);
painter.setPen(pold);
} else if (decoration==MTDoverleftarrow) {
painter.setPen(p);
const QPainterPath path=JKQTMathTextMakeArrow(decotop_xstart, deco_ytopcenter, deco_width, deco_height, true, false);
painter.drawPath(path);
painter.setPen(pold);
} else if (decoration==MTDoverleftrightarrow) {
painter.setPen(p);
const QPainterPath path=JKQTMathTextMakeArrow(decotop_xstart, deco_ytopcenter, deco_width, deco_height, true, true);
painter.drawPath(path);
painter.setPen(pold);
} else if (decoration==MTDunderrightarrow) {
painter.setPen(p);
const QPainterPath path=JKQTMathTextMakeArrow(decobot_xstart, decobelow_ypos+deco_height/2.0, decobot_xend-decobot_xstart, deco_height, false, true);
painter.drawPath(path);
painter.setPen(pold);
} else if (decoration==MTDunderleftarrow) {
painter.setPen(p);
const QPainterPath path=JKQTMathTextMakeArrow(decobot_xstart, decobelow_ypos+deco_height/2.0, decobot_xend-decobot_xstart, deco_height, true, false);
painter.drawPath(path);
painter.setPen(pold);
} else if (decoration==MTDunderleftrightarrow) {
painter.setPen(p);
const QPainterPath path=JKQTMathTextMakeArrow(decobot_xstart, decobelow_ypos+deco_height/2.0, decobot_xend-decobot_xstart, deco_height, true, true);
painter.drawPath(path);
painter.setPen(pold);
} else if (decoration==MTDhat) {
if (!fDrawFontAccent(QChar(0x302), QChar(0x2c6))) {
painter.setPen(p);
@ -378,13 +444,13 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
}
} else if (decoration==MTDacute) {
if (!fDrawFontAccent(QChar(0x301), QChar(0x2CA))) {
painter.setPen(p);
painter.setPen(pul);
painter.drawLine(QLineF(decotop_xcenter, deco_ytopbot, decotop_xcenter-deco_accentwidth, deco_ytopcenter));
painter.setPen(pold);
}
} else if (decoration==MTDgrave) {
if (!fDrawFontAccent(QChar(0x300), QChar(0x2CB))) {
painter.setPen(p);
painter.setPen(pul);
painter.drawLine(QLineF(decotop_xcenter, deco_ytopbot, decotop_xcenter+deco_accentwidth, deco_ytopcenter));
painter.setPen(pold);
}
@ -438,22 +504,22 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
painter.setBrush(bold);
}
} else if (decoration==MTDstrike) {
painter.setPen(p);
painter.setPen(pul);
const QLineF l((decotop_xstart+decobot_xstart)/2.0, strike_ypos, (decotop_xend+decobot_xend)/2.0, strike_ypos);
if (l.length()>0) painter.drawLine(l);
painter.setPen(pold);
} else if (decoration==MTDcancel) {
painter.setPen(p);
painter.setPen(pul);
const QLineF l(decobot_xstart, decobelow_ypos, decotop_xend, deco_ytopbot);
if (l.length()>0) painter.drawLine(l);
painter.setPen(pold);
} else if (decoration==MTDbcancel) {
painter.setPen(p);
painter.setPen(pul);
const QLineF l(decobot_xstart, deco_ytopbot, decotop_xend, decobelow_ypos);
if (l.length()>0) painter.drawLine(l);
painter.setPen(pold);
} else if (decoration==MTDxcancel) {
painter.setPen(p);
painter.setPen(pul);
const QLineF l(decobot_xstart, deco_ytopbot, decotop_xend, decobelow_ypos);
if (l.length()>0) painter.drawLine(l);
const QLineF l1(decobot_xstart, decobelow_ypos, decotop_xend, deco_ytopbot);

View File

@ -57,7 +57,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSing
MTDoverline, /*!< \brief overline over block \image html jkqtmathtext/MTDoverline.png */
MTDdoubleoverline, /*!< \brief double overline over block \image html jkqtmathtext/MTDdoubleoverline.png */
MTDunderline, /*!< \brief underline under block \image html jkqtmathtext/MTDunderline.png */
MTDdoubleunderline, /*!< \brief double underline under block \image html jkqtmathtext/MTDdoubleunderline.png */
MTDunderlineDashed, /*!< \brief dashed line under block \image html jkqtmathtext/MTDunderlineDashed.png */
MTDunderlineDotted, /*!< \brief dotted line under block \image html jkqtmathtext/MTDunderlineDotted.png */
MTDdoubleunderline, /*!< \brief double line under block \image html jkqtmathtext/MTDdoubleunderline.png */
MTDtilde, /*!< \brief small tilde over block \image html jkqtmathtext/MTDtilde.png */
MTDwidetilde, /*!< \brief full width tilde over block \image html jkqtmathtext/MTDwidetilde.png */
MTDacute, /*!< \brief small acute accent over block \image html jkqtmathtext/MTDacute.png */
@ -65,7 +67,13 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSing
MTDcancel, /*!< \brief cancel text with sloped line \image html jkqtmathtext/MTDcancel.png */
MTDbcancel, /*!< \brief cancel text with backward sloped line \image html jkqtmathtext/MTDbcancel.png */
MTDxcancel, /*!< \brief cancel text with X \image html jkqtmathtext/MTDxcancel.png */
MTDstrike /*!< \brief strikethrough text \image html jkqtmathtext/MTDstrike.png */
MTDstrike, /*!< \brief strikethrough text \image html jkqtmathtext/MTDstrike.png */
MTDoverleftarrow, /*!< \brief left-pointing arrow over everything text \image html jkqtmathtext/MTDoverleftarrow.png */
MTDoverrightarrow, /*!< \brief right-pointing arrow over everything text \image html jkqtmathtext/MTDoverrightarrow.png */
MTDoverleftrightarrow, /*!< \brief left/right-pointing arrow over everything text \image html jkqtmathtext/MTDoverleftrightarrow.png */
MTDunderleftarrow, /*!< \brief left-pointing arrow under everything text \image html jkqtmathtext/MTDunderleftarrow.png */
MTDunderrightarrow, /*!< \brief right-pointing arrow under everything text \image html jkqtmathtext/MTDunderrightarrow.png */
MTDunderleftrightarrow, /*!< \brief left/right-pointing arrow under everything text \image html jkqtmathtext/MTDunderleftrightarrow.png */
};
/** \brief convert a DecorationType into a string
*/