I resolved my issue, it was only because a bad export of TTF.
Now it works, but I don’t know how to set default font !
I overloaded getTypefaceForFont() function, but labels don’t use my custom font.
So, can you tell me how it works ?
Where can I define a global font ?
Maybe you’re creating your lookandfeel too late, so that some fonts have already loaded and cached the default typeface before you set your own custom one?
I have inserted my L+F in Jucer so that I can select it as we can do with new and old school L+F.
If it does not work like this, how do I have to create it ? Or when ?
Well, you’d need to apply it before creating the Font objects that you want it to change. Once a Font has been created, its typeface is fixed, and won’t be affected by anything you do in the l+f afterwards.
Like I said, any Font objects created before you apply your l+f will not be affected by it.
You were complaining that a label wasn’t using your typeface, so I’m assuming you created this label BEFORE you applied your l+f, and it probably has an internal Font object that was created beforehand.
[quote=“jules”]
When a Font is asked to produce its Typeface object, it uses LookAndFeel::getTypefaceForFont to get one.
The result gets cached inside the Font object, so it will only call getTypefaceForFont once.
That’s it. I don’t know what else you expect me to explain![/quote]
So I tried something :
Put a break into getTypefaceForFont() in my own l+f
Create a label
At the creation label does not look in l+f, and get a default font (sansSerif).
It does like this because of creating font member using SharedFontInternal which initialize typeface like this :
If I initialize my l+f before any window, TypefaceCache uses its typeface ! …
So apparently, after having initialized any GUI component using a selected l+f, you cannot change labels without restarting application because TypefaceCache is not reset by new l+f.
I was assuming you already were creating your l+f before creating any components!
If you really need to change it later, you could clear the cache by calling Typeface::setTypefaceCacheSize, but even then you can’t guarantee that all fonts will magically update, so just setting it up early is the best plan.
So now that I understood how to set it by default, can you explain me why I cannot set labels in bold or italic ?
That does not work at all, whereas I exported the 260 glyphs using FontBuilder (application posted in another thread).
Do you know why ?