JKQTMathText: improved rendering of decorations

This commit is contained in:
jkriege2 2022-08-11 12:26:14 +02:00
parent c7b0185735
commit 62e3b47d08
28 changed files with 8 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 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: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.6 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: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 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.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 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: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.5 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: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 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.4 KiB

View File

@ -57,7 +57,7 @@ MTDwidetilde.png
$\widetilde{x}\widetilde{i}\widetilde{X}\widetilde{\psi}\widetilde{abc}$ $\widetilde{x}\widetilde{i}\widetilde{X}\widetilde{\psi}\widetilde{abc}$
--- ---
jkqtmathtext_mathdeco.png 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} ...$ $\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}\ ...$
--- ---
jkqtmathtext_textaccents.png jkqtmathtext_textaccents.png
\begin{array} \begin{array}

View File

@ -217,8 +217,8 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
const double italic_xcorrection=getNonItalicXCorretion(painter, cwidth, ev, getChild()); const double italic_xcorrection=getNonItalicXCorretion(painter, cwidth, ev, getChild());
const double deco_xoffset=parentMathText->getDecorationWidthReductionXFactor()*width_X/2.0; const double deco_xoffset=parentMathText->getDecorationWidthReductionXFactor()*width_X/2.0;
const double deco_width=std::max<double>(width_x*0.5,cwidth-2.0*deco_xoffset-italic_xcorrection); const double deco_width=std::max<double>(width_x*0.5,cwidth-2.0*deco_xoffset-italic_xcorrection);
const double deco_vecwidth=width_x*0.33; const double deco_vecwidth=width_x*0.18;
const double deco_vecheight=deco_height*0.33; const double deco_vecheight=deco_height*0.25;
const double deco_accentwidth=deco_height/4.0; const double deco_accentwidth=deco_height/4.0;
const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("j").width():fm.boundingRect("^").width())-italic_xcorrection; const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("j").width():fm.boundingRect("^").width())-italic_xcorrection;
const double decotop_xcenter=x+italic_xcorrection+(cwidth-italic_xcorrection)/2.0; const double decotop_xcenter=x+italic_xcorrection+(cwidth-italic_xcorrection)/2.0;
@ -236,7 +236,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
QPen pold=painter.pen(); QPen pold=painter.pen();
QPen p=pold; QPen p=pold;
p.setColor(ev.color); p.setColor(ev.color);
p.setWidthF(linewidth);//ceil(currentEv.fontSize/16.0)); p.setWidthF(linewidth*0.75);
p.setCapStyle(Qt::RoundCap); p.setCapStyle(Qt::RoundCap);
p.setJoinStyle(Qt::RoundJoin); p.setJoinStyle(Qt::RoundJoin);
@ -246,7 +246,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
if (!aDirect.isNull() && fm.inFont(aDirect)) { if (!aDirect.isNull() && fm.inFont(aDirect)) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
const QRectF tbra=fm.tightBoundingRect(aDirect); const QRectF tbra=fm.tightBoundingRect(aDirect);
painter.translate(decotop_xcenter-tbra.width()/2.0, (deco_ytopcenter+deco_ytopbot)/2.0); painter.translate(decotop_xcenter-tbra.width()/2.0, (deco_ytopcenter+deco_ytoptop)/2.0);
//painter.setPen("red"); //painter.setPen("red");
//painter.drawEllipse(0-2,0-2,4,4); //painter.drawEllipse(0-2,0-2,4,4);
painter.translate(-tbra.x(), -tbra.y()); painter.translate(-tbra.x(), -tbra.y());
@ -264,7 +264,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
if (!aFallback.isNull() && fm.inFont(aFallback)) { if (!aFallback.isNull() && fm.inFont(aFallback)) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
const QRectF tbra=fm.tightBoundingRect(aFallback); const QRectF tbra=fm.tightBoundingRect(aFallback);
painter.translate(decotop_xcenter-tbra.width()/2.0, deco_ytopcenter); painter.translate(decotop_xcenter-tbra.width()/2.0, (deco_ytopcenter+deco_ytoptop)/2.0);
//painter.setPen("yellow"); //painter.setPen("yellow");
//painter.drawEllipse(0-2,0-2,4,4); //painter.drawEllipse(0-2,0-2,4,4);
painter.translate(-tbra.x(), -tbra.y()); painter.translate(-tbra.x(), -tbra.y());
@ -302,7 +302,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
painter.setPen(p); painter.setPen(p);
const QLineF l(decotop_xstart, deco_ytopbot, decotop_xend, deco_ytopbot); const QLineF l(decotop_xstart, deco_ytopbot, decotop_xend, deco_ytopbot);
if (l.length()>0) painter.drawLine(l); if (l.length()>0) painter.drawLine(l);
const QLineF l2(decotop_xstart, deco_ytopbot-2.0*p.widthF(), decotop_xend, deco_ytopbot-2.0*p.widthF()); const QLineF l2(decotop_xstart, deco_ytopbot-3.0*p.widthF(), decotop_xend, deco_ytopbot-3.0*p.widthF());
if (l2.length()>0) painter.drawLine(l2); if (l2.length()>0) painter.drawLine(l2);
painter.setPen(pold); painter.setPen(pold);
} else if (decoration==MTDunderline) { } else if (decoration==MTDunderline) {
@ -314,7 +314,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK
painter.setPen(p); painter.setPen(p);
const QLineF l(decobot_xstart, decobelow_ypos, decobot_xend, decobelow_ypos); const QLineF l(decobot_xstart, decobelow_ypos, decobot_xend, decobelow_ypos);
if (l.length()>0) painter.drawLine(l); if (l.length()>0) painter.drawLine(l);
QLineF l2(decobot_xstart, decobelow_ypos+2.0*p.widthF(), decobot_xend, decobelow_ypos+2.0*p.widthF()); QLineF l2(decobot_xstart, decobelow_ypos+3.0*p.widthF(), decobot_xend, decobelow_ypos+3.0*p.widthF());
if (l2.length()>0) painter.drawLine(l2); if (l2.length()>0) painter.drawLine(l2);
painter.setPen(pold); painter.setPen(pold);
} else if (decoration==MTDarrow) { } else if (decoration==MTDarrow) {

View File

@ -341,7 +341,6 @@ void JKQTMathTextModifiedTextPropsInstructionNode::fillInstructions()
ev.underlined=true; ev.underlined=true;
}, 0); }, 0);
instructions["ul"] = i; instructions["ul"] = i;
instructions["underline"] = i;
instructions["underlined"]= i; instructions["underlined"]= i;
} }
{ {
@ -349,7 +348,6 @@ void JKQTMathTextModifiedTextPropsInstructionNode::fillInstructions()
ev.overline=true; ev.overline=true;
}, 0); }, 0);
instructions["ol"] = i; instructions["ol"] = i;
instructions["overline"] = i;
instructions["overlined"]= i; instructions["overlined"]= i;
} }
{ {