CustomTypeface questions


When using writeToStream() method, does it write all possible style flags? I serialize a typeface by name, write it to a file, add that file as a resource (using JUCER) and use that Typeface (create a new font from it). it works, untili i try to set the Bold flag, then the Graphics class falls back to a default typeface. The same font used from within JUCER on a Label has all the bold/italic flags.

So my question is. Should i write 4 versions of a typeface to 4 different files (each with a different set of flags) and use them, if so - how (setCharacteristics()? perhaps) ? Is there a way to serialize all possible variations into one file/stream and use that?

or am i just missing the point completly.


A typeface doesn’t contain alternate versions for different styles, so yes, you’d need to serialise several different styles if that’s what you need it to do.


well yes i’d like to serialize a font, by that i mean it’s bold and italic and bold+italic styles.

if i serialize it’s all versions into seperate files, then to glue it back together can i use addGlyphsFromOtherTypeface() and do it for all versions and create a typeface that contains all of the styles, will this work.

Also is there a way to find a number of characetrs in a typeface.


No - a typeface only has one style, no matter how you create it! You can only do it by having different typefaces for each style.

Finding the number of glyphs is tricky - on windows, it’s possible, but I think the mac is lacking the right APIs. Can’t quite remember the details though.


So how do you serialize a Font then, writing a typeface to stream is not equivalent of writing a Font to stream. If i write 4 typefaces to 4 streams i can’t put them back into one font, so it’s not usable. Also i have a font (Windows) and it has one name “Sony Sketch EF” (as seen in JUCER), however this font in JUCER has Bold and Italic styles. I do have seperate font files (ttf) for Bold, Italic and Bold+italic styles, however after installing them JUCER does not see them (they are named differently), however GIMP sees them as seperate fonts that i can use.

so it’s not clear to me how to write a WHOLE font to a file and re-use it in my app.

the font i’m taling about is here:


There’s not really any such thing as a “whole font”. When you ask a font to become bold or italic, it goes off and looks for a new typeface that matches that style, which might mean loading a different typeface file, or the OS might shear a non-italic typeface to make it italicised, etc. The typeface object really isn’t designed to be smart enough to do what you’re asking - it just stores some glyphs and knows nothing about their attributes.


allright i get it now. i’ll try to re-write the font serializer utility.

thank you for the information.


Hey Atom,
Do you have this rewritten yet? I was using your older one a couple months back with success, but now I’m trying to figure out how to use this on the latest git version. no success yet. It was working with the older 1.50 stable zip from the August download, but not in the latest git version tip… I get a compile error (Error 1 error C2259: ‘juce::Typeface’ : cannot instantiate abstract class).

Jules, can you explain or provide a simple example of using the new typeface class? It looks like you redid the Typeface class (and folder structures in the core) back in November 2009, no?

Thanks for any insight or direction.



yeah i fixed this stuff and got it to work


Cool thanks Atom. I was hoping to see how you implemented it too from your Gekon link (which seem to have been removed). I’m stuck on creating the stream for the typeface creation in my plug-in. Any suggestions for that?



I posted an example project it’s in the fserialize dir hehre

i was able to get this to work with setDefaultLookAndFeel (exe here