File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,23 +126,29 @@ void Label::prepareText()
126126 if (! needsUpdate)
127127 return ;
128128
129- auto fontSize = getHeight () * 0 .8f ; // TODO - needs config
130- auto fontToUse = ApplicationTheme::getGlobalTheme ()->getDefaultFont ().withHeight (fontSize);
131- if (font)
132- fontToUse = *font;
129+ auto fontToUse = font.value_or (ApplicationTheme::getGlobalTheme ()->getDefaultFont ());
133130
131+ auto setup = [&] (const Font& f)
134132 {
135133 auto modifier = styledText.startUpdate ();
136134 modifier.setMaxSize (getSize ());
137135 modifier.setHorizontalAlign (StyledText::horizontalAlignFromJustification (justification));
138136 modifier.setVerticalAlign (StyledText::verticalAlignFromJustification (justification));
139- modifier.setOverflow (StyledText::ellipsis );
137+ modifier.setOverflow (StyledText::visible );
140138 modifier.setWrap (StyledText::noWrap);
141-
142139 modifier.clear ();
143-
144140 if (text.isNotEmpty ())
145- modifier.appendText (text, fontToUse);
141+ modifier.appendText (text, f);
142+ };
143+
144+ setup (fontToUse);
145+
146+ if (text.isNotEmpty ())
147+ {
148+ const float availableWidth = static_cast <float > (getWidth ());
149+ const float textWidth = styledText.getComputedTextBounds ().getWidth ();
150+ if (availableWidth > 0 .0f && textWidth > availableWidth)
151+ setup (fontToUse.withHeight (fontToUse.getHeight () * (availableWidth / textWidth)));
146152 }
147153
148154 needsUpdate = false ;
You can’t perform that action at this time.
0 commit comments