1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Font: Deprecate getStringWidth and getGlyphPositions

This commit is contained in:
reuk 2024-09-06 16:20:20 +01:00
parent eddedc2d13
commit 29213e07a1
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
21 changed files with 179 additions and 58 deletions

View file

@ -1696,7 +1696,13 @@ int CodeEditorComponent::columnToIndex (int lineNum, int column) const noexcept
void CodeEditorComponent::setFont (const Font& newFont)
{
font = newFont;
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996)
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
charWidth = font.getStringWidthFloat ("0");
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
JUCE_END_IGNORE_WARNINGS_MSVC
lineHeight = roundToInt (font.getHeight());
resized();
}

View file

@ -352,7 +352,7 @@ public:
colourLabel.setColour (Label::textWhenEditingColourId, textColour);
colourLabel.setText (currentColour.toDisplayString ((owner.flags & showAlphaChannel) != 0), dontSendNotification);
labelWidth = labelFont.getStringWidth (colourLabel.getText());
labelWidth = GlyphArrangement::getStringWidthInt (labelFont, colourLabel.getText());
repaint();
}

View file

@ -95,9 +95,14 @@ public:
void fitToContent (const int h) noexcept
{
if (keyNum < 0)
{
setSize (h, h);
}
else
setSize (jlimit (h * 4, h * 8, 6 + Font (withDefaultMetrics (FontOptions { (float) h * 0.6f })).getStringWidth (getName())), h);
{
const auto idealWidth = GlyphArrangement::getStringWidthInt (withDefaultMetrics (FontOptions { (float) h * 0.6f }), getName());
setSize (jlimit (h * 4, h * 8, 6 + idealWidth), h);
}
}
//==============================================================================