Skip to content

Commit 4fe7d7b

Browse files
committed
Make sure a text's border is at least as wide as half the font's ascent height
basically affects multi-line texts only
1 parent 750840f commit 4fe7d7b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/engraving/dom/textbase.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,9 +1847,10 @@ void TextBase::layoutFrame(LayoutData* ldata) const
18471847
}
18481848

18491849
if (rectangle()) {
1850-
// make sure width >= height, if only one row (basically: make square for single characters)
1851-
if (ldata->frame.height() > ldata->frame.width() && ldata->rows() == 1) {
1852-
double w = ldata->frame.height() - ldata->frame.width();
1850+
// make sure width >= height, with min. width half the font's ascent
1851+
if (ldata->frame.height() > ldata->frame.width()) {
1852+
FontMetrics fm = FontMetrics(font());
1853+
double w = fmin(ldata->frame.height() - ldata->frame.width(), fm.ascent() * .5);
18531854
ldata->frame.adjust(-w * .5, 0.0, w * .5, 0.0);
18541855
}
18551856
} else if (circle()) {

0 commit comments

Comments
 (0)