Custom font scaling

I have all my plugins using a custom font embedded in the CMake project (as a C++ array). I’m loading it by using “createSystemTypefaceFor”.

I set the height manually with setHeight/setWidth. This way of setting the font size is not responding to DPI scaling neither on Windows Reaper nor on Linux KDE Plasma Reaper.

I’m using Juce8. Which is the most portable way to scale fonts?

I also use juce::Typeface::createSystemTypefaceFor. And you should be able to draw text as follows, right? You only need to provide a proper font_size.

g.setFont(font_size);
g.drawText(...);

Are you setting the point height, or just the height?

See JUCE: juce::FontOptions Class Reference vs JUCE: juce::FontOptions Class Reference

Yes, I set an initial size that works well with 100% scaling.

But when I set system-wide display scaling (e.g. 200%) on the display properties (to emulate an HD screen), either on Win or Linux the fonts for e.g. labels become too big.

Also juce functions like e.g. “LookAndFeel_V4::getIdealPopupMenuItemSize” set heights all the time. I haven’t found the culprit.

I use the plain ones. I did read this before but I understood as if you only have to care about the point ones if you use e.g. figma.

Ok, claude fixed this one for me.

I’m setting font sizes based on its TopLevelComponent height. “obj.getTopLevelComponent().getHeight()” returns the unscaled height.

I had to call “getTransform().getScaleFactor();“ on “resized()“ and divide the size returned by getTopLevelComponent().getHeight() by that factor.

I don’t know if this is a bad pattern but it worked.