Typeface::serialise confusion


I’m trying to serialise some fonts to embed them in my application using typeface->serialise and the corresponding constructor to load them later… for example:


	OutputStream* out = testFile.createOutputStream();

	Typeface* tf = new Typeface(T("Arial"), false, false);



…however, by stepping into the Typeface constructor I see that the glyphs are not loaded by default, and I do not see how to “populate” it manually before calling serialise. Usually this is an indicator that I’m either doing something horribly wrong, or overlooking the obvious :frowning: Could someone enlighten me as to the proper usage of serialise?


You can just call Typeface::getGlyph for the characters you need, and the typeface will load them if it hasn’t already.


Is there some easier way ? Preferably have all the glyphs defined by the loaded typeface to be loaded upon request?


	OutputStream* out = testFile.createOutputStream();

	Typeface* tf = new Typeface(T("LegalFontName"), false, false);

	//Here's the important part.
	for (int i = 0; i < 256; ++i)



should be enough :smiley:



should be enough :smiley:

Unfortunately not. Non-Latin unicode character sets are not included. Ideally I’d like only to getGlyph on the characters are in the font. Now I just get the Kanji/Katakana/Hiragana charset codes and it seems to work fine. And not from “Arial” mind you. Quite illegal code you have there… :wink:


well, i don’t know much about Kanji/Katakana/Hiragana fonts. never used myself.

maybe a typeface->loadContainedGlyphs() function from Jules side ?


Precisely something along those lines would be nice :slight_smile:

Jules ? :wink:


Yes, I seem to remember having some issues with doing that on certain platforms, which is why it’s not there. I think it was on the mac where I couldn’t find a way of discovering which glyphs were used.