Typeface::serialise confusion


#1

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);

	tf->serialise(*out);

	//...

…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?


#2

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


#3

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


#4
	//...

	OutputStream* out = testFile.createOutputStream();

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

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

	tf->serialise(*out);

	//...

should be enough :smiley:

cheers


#5

[quote=“kraken”]
should be enough :smiley:
cheers[/quote]

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:


#6

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

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


#7

Precisely something along those lines would be nice :slight_smile:

Jules ? :wink:


#8

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.