Font embedding broken in windows 10.x?


#1

I'm trying to release the latest update for my app and I have a couple users who were willing to test it on their windows machines.   I have windows 8.1 here, and everything works fine and all on that OS version.  But on their Windows 10 boxes(running the latest release), font embedding via BinaryData.h/cpp doesn't work.    Has anyone else experienced this?    My app was built with juce 3.2, and I am hesitant to port it over to 4.1, but if I need to, then I will. 


#2

Definitely works in Windows 10, we use it all the time.

You're not hitting the same AttributedString bug that a couple of other people have reported recently, are you? http://www.juce.com/forum/topic/use-embeded-font


#3

I just bumped into a similar problem: a customer reported that the label text above the sliders in my plugin is illegible on Windows10. The version he’s using was built with Juce 3.2.

I was able to reproduce myself on a Win10 machine with that version, and I went ahead and tried with the update I’m working on using Juce 4.2.3 + several commits later on the develop branch (3ff5ed0f44a2456c28793fb2ec700034c3ab5e74, date: 20160707).
But that gave the same problem: on Win7, it looks normal, but on Win10, it shows a wrong font:
Win7:

Win10:

The code is using this to load the font from a binary resource (old code someone else wrote, and I should move to createSystemTypefaceFor instead now, but it worked fine so I didn’t touch it):

Font FontBuilderSerializedFont::GetFontForFlags(const char* data, const int size, const int fontFlags)
{
    MemoryBlock m_PlainData;
    MemoryBlock m_ItalicData;
    MemoryBlock m_BoldData;
    MemoryBlock m_BoldItalicData;

    MemoryInputStream serializedFont(data, size, false);

    serializedFont.readIntoMemoryBlock(m_PlainData, static_cast<ssize_t>(serializedFont.readInt64()));
    serializedFont.readIntoMemoryBlock(m_ItalicData, static_cast<ssize_t>(serializedFont.readInt64()));
    serializedFont.readIntoMemoryBlock(m_BoldData, static_cast<ssize_t>(serializedFont.readInt64()));
    serializedFont.readIntoMemoryBlock(m_BoldItalicData, static_cast<ssize_t>(serializedFont.readInt64()));

    Typeface::Ptr typeface = nullptr;

    if (fontFlags == Font::plain)
    {
        MemoryInputStream stream(m_PlainData, false);
        typeface = new CustomTypeface(stream);
    }
    else if (fontFlags == Font::italic)
    {
        MemoryInputStream stream(m_ItalicData, false);
        typeface = new CustomTypeface(stream);
    }
    else if (fontFlags == Font::bold)
    {
        MemoryInputStream stream(m_BoldData, false);
        typeface = new CustomTypeface(stream);
    }
    else if (fontFlags == (Font::bold | Font::italic))
    {
        MemoryInputStream stream(m_BoldItalicData, false);
        typeface = new CustomTypeface(stream);
    }
    else
    {
        return Font();
    }

    if (typeface != nullptr)
    {
        Font font = Font(typeface);
        font.setStyleFlags(fontFlags);
        return font;
    }
    else
        return Font();
}

And it’s used like this:

Font myFontBold = SampleSumo::FontBuilderSerializedFont::GetFontForFlags(BinaryData::MyFont_ft, BinaryData::MyFont_ftSize, Font::bold);
myFontBold.setHeight(12.f);
m_NameLabel->setFont(myFontBold);

The strange thing is: when I manually install the font in Windows 10, then it looks OK (whereas I would expect that to not matter, as the font is embedded).

Is there anything that changed with Windows 10 that could trigger such strangeness?
Or could there be anything in the Juce code related to Windows font handling that now behaves differently compared to Windows 7 or XP?

Question related to createSystemTypefaceFor: what happens if the embedded font only contains a “plain” style (not bold, not italic, …), but the created font is then changed with setStyleFlags() to make it bold or italic?


Issue with DirectWrite renderer and loading of Font files
#4

Have you tried to disable DirectWrite in the Projucer ?


#5

No, I didn’t try that.
Where exactly is the setting for that (can’t seem to find anything in the Projucer)?


#6

The setting is displayed when you click on the juce_graphics module