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

Font: Deprecate old Font constructors

This commit is contained in:
reuk 2024-03-19 20:32:19 +00:00
parent 2ed9b84070
commit 4f2c287f9b
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
95 changed files with 428 additions and 209 deletions

View file

@ -267,7 +267,7 @@ public:
AudioPlaybackDemo()
{
addAndMakeVisible (zoomLabel);
zoomLabel.setFont (Font (15.00f, Font::plain));
zoomLabel.setFont (FontOptions (15.00f, Font::plain));
zoomLabel.setJustificationType (Justification::centredRight);
zoomLabel.setEditable (false, false, false);
zoomLabel.setColour (TextEditor::textColourId, Colours::black);
@ -289,7 +289,7 @@ public:
fileTreeComp.addListener (this);
addAndMakeVisible (explanation);
explanation.setFont (Font (14.00f, Font::plain));
explanation.setFont (FontOptions (14.00f, Font::plain));
explanation.setJustificationType (Justification::bottomRight);
explanation.setEditable (false, false, false);
explanation.setColour (TextEditor::textColourId, Colours::black);

View file

@ -243,7 +243,7 @@ public:
addAndMakeVisible (liveAudioScroller);
addAndMakeVisible (explanationLabel);
explanationLabel.setFont (Font (15.0f, Font::plain));
explanationLabel.setFont (FontOptions (15.0f, Font::plain));
explanationLabel.setJustificationType (Justification::topLeft);
explanationLabel.setEditable (false, false, false);
explanationLabel.setColour (TextEditor::textColourId, Colours::black);

View file

@ -907,7 +907,7 @@ class MonospaceEditor : public TextEditor
public:
MonospaceEditor()
{
setFont (Font { Font::getDefaultMonospacedFontName(), 12, 0 });
setFont (FontOptions { Font::getDefaultMonospacedFontName(), 12, 0 });
}
void onCommit (std::function<void()> fn)
@ -926,7 +926,7 @@ class MonospaceLabel : public Label
public:
MonospaceLabel()
{
setFont (Font { Font::getDefaultMonospacedFontName(), 12, 0 });
setFont (FontOptions { Font::getDefaultMonospacedFontName(), 12, 0 });
setMinimumHorizontalScale (1.0f);
setInterceptsMouseClicks (false, false);
}
@ -1531,7 +1531,7 @@ public:
const auto groupWidth = 100;
GlyphArrangement groupArrangement;
groupArrangement.addJustifiedText ({},
groupArrangement.addJustifiedText (FontOptions{},
"Group",
0,
0,
@ -1571,7 +1571,7 @@ public:
const auto bounds = buttons[(size_t) i].getBounds();
GlyphArrangement channelArrangement;
channelArrangement.addJustifiedText ({},
channelArrangement.addJustifiedText (FontOptions{},
i < 16 ? String (i + 1) : "All",
0,
0,

View file

@ -449,7 +449,7 @@ private:
//==============================================================================
void addLabelAndSetStyle (Label& label)
{
label.setFont (Font (15.00f, Font::plain));
label.setFont (FontOptions (15.00f, Font::plain));
label.setJustificationType (Justification::centredLeft);
label.setEditable (false, false, false);
label.setColour (TextEditor::textColourId, Colours::black);

View file

@ -12,7 +12,7 @@ void MainComponent::paint (juce::Graphics& g)
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
g.setFont (juce::Font (16.0f));
g.setFont (juce::FontOptions (16.0f));
g.setColour (juce::Colours::white);
g.drawText ("Hello World!", getLocalBounds(), juce::Justification::centred, true);
}

View file

@ -74,7 +74,7 @@ private:
mainComponent (comp)
{
addAndMakeVisible (titleLabel);
titleLabel.setFont (titleLabelFontHeight);
titleLabel.setFont (FontOptions { titleLabelFontHeight });
addLookAndFeels();
@ -184,7 +184,7 @@ private:
: deviceSelectorComp (getSharedAudioDeviceManager(), 0, 256, 0, 256, true, true, true, false)
{
addAndMakeVisible (titleLabel);
titleLabel.setFont (titleLabelFontHeight);
titleLabel.setFont (FontOptions { titleLabelFontHeight });
addAndMakeVisible (deviceSelectorComp);
deviceSelectorComp.setItemHeight (itemHeight);

View file

@ -227,7 +227,7 @@ class CubicBezierSettingsComponent final : public Component
public:
CubicBezierSettingsComponent()
{
textEditor.setFont (Font (18.0f));
textEditor.setFont (FontOptions (18.0f));
textEditor.setColour (TextEditor::ColourIds::backgroundColourId, {});
textEditor.setColour (TextEditor::ColourIds::highlightColourId, {});
textEditor.setColour (TextEditor::ColourIds::outlineColourId, {});

View file

@ -218,20 +218,20 @@ public:
if (rowIsSelected)
g.fillAll (Colours::lightblue);
auto font = fonts[rowNumber];
auto font = getFont (rowNumber);
AttributedString s;
s.setWordWrap (AttributedString::none);
s.setJustification (Justification::centredLeft);
s.append (getNameForRow (rowNumber), font.withHeight ((float) height * 0.7f), Colours::black);
s.append (" " + font.getTypefaceName(), Font ((float) height * 0.5f, Font::italic), Colours::grey);
s.append (" " + font.getTypefaceName(), FontOptions ((float) height * 0.5f, Font::italic), Colours::grey);
s.draw (g, Rectangle<int> (width, height).expanded (-4, 50).toFloat());
}
String getNameForRow (int rowNumber) override
{
return fonts[rowNumber].getTypefaceName();
return getFont (rowNumber).getTypefaceName();
}
void selectedRowsChanged (int /*lastRowselected*/) override
@ -240,6 +240,11 @@ public:
}
private:
Font getFont (int rowNumber) const
{
return isPositiveAndBelow (rowNumber, fonts.size()) ? fonts.getUnchecked (rowNumber) : FontOptions{};
}
Array<Font> fonts;
StringArray currentStyleList;
@ -317,7 +322,7 @@ private:
auto italic = italicToggle.getToggleState();
auto useStyle = ! (bold || italic);
auto font = fonts[listBox.getSelectedRow()];
auto font = getFont (listBox.getSelectedRow());
font = font.withPointHeight ((float) heightSlider .getValue())
.withExtraKerningFactor ((float) kerningSlider.getValue())

View file

@ -124,7 +124,7 @@ public:
: Component (name),
controls (cc)
{
displayFont = Font (Font::getDefaultMonospacedFontName(), 12.0f, Font::bold);
displayFont = FontOptions (Font::getDefaultMonospacedFontName(), 12.0f, Font::bold);
}
AffineTransform getTransform()
@ -278,7 +278,7 @@ public:
double lastRenderStartTime = 0.0, averageTimeMs = 0.0, averageActualFPS = 0.0;
Image clipImage;
Font displayFont;
Font displayFont { FontOptions{} };
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphicsDemoBase)
};
@ -458,7 +458,7 @@ public:
GlyphsDemo (ControllersComponent& cc)
: GraphicsDemoBase (cc, "Glyphs")
{
glyphs.addFittedText ({ 20.0f }, "The Quick Brown Fox Jumps Over The Lazy Dog",
glyphs.addFittedText (FontOptions { 20.0f }, "The Quick Brown Fox Jumps Over The Lazy Dog",
-120, -50, 240, 100, Justification::centred, 2, 1.0f);
}

View file

@ -60,7 +60,7 @@ public:
{
addAndMakeVisible (helloWorldLabel);
helloWorldLabel.setFont (Font (40.00f, Font::bold));
helloWorldLabel.setFont (FontOptions (40.00f, Font::bold));
helloWorldLabel.setJustificationType (Justification::centred);
helloWorldLabel.setEditable (false, false, false);
helloWorldLabel.setColour (Label::textColourId, Colours::black);

View file

@ -106,7 +106,7 @@ private:
burgerButton.setBounds (r.removeFromRight (40).withSizeKeepingCentre (20, 20));
titleLabel.setFont (Font ((float) getHeight() * 0.5f, Font::plain));
titleLabel.setFont (FontOptions ((float) getHeight() * 0.5f, Font::plain));
titleLabel.setBounds (r);
}

View file

@ -997,7 +997,7 @@ private:
{
addAndMakeVisible (statusLabel);
statusLabel.setJustificationType (Justification::topLeft);
statusLabel.setFont (Font (14.0f));
statusLabel.setFont (FontOptions (14.0f));
addAndMakeVisible (sizeSlider);
sizeSlider.setRange (0.0, 1.0, 0.001);

View file

@ -69,7 +69,7 @@ public:
addAndMakeVisible (statusLabel);
statusLabel.setJustificationType (Justification::topLeft);
statusLabel.setFont (Font (14.0f));
statusLabel.setFont (FontOptions (14.0f));
auto presets = getPresets();

View file

@ -1156,7 +1156,7 @@ public:
private:
TableListBox table; // the table component itself
Font font { 14.0f };
Font font { FontOptions { 14.0f } };
std::unique_ptr<XmlElement> demoData; // This is the XML document loaded from the embedded file "demo table data.xml"
XmlElement* columnList = nullptr; // A pointer to the sub-node of demoData that contains the list of columns

View file

@ -1049,7 +1049,7 @@ public:
const auto rulerHeight = bounds.getHeight() / 3;
g.drawRect (drawBounds.getX(), rulerHeight, drawBounds.getRight(), rulerHeight);
g.setFont (Font (12.0f));
g.setFont (FontOptions (12.0f));
const int lightLineWidth = 1;
const int heavyLineWidth = 3;
@ -1455,12 +1455,12 @@ public:
}
else
{
g.setFont (Font (12.0f));
g.setFont (FontOptions (12.0f));
g.drawText ("Audio Access Disabled", getLocalBounds(), Justification::centred);
}
g.setColour (Colours::white.withMultipliedAlpha (0.9f));
g.setFont (Font (12.0f));
g.setFont (FontOptions (12.0f));
g.drawText (convertOptionalARAString (playbackRegion.getEffectiveName()),
getLocalBounds(),
Justification::topLeft);
@ -2325,7 +2325,7 @@ public:
if (! isARAEditorView())
{
g.setColour (Colours::white);
g.setFont (15.0f);
g.setFont (FontOptions (15.0f));
g.drawFittedText ("ARA host isn't detected. This plugin only supports ARA mode",
getLocalBounds(),
Justification::centred,

View file

@ -386,17 +386,17 @@ private:
// add some labels for the sliders..
gainLabel.attachToComponent (&gainSlider, false);
gainLabel.setFont (Font (11.0f));
gainLabel.setFont (FontOptions (11.0f));
delayLabel.attachToComponent (&delaySlider, false);
delayLabel.setFont (Font (11.0f));
delayLabel.setFont (FontOptions (11.0f));
// add the midi keyboard component..
addAndMakeVisible (midiKeyboard);
// add a label that will display the current timecode and status..
addAndMakeVisible (timecodeDisplayLabel);
timecodeDisplayLabel.setFont (Font (Font::getDefaultMonospacedFontName(), 15.0f, Font::plain));
timecodeDisplayLabel.setFont (FontOptions (Font::getDefaultMonospacedFontName(), 15.0f, Font::plain));
// set resize limits for this plug-in
setResizeLimits (400, 200, 1024, 700);

View file

@ -1582,10 +1582,10 @@ public:
g.fillRect (rectChoice);
g.setColour (Colours::white);
g.setFont (Font (20.0f).italicised().withExtraKerningFactor (0.1f));
g.setFont (Font (FontOptions (20.0f)).italicised().withExtraKerningFactor (0.1f));
g.drawFittedText ("DSP MODULE DEMO", rectTop.reduced (10, 0), Justification::centredLeft, 1);
g.setFont (Font (14.0f));
g.setFont (FontOptions (14.0f));
String strText = "IR length (reverb): " + String (proc.getCurrentIRSize()) + " samples";
g.drawFittedText (strText, rectBottom.reduced (10, 0), Justification::centredRight, 1);
}

View file

@ -99,7 +99,7 @@ public:
addAndMakeVisible (testResultsBox);
testResultsBox.setMultiLine (true);
testResultsBox.setFont ({ Font::getDefaultMonospacedFontName(), 12.0f, Font::plain });
testResultsBox.setFont (FontOptions { Font::getDefaultMonospacedFontName(), 12.0f, Font::plain });
logMessage (String ("This demo uses the ChildProcessCoordinator and ChildProcessWorker classes to launch and communicate "
"with a child process, sending messages in the form of serialised ValueTree objects.") + newLine

View file

@ -395,10 +395,10 @@ public:
else
stopTimer();
nameLabel.setFont (Font (16).withStyle (Font::bold | (hasBeenPurchased ? 0 : Font::italic)));
nameLabel.setFont (FontOptions { 16.0f, Font::bold | (hasBeenPurchased ? 0 : Font::italic) });
nameLabel.setColour (Label::textColourId, hasBeenPurchased ? Colours::white : Colours::grey);
priceLabel.setFont (Font (10).withStyle (purchase.priceIsKnown ? 0 : Font::italic));
priceLabel.setFont (FontOptions { 10.0f, purchase.priceIsKnown ? 0 : Font::italic });
priceLabel.setColour (Label::textColourId, hasBeenPurchased ? Colours::white : Colours::grey);
priceLabel.setText (purchase.purchasePrice, NotificationType::dontSendNotification);

View file

@ -86,13 +86,13 @@ public:
editor.reset (new CodeEditorComponent (codeDocument, nullptr));
addAndMakeVisible (editor.get());
editor->setFont ({ Font::getDefaultMonospacedFontName(), 14.0f, Font::plain });
editor->setFont (FontOptions { Font::getDefaultMonospacedFontName(), 14.0f, Font::plain });
editor->setTabSize (4, true);
outputDisplay.setMultiLine (true);
outputDisplay.setReadOnly (true);
outputDisplay.setCaretVisible (false);
outputDisplay.setFont ({ Font::getDefaultMonospacedFontName(), 14.0f, Font::plain });
outputDisplay.setFont (FontOptions { Font::getDefaultMonospacedFontName(), 14.0f, Font::plain });
addAndMakeVisible (outputDisplay);
codeDocument.addListener (this);

View file

@ -458,7 +458,7 @@ private:
auto textColour = isConnected() ? Colours::green : Colours::red;
connectionStatusLabel.setText (text, dontSendNotification);
connectionStatusLabel.setFont (Font (15.00f, Font::bold));
connectionStatusLabel.setFont (FontOptions (15.00f, Font::bold));
connectionStatusLabel.setColour (Label::textColourId, textColour);
connectionStatusLabel.setJustificationType (Justification::centredRight);
}

View file

@ -232,7 +232,7 @@ public:
resultsBox.setReadOnly (true);
resultsBox.setMultiLine (true);
resultsBox.setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
resultsBox.setFont ({ Font::getDefaultMonospacedFontName(), 12.0f, Font::plain });
resultsBox.setFont (FontOptions { Font::getDefaultMonospacedFontName(), 12.0f, Font::plain });
resultsBox.setText (getAllSystemInfo());
setSize (500, 500);

View file

@ -221,7 +221,7 @@ public:
s.append (newLine);
s.append ("Click the \"Set Random Colour\" button to change the colour of one of the circles.");
s.append (newLine);
s.setFont (16.0f);
s.setFont (FontOptions { 16.0f });
s.setColour (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::defaultText, Colours::lightgrey));
s.draw (g, explanationArea.reduced (10).toFloat());
}

View file

@ -70,7 +70,7 @@ public:
addAndMakeVisible (testResultsBox);
testResultsBox.setMultiLine (true);
testResultsBox.setFont (Font (Font::getDefaultMonospacedFontName(), 12.0f, Font::plain));
testResultsBox.setFont (FontOptions (Font::getDefaultMonospacedFontName(), 12.0f, Font::plain));
addAndMakeVisible (categoriesBox);
categoriesBox.addItem ("All Tests", 1);