Skip to content

Commit

Permalink
Fixed display of absolute font size texts
Browse files Browse the repository at this point in the history
When the font size is absolute then don't calcualte the font size based on extents but draw the ellipses if needed.
If the elided text is just ellipses then we don't show anything.
This fixes the display of SystemDynamics library world3 scenarios.
  • Loading branch information
adeas31 committed Mar 6, 2020
1 parent 2b9188a commit 75a82ae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions OMEdit/OMEditLIB/Annotations/TextAnnotation.cpp
Expand Up @@ -368,14 +368,17 @@ void TextAnnotation::drawTextAnnotaion(QPainter *painter)
font.setPointSizeF(qMax(fontSizeFactor, Helper::minimumTextFontSize));
painter->setFont(font);
}
/* Get the elided text
* Try to get the elided text if the shape is inside a Component
* If the shape is not part of Component then only try to get the elided text if its font size <= Helper::minimumTextFontSize
/* Try to get the elided text if calculated font size <= Helper::minimumTextFontSize
* OR if font size is absolute.
*/
QString textToDraw = mTextString;
if (absMappedBoundingRect.width() > 1 && painter->font().pointSizeF() <= Helper::minimumTextFontSize) {
if (absMappedBoundingRect.width() > 1 && ((mFontSize <= 0 && painter->font().pointSizeF() <= Helper::minimumTextFontSize) || mFontSize > 0)) {
QFontMetrics fontMetrics(painter->font());
textToDraw = fontMetrics.elidedText(mTextString, Qt::ElideRight, absMappedBoundingRect.width());
// if we get "..." i.e., QChar(0x2026) as textToDraw then don't draw anything
if (textToDraw.compare(QChar(0x2026)) == 0) {
textToDraw = "";
}
}
// draw the font
if (mpComponent || mappedBoundingRect.width() != 0 || mappedBoundingRect.height() != 0) {
Expand Down

0 comments on commit 75a82ae

Please sign in to comment.