JKQTMathText: optimized frac/sub/super spacing
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 1007 B After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 1016 B After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 887 B After Width: | Height: | Size: 831 B |
Before Width: | Height: | Size: 988 B After Width: | Height: | Size: 994 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 851 B |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.6 KiB |
@ -33,7 +33,7 @@ MTFMunderbrace.png
|
|||||||
$f(x)=\underbrace{x+x+\ldots+x}{k\ \text{times}}$
|
$f(x)=\underbrace{x+x+\ldots+x}{k\ \text{times}}$
|
||||||
---
|
---
|
||||||
MTFMoverset.png
|
MTFMoverset.png
|
||||||
$X\overset{=}{\text{def}}Y\ \ \ \ X\overset{=}{!}Y\ \ \ \ \ \frac{\Delta f}{\Delta x}\overset{\rightarrow}{\Delta x\rightarrow0}f^\prime$
|
$X\overset{=}{\text{def}}Y\ \ \ \ X\overset{=}{!}Y\ \ \ \ \ \frac{\Delta f}{\Delta x}\overset{\longrightarrow}{\Delta x\rightarrow0}f^\prime$
|
||||||
---
|
---
|
||||||
MTFMunderset.png
|
MTFMunderset.png
|
||||||
$X\underset{=}{\text{def (5)}}Y\ \ \ \ X\underset{\Rightarrow}{f}Y\ \ \ \ \ \frac{\Delta f}{\Delta x}\underset{\rightarrow}{\Delta x\rightarrow0}f^\prime$
|
$X\underset{=}{\text{def (5)}}Y\ \ \ \ X\underset{\Rightarrow}{f}Y\ \ \ \ \ \frac{\Delta f}{\Delta x}\underset{\longrightarrow}{\Delta x\rightarrow0}f^\prime$
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
|
\item $x_1^2 X_1^2 q_1^2$
|
||||||
\item\textbf{Text: Umlaute \& fonts: }\\ rm: \textrm{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
\item\textbf{Text: Umlaute \& fonts: }\\ rm: \textrm{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
||||||
it: \textit{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
it: \textit{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
||||||
sf: \textsf{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
sf: \textsf{\"Aq{\"u}\"{a}t{\oe}r abcABC00, 123-45+6.0\%\S},\\
|
||||||
|
@ -68,7 +68,7 @@ JKQTMathText::JKQTMathText(QObject* parent):
|
|||||||
brace_shrink_factor=0.45;
|
brace_shrink_factor=0.45;
|
||||||
brace_y_shift_factor=0.7;//-1;
|
brace_y_shift_factor=0.7;//-1;
|
||||||
|
|
||||||
subsuper_size_factor=0.7;
|
subsuper_size_factor=0.65;
|
||||||
subsuper_mode_selection_by_size_factor=1.01;
|
subsuper_mode_selection_by_size_factor=1.01;
|
||||||
sub_shift_factor=0.4;
|
sub_shift_factor=0.4;
|
||||||
super_shift_factor=0.7;
|
super_shift_factor=0.7;
|
||||||
|
@ -755,14 +755,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
double bigmathoperator_font_factor;
|
double bigmathoperator_font_factor;
|
||||||
/** \brief relative shift of text in superscript to normal text:
|
/** \brief relative shift of text in superscript to normal text, factor is multiplied by \c font.xHeight()
|
||||||
* 0= baseline kept, 1: baseline shifted to top of normal text
|
|
||||||
*
|
*
|
||||||
* \image html jkqtmathtext_superscriptnode_getSizeInternal.png
|
* \image html jkqtmathtext_superscriptnode_getSizeInternal.png
|
||||||
*/
|
*/
|
||||||
double super_shift_factor;
|
double super_shift_factor;
|
||||||
/** \brief relative shift of text in subscript to normal text:
|
/** \brief relative shift of text in subscript to normal text, factor is multiplied by \c font.xHeight()
|
||||||
* 0= baseline kept, 1: baseline shifted to bottom of normal text
|
|
||||||
*
|
*
|
||||||
* \image html jkqtmathtext_subscriptnode_getSizeInternal.png
|
* \image html jkqtmathtext_subscriptnode_getSizeInternal.png
|
||||||
*/
|
*/
|
||||||
|
@ -149,11 +149,27 @@ void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
|||||||
ev2.fontSize=ev2.fontSize*getFracScalingFactor()*0.7;
|
ev2.fontSize=ev2.fontSize*getFracScalingFactor()*0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QFontMetricsF fmev1(ev1.getFont(parentMathText), painter.device());
|
||||||
|
const QRectF AeTBR1=fmev1.tightBoundingRect("A");
|
||||||
|
const double asc1=AeTBR1.height();
|
||||||
|
const QFontMetricsF fmev2(ev2.getFont(parentMathText), painter.device());
|
||||||
|
const QRectF AeTBR2=fmev2.tightBoundingRect("A");
|
||||||
|
const double asc2=AeTBR2.height();
|
||||||
|
|
||||||
double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos1=0;
|
double width1=0, baselineHeight1=0, overallHeight1=0, strikeoutPos1=0;
|
||||||
double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos2=0;
|
double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos2=0;
|
||||||
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos1);
|
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos1);
|
||||||
child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos2);
|
child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos2);
|
||||||
|
if (asc1>baselineHeight1) {
|
||||||
|
const double oldDescent=overallHeight1-baselineHeight1;
|
||||||
|
baselineHeight1=asc1;
|
||||||
|
overallHeight1=baselineHeight1+oldDescent;
|
||||||
|
}
|
||||||
|
if (asc2>baselineHeight2) {
|
||||||
|
const double oldDescent=overallHeight2-baselineHeight2;
|
||||||
|
baselineHeight2=asc2;
|
||||||
|
overallHeight2=baselineHeight2+oldDescent;
|
||||||
|
}
|
||||||
const double descent1=overallHeight1-baselineHeight1;
|
const double descent1=overallHeight1-baselineHeight1;
|
||||||
|
|
||||||
|
|
||||||
@ -176,7 +192,7 @@ void JKQTMathTextFracNode::getSizeInternal(QPainter& painter, JKQTMathTextEnviro
|
|||||||
const double top_ascent=line_ascent;
|
const double top_ascent=line_ascent;
|
||||||
const double newascent=overallHeight1+top_ascent;
|
const double newascent=overallHeight1+top_ascent;
|
||||||
const double newdescent=qMax(overallHeight2-baselineHeight2, qheight-xheight);
|
const double newdescent=qMax(overallHeight2-baselineHeight2, qheight-xheight);
|
||||||
width=width1+width2+xwidth/2.0;
|
width=width1+width2+xwidth*0.666;
|
||||||
strikeoutPos=line_ascent;
|
strikeoutPos=line_ascent;
|
||||||
|
|
||||||
overallHeight=newascent+newdescent;
|
overallHeight=newascent+newdescent;
|
||||||
@ -253,10 +269,27 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QFontMetricsF fmev1(ev1.getFont(parentMathText), painter.device());
|
||||||
|
const QRectF AeTBR1=fmev1.tightBoundingRect("A");
|
||||||
|
const double asc1=AeTBR1.height();
|
||||||
|
const QFontMetricsF fmev2(ev2.getFont(parentMathText), painter.device());
|
||||||
|
const QRectF AeTBR2=fmev2.tightBoundingRect("A");
|
||||||
|
const double asc2=AeTBR2.height();
|
||||||
|
|
||||||
double width1=0, baselineHeight1=0, overallHeight1=0;//, strikeoutPos1=0;
|
double width1=0, baselineHeight1=0, overallHeight1=0;//, strikeoutPos1=0;
|
||||||
double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos=0;
|
double width2=0, baselineHeight2=0, overallHeight2=0, strikeoutPos=0;
|
||||||
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos);
|
child1->getSize(painter, ev1, width1, baselineHeight1, overallHeight1, strikeoutPos);
|
||||||
child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos);
|
child2->getSize(painter, ev2, width2, baselineHeight2, overallHeight2, strikeoutPos);
|
||||||
|
if (asc1>baselineHeight1) {
|
||||||
|
const double oldDescent=overallHeight1-baselineHeight1;
|
||||||
|
baselineHeight1=asc1;
|
||||||
|
overallHeight1=baselineHeight1+oldDescent;
|
||||||
|
}
|
||||||
|
if (asc2>baselineHeight2) {
|
||||||
|
const double oldDescent=overallHeight2-baselineHeight2;
|
||||||
|
baselineHeight2=asc2;
|
||||||
|
overallHeight2=baselineHeight2+oldDescent;
|
||||||
|
}
|
||||||
const double ascent1=baselineHeight1;
|
const double ascent1=baselineHeight1;
|
||||||
const double descent1=overallHeight1-baselineHeight1;
|
const double descent1=overallHeight1-baselineHeight1;
|
||||||
const double ascent2=baselineHeight2;
|
const double ascent2=baselineHeight2;
|
||||||
@ -286,7 +319,7 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
|
|||||||
child1->draw(painter, x+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
child1->draw(painter, x+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
|
||||||
child2->draw(painter, x+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
child2->draw(painter, x+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);
|
||||||
} else if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
} else if (mode==JKQTMathTextFracNode::MTFMstfrac || mode==JKQTMathTextFracNode::MTFMsfrac) {
|
||||||
deltaWidth=xwidth/2.0;
|
deltaWidth=xwidth*0.666;
|
||||||
child1->draw(painter, x, yline, ev1);
|
child1->draw(painter, x, yline, ev1);
|
||||||
child2->draw(painter, x+width1+deltaWidth, y, ev2);
|
child2->draw(painter, x+width1+deltaWidth, y, ev2);
|
||||||
const QLineF l(x+width1+deltaWidth, y-Mheight, x+width1, y+(qheight-xheight));
|
const QLineF l(x+width1+deltaWidth, y-Mheight, x+width1, y+(qheight-xheight));
|
||||||
|
@ -53,7 +53,7 @@ void JKQTMathTextSuperscriptNode::getSizeInternal(QPainter& painter, JKQTMathTex
|
|||||||
double cStrikeoutPos=0, cWidth=0, cBaselineHeight=0, cOverallHeight=0;
|
double cStrikeoutPos=0, cWidth=0, cBaselineHeight=0, cOverallHeight=0;
|
||||||
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
||||||
const double childDescent=cOverallHeight-cBaselineHeight;
|
const double childDescent=cOverallHeight-cBaselineHeight;
|
||||||
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*tbr_of_letterM.height();
|
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*fm.xHeight();
|
||||||
|
|
||||||
if (prevNodeSize!=nullptr) {
|
if (prevNodeSize!=nullptr) {
|
||||||
const double modifiedShift=prevNodeSize->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cBaselineHeight-childDescent;
|
const double modifiedShift=prevNodeSize->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cBaselineHeight-childDescent;
|
||||||
@ -78,7 +78,7 @@ double JKQTMathTextSuperscriptNode::draw(QPainter& painter, double x, double y,
|
|||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
||||||
QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||||
const double childDescent=cOverallHeight-cBaselineHeight;
|
const double childDescent=cOverallHeight-cBaselineHeight;
|
||||||
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*tbr_of_letterM.height();
|
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*fm.xHeight();
|
||||||
|
|
||||||
if (prevNodeSize!=nullptr) {
|
if (prevNodeSize!=nullptr) {
|
||||||
const double modifiedShift=prevNodeSize->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cBaselineHeight-childDescent;
|
const double modifiedShift=prevNodeSize->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cBaselineHeight-childDescent;
|
||||||
@ -130,7 +130,7 @@ void JKQTMathTextSubscriptNode::getSizeInternal(QPainter& painter, JKQTMathTextE
|
|||||||
double cWidth=0, cBaselineHeight=0, cOverallHeight=0, cStrikeoutPos=0;
|
double cWidth=0, cBaselineHeight=0, cOverallHeight=0, cStrikeoutPos=0;
|
||||||
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
||||||
//const double childDescent=cOverallHeight-cBaselineHeight;
|
//const double childDescent=cOverallHeight-cBaselineHeight;
|
||||||
double shift_to_childBaseline=cBaselineHeight-parentMathText->getSubShiftFactor()*tbr_of_letterM.height();
|
double shift_to_childBaseline=cBaselineHeight-parentMathText->getSubShiftFactor()*fm.xHeight();
|
||||||
|
|
||||||
if (prevNodeSize!=nullptr) {
|
if (prevNodeSize!=nullptr) {
|
||||||
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
||||||
@ -157,7 +157,7 @@ double JKQTMathTextSubscriptNode::draw(QPainter& painter, double x, double y, JK
|
|||||||
|
|
||||||
double cWidth=0, cBaselineHeight=0, cOverallHeight=0, cStrikeoutPos=0;
|
double cWidth=0, cBaselineHeight=0, cOverallHeight=0, cStrikeoutPos=0;
|
||||||
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
getChild()->getSize(painter, ev, cWidth, cBaselineHeight, cOverallHeight, cStrikeoutPos);
|
||||||
double shift_to_childBaseline=cBaselineHeight-parentMathText->getSubShiftFactor()*tbr_of_letterM.height();
|
double shift_to_childBaseline=cBaselineHeight-parentMathText->getSubShiftFactor()*fm.xHeight();
|
||||||
|
|
||||||
if (prevNodeSize!=nullptr) {
|
if (prevNodeSize!=nullptr) {
|
||||||
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
//qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
|
||||||
|