On what basis is a typeface style chosen?

I’m loading NotoSansCJK.ttc, which contains 7 weights ranging from Extra Light to Black, using juce::Typeface::createSystemTypefaceFor(const void *fontFileData, size_t fontFileDataSize).

I’d expect the Typeface to work together with JUCE’s Font system, but am running into the following questions/issues:

  • When I call getStyle() on the Typeface “Thin” is returned. On what basis is this chosen as the default?
  • When I create a juce::Font with this Typeface and set the style to FontStyleFlags::bold, I don’t see my text drawn as bold. What do the flags actually influence? I can see the style changed to “Bold”.

I always override getTypefaceForFont in the look and feel class. You can do whatever magic you like then by inspecting a Font() object and returning a typeface.

1 Like

Hey, didn’t know you could do that. Thanks, that should be a good workaround!

Just today, I was working on the same thing. In constructor of your LookAndFeel class (e.g. inheriting LookAndFeelV4) you can also call

setDefaultSansSerifTypefaceName("YourTypefaceName");

In my case, changes were not applied everywhere, so I made few overrides like:

Font getLabelFont(Label& label) override