Issue with DirectWrite renderer and loading of Font files

Hello guys !

Not sure why it happens, but I have noticed some issues on Windows with the DirectWrite renderer. To make the issue appear, you need to follow these instructions :

  • Enable the DirectWrite renderer in the Projucer
  • Load a font file (on the hard drive or embedded) using for example the code below
  • Draw some text using that new Font (it should work)
  • Try again using that Font and a style different from “plain”
  • The rendering should display Times New Roman or any other default font instead of the one in the file

[code]const Font loadFontFile(File fileFont)
if (fileFont.existsAsFile() == false)
return Font();

FileInputStream theStream(fileFont);

    MemoryBlock theMemoryBlock;

    Typeface::Ptr ptr = Typeface::createSystemTypefaceFor(theMemoryBlock.getData(), theMemoryBlock.getSize());

    if (ptr == nullptr)
        return Font();

        return Font(ptr);

    return Font();


The strange thing about that issue is that you can use the same font if it has been already installed on the system without any problem. And if you disable DirectWrite in the Projucer, everything works as expected too. Same for Mac OS X.

That’s not a very important problem (I just disable DirectWrite all the time in general), but important enough to report I think, in a case of other people seeing a problem with embedded fonts too…

similar to this? Font embedding broken in windows 10.x?

Maybe but I’m not sure that’s the same problem. I think the issue I reported is related with the need to load all the different styles of a given Typeface when the renderer engine is DirectWrite, while the issue in the other thread is about Windows 10 and plain text rendered incorrectly…

What type of font file are you loading? .ttf?

Just did the test right now, I have the same font in OTF and TTF formats, the issue is there only with the OTF file.