Hello If I give a constant size for a Label
let’s say I do this:
label->setSystemFontSize(100);
will the font size scale based on different screen sizes or rather
it’s constant?
I’d also like to better understand how font scaling works. In the project I am working on, if I build for windows desktop, the fonts are about the right size that I want, but building for android and running on a device (or emulator), the fonts are much too small.
In both cases, I am just using something similar to the OP (in JS though):
var label = new cc.LabelTTF("This is my test", "Arial", 100);
Is the right thing to do to set the font size proportional to the screen resolution, or possibly the design resolution?
Guidance, maybe an example too, would be appreciated, thanks!
I believe that will just set the system font to stay at a constant size of 100. Here’s the code for Label::setSystemFontSize:
void Label::setSystemFontSize(float fontSize)
{
if (_systemFontSize != fontSize)
{
_systemFontSize = fontSize;
_originalFontSize = fontSize;
_currentLabelType = LabelType::STRING_TEXTURE;
_systemFontDirty = true;
}
}
Also, just try it out. If you’re running in a simulator or VM, just change the resolution and see what happens.
Set the font size proportional to the design resolution. I use bitmap fonts, and one thing I do to get around having too much code in my app is to output my bitmap fonts the same way as I do my textures, with the SD/HD/HDR variants, and I specify my bitmap font sizes according to the SD. So for example, a 12pt font size in my app would effectively be:
SD: 12pt font
HD: 24pt font
HDR: 48pt font
I use TTF fonts and I end up multiplying the font size x a scale factor, that I determine at app startup. This scale factor is based upon what type of device the user is running. i.e ipad Pro, iPad HD, iPad SD, iPhone , etc
var label = new cc.LabelTTF("This is my test", "Arial", 100 * scaleFactor);