Memory-based font not rendering properly on Windows


#1

Hi,

I am seeing an issue with a memory-based font I’m using in that it renders correctly on Mac but not Windows for identical code. I’ve made a simple app to show the issue, the only lines I’ve added on top of the basic GUI app template are in paint():

void MainContentComponent::paint (Graphics& g)
{
    g.fillAll (Colour (0xff001F36));

    auto myFont = Font (Typeface::createSystemTypefaceFor (BinaryData::News_Gothic_Extra_Condensed_Bold_otf,
                                                           BinaryData::News_Gothic_Extra_Condensed_Bold_otfSize));

    myFont.setHeight (25);
    g.setFont (myFont);
    g.setColour (Colours::white);
    g.drawSingleLineText ("News Gothic Extra Condensed Bold", 20, 30);

}

This gives the following results:

Mac – font displaying correctly
MacFont

Windows – font not displaying correctly

This is using a .otf file for the font, if I convert to a .ttf the issue goes away and both platforms display the font correctly.

Does anyone know what the issue is here?

Thanks,

George

(Sorry, I can’t add a .zip or .otf, below is a download link for the .otf I’m using. If anyone wants a copy of the app for debugging just let me know. http://fontsgeek.com/fonts/News-Gothic-Extra-Condensed-Bold)


Embedding Custom Fonts OTF, TTF
#2

This rings a bell - IIRC there was just some mysterious problem that stopped Windows from loading OTFs correctly when they’re done as in-memory fonts. Not sure whether a fix is even possible for it, I think just sticking to TTFs might be the answer


#3

something similar also happens with TTF, afaik. I’ve never been able to match how the fonts are rendered (using the same cross platform font file) between Mac and PC.