Loading font from a file

Hi all !

Is there a way with JUCE to load a font from a file or, better, include a font in the executable ?

thx.

Absolutely. Do a search for CustomTypeface…

Thx for this quick answer.

However, when i try to serialise my font, i only get a small file and Loading this file back does not give me access to my original font ( No characters at all ).
Using my font after this code does work, so the issue does not come from an “empty” font.

here is my code:

    String str("Eurostile");
bFont = new Font(str,12,Font::plain);
Typeface tf(*(bFont->getTypeface()));
File file("/Users/drolland/Eurostile_font.h");
FileOutputStream fileos(file);
tf.serialise(fileos);
fileos.flush();

what i am doing wrong ?

Thx !

It’ll only save any characters that have been loaded into the typeface (by drawing them).

have a look here
http://www.rawmaterialsoftware.com/viewtopic.php?f=6&t=54
and here

http://edoapp.googlecode.com/svn/trunk/Tools/Fserialize/

Do we have any newer docs on how to load custom fonts, please?

Maybe this?

1 Like

Just a clarification this process does NOT necessarily need Projucer.

using the BinaryBuilder as shown below these assets can be embedded in any project, CMAKE or otherwise (even without JUCE).

$JUCE_HOME/build/extras/BinaryBuilder/BinaryBuilder_artefacts/Debug/BinaryBuilder <directory_where_font[s]_are> <directory_where_cpp_hpp_files_wil_be_placed> BinaryAssets