Using serialized font as default font


#1

Hello,

I’d like to use a serialized font as default font but I don’t known how to do it.

I managed to serialize a font and use it for specific component.

I also managed to set a default system font using the Font::setDefaultSansSerifFontName method.

But I don’t know how to use my serialized font as a default one. It seems the setDefaultSansSerifFontName can only be used for system fonts.

Note : I don’t want to install the font on the system.

Does anybody have an idea ?


#2

You can use LookAndFeel::getTypefaceForFont, which is there for exactly this kind of purpose…


#3

I didn’t find this method anywhere in the juce code :oops: . I found a Typeface::getTypefaceFor method that is not documented.
I’m using the 1.46 juce version. Is this something knew ?


#4

Sorry, yes, it’s recent code, in the tip version.


#5

Took me a while to give you a feedback. It works fine. Thank you Jules.


#6

I'm kind of stucked how to override this method.

I did the following:

Font f (Typeface::createSystemTypefaceFor (myfont_otf, myfont_otfSize));

myLNF->getTypefaceForFont (f);

What do I exactly have to do in overriding the getTypefaceForFont method? Might be a stupid question, but I have my wires crossed.