Bug in CustomTypeFace

It seems the CustomTypeface serialization is not a 1:1 process.
In the attached image, top half show standard Arial font from system (not using custom L&F)
Bottom half shows with Arial glyph serialized from CustomTypeface and then loaded in a custom L&F.

The other code doesn’t change, but it seem the baseline is lower on the bottom half, and the text “touch” the bottom rectangle.

Also, I think the CustomTypeface(InputStream &) should be CustomTypeface(const InputStream &).
This force to have an object elsewhere, while the constructor don’t need the reference anymore after execution.

Did you call setCharacteristics() to make sure it had it the correct ascent before saving it?

I think you may be a little bit muddled there… It would be impossible to read from a const InputStream.

I have no idea about the ascent (what is the good value ?). The code does this:

// Saving
CustomTypeface customTypeface;
customTypeface.addGlyphsFromOtherTypeface (*font.getTypeface(), 0, glyphCount);
customTypeface.writeToStream (*stream);

// Loading 
const Typeface::Ptr getTypefaceForFont (const Font& font)
   MemoryStream ins(...);
   return new CustomTypeface tf(ins);

So nothing strange in there, I’m not dealing with the generated stream in anyway.

Yes, sorry… it’s late. I’ve read it as a MemoryBlock.

If you’re copying glyphs from another typeface, then you’d need to also copy its ascent value for the result to look the same.

Is there any reason why it’s not done dynamically ?
I mean, you can’t add glyphs with different ascent anyway with the current interface, as there is no way to set the input ascent.
So it’s probably better if addGlyphsFromOtherTypeface called setCharacteristics from the first given typeface (first glyph added) ?

Yes, I guess it probably could do that automatically.