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,
g.drawSingleLineText ("News Gothic Extra Condensed Bold", 20, 30);
This gives the following results:
Mac – font displaying correctly
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?
(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)
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
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.
@george-spitfire Did you find a solution to this ?
We are seeing similar issue even with TTF if user has installed some custom font on his system.
We’ve been experiencing this too, since about two years.
Memory based TTF.
I found a fix for my use case. I don’t know if this is useful, anyway here it goes:
In my case the problem was happening for some fonts that have particular styles (e.g. Bold, Italic).
This is what I was doing, in pseudo code:
auto myFont(Typeface::createSystemTypefaceFor(ItalicFontName, ItalicFontSize));
Calling setStyleFlags destroyed the contained typeface.
And this seems to be the culprit.
Taking a look into the setStyleFlags implementation I see
font->typeface = nullptr;
I don’t know why this is happening on Windows only.
Maybe @ed95 could take a look at this?
You can try with the DSEG14Classic-Italic.ttf font contained in the package available at https://www.keshikan.net/fonts-e.html