new to JUCE and was having the same problem when I came across this old thread. After playing around with JUCE for a bit, I found an easy way to get the font to get the font to resize in proportion to your window resize so I thought I’d share
all you have to do is use the function proportionOfWidth(font size you want at default / default width) and your text will stay the same proportion at resize
For example, if you want the font Arial to be set to font size 20 at default at a screen width of 640, you would call your setFont() function and in the parenthesis put (“Arial”, “Regular”, proportionOfWidth(0.03125f)
Hope this helps anyone else struggling to get their font to resize!
This is a pretty easy, on the fly font change.
However, since writing that comment four months ago, I’ve since changed over to putting it in my default look and feel as based on this tutorial:
as I am using my own ttf font that I created. I wrote it as
const juce::Font OtherLookAndFeel::getCustomFont()
{
/* Importing binary of custom font */
static auto typeface = juce::Typeface::createSystemTypefaceFor(BinaryData::amiDOS_ttf, BinaryData::amiDOS_ttfSize);
return juce::Font(typeface);
}
juce::Typeface::Ptr OtherLookAndFeel::getTypefaceForFont(const juce::Font& f)
{
/* Returning font typeface */
return getCustomFont().getTypeface();
}
in my LookAndFeel’s .cpp file.
If you have your custom LnF component set as your default LnF, you can change the height by calling it in the component by writing in paint:
auto theFont = g.getCurrentFont();
theFont.setHeight(proportionOfWidth(0.03125f));
g.setFont(theFont));
Hope this is more help than my last comment! Sorry again for not typing it out well last time