mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 10:01:38 +08:00
JKQTMathText: fixed super-script sizing (using tightboundingbox around x instead of xHeight(), which caused some problems recently for several standard fonts
This commit is contained in:
parent
8719208acf
commit
4b4075c226
@ -49,11 +49,15 @@ JKQTMathTextNodeSize JKQTMathTextSuperscriptNode::getSizeWithSpecialPlacement(QP
|
|||||||
JKQTMathTextNodeSize s;
|
JKQTMathTextNodeSize s;
|
||||||
JKQTMathTextEnvironment ev=currentEv;
|
JKQTMathTextEnvironment ev=currentEv;
|
||||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFont fnt=currentEv.getFont(parentMathText);
|
||||||
const QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
const QFontMetricsF fm(fnt, painter.device());
|
||||||
|
//const QRectF tbr_of_letterM=JKQTMathTextGetTightBoundingRect(currentEv.getFont(parentMathText), "M", painter.device());
|
||||||
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
const double childDescent=cs.getDescent();
|
const double childDescent=cs.getDescent();
|
||||||
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*fm.xHeight();
|
const QRectF tbr=JKQTMathTextGetTightBoundingRect(fnt, "x", painter.device());
|
||||||
|
const double xh=tbr.height();
|
||||||
|
|
||||||
|
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*xh;//fm.xHeight();
|
||||||
|
|
||||||
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
||||||
const double modifiedShift=prevNodeSizeForSpecialPlacement->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cs.baselineHeight-childDescent;
|
const double modifiedShift=prevNodeSizeForSpecialPlacement->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cs.baselineHeight-childDescent;
|
||||||
@ -78,11 +82,14 @@ double JKQTMathTextSuperscriptNode::drawWithSpecialPlacement(QPainter& painter,
|
|||||||
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
ev.fontSize=ev.fontSize*parentMathText->getSubsuperSizeFactor();
|
||||||
|
|
||||||
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
const JKQTMathTextNodeSize cs=getChild()->getSize(painter, ev);
|
||||||
|
const QFont fnt=currentEv.getFont(parentMathText);
|
||||||
const QFontMetricsF fm(currentEv.getFont(parentMathText), painter.device());
|
const QFontMetricsF fm(fnt, painter.device());
|
||||||
|
const QRectF tbr=JKQTMathTextGetTightBoundingRect(fnt, "x", painter.device());
|
||||||
|
const double xh=tbr.height();
|
||||||
|
//qDebug()<<"x="<<x<<" prevNodeSizeForSpecialPlacement="<<prevNodeSizeForSpecialPlacement<<" font="<<currentEv.getFont(parentMathText);
|
||||||
//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=cs.overallHeight-cs.baselineHeight;
|
const double childDescent=cs.overallHeight-cs.baselineHeight;
|
||||||
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*fm.xHeight();
|
double shiftToChildBottom=parentMathText->getSuperShiftFactor()*xh;//fm.xHeight();
|
||||||
|
|
||||||
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
if (prevNodeSizeForSpecialPlacement!=nullptr) {
|
||||||
const double modifiedShift=prevNodeSizeForSpecialPlacement->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cs.baselineHeight-childDescent;
|
const double modifiedShift=prevNodeSizeForSpecialPlacement->baselineHeight-childDescent-parentMathText->getSpecialSuperShiftFactor()*cs.baselineHeight-childDescent;
|
||||||
|
Loading…
Reference in New Issue
Block a user