Sounds like the button is sharing the same look&feel as all your other buttons, not using the one you’ve declared. Did you set it as the look&feel for that component (using setLookAndFeel(m_LookAndFeelIcons))?
If not, then getLookAndFeel will return the default Look&Feel, which is apparently shared by the other buttons. That would explain setting all the buttons’ fonts.
But for the issue at hand, which is the button NOT using the expected typeface, perhaps the Font is the problem somehow? Not sure how the button gets its Font, but the function setDefaultSansSerifTypeface() sets the member defaultTypeface, but that member only gets returned from getTypefaceForFont() if the typeface name matches the default sans serif font name. Perhaps the issue lies there?
Debugging seems to be problematic right know. I don’t know what the issue is, but I can not “step into” the setLookAndFeel function, with the debugger(I use Visual Studio). But, when I hover over the m_LookAndFeelIcons, I find my Typeface set as default there in the debugger.
When I use getLookAndFeel(), the way you mentioned, the Font of everything changes…
You should at least be able to assign the return value of getLookAndFeel() to a local pointer, and compare that pointer value with the address of m_LookAndFeelIcons. That would tell you if they are the same. And you could find where the function getTypefaceForFont() is being called, and see if that is doing what you expect.
I tried a different font from the web and the same behaviour appears. I think it is not related to my font… And as earlier mentioned, my font can be displayed, when I set it as default for the overall LookAndFeel.
It works as expected… But this can not be the solution, right? I have different Components with text, which will be using my CustomLookAndFeel and I don’t want to always overwrite this function for all the component types.
Well, the function getTextButtonFont() does get passed a reference to the specific TextButton. If you check the button’s name, then you can apply that fix for just that button, and call the default code for others. That’s what our LookAndFeel classes do in many cases.
I actually don’t want to deal with getTextButtonFont()… when not necessary!
I would expect this to do the job:
I just want to assign a custom LookAndFeel to some components to set my TypeFace as default font for them (Actually as simple as that). All of the components, using the LookAndFeel shell behave the same, using my font, I don’t want to filter out button names for differnent behaviour. Should the code, I quoted, to the job or not?
At the moment, I also need to override the getFont functions, otherwise my Buttons do not get the desired font:…
Furthermore I had to override these the same way, to apply the font to other component types:
Anyway, thank you for your help so far @HowardAntares ! Maybe I am just missunderstanding something…