I’ve two fonts in my project, a default font, and a monospaced font.
I use two functions:
Font getDefaultFont (float size, Font::FontStyleFlags style) noexcept
{
Font font;
if (style == Font::FontStyleFlags::plain)
font = Font (Typeface::createSystemTypefaceFor (BinaryData::Vera_ttf, BinaryData::Vera_ttfSize));
else if (style == Font::FontStyleFlags::italic)
font = Font (Typeface::createSystemTypefaceFor (BinaryData::VeraItalic_ttf, BinaryData::VeraItalic_ttfSize));
else if (style == Font::FontStyleFlags::bold)
font = Font (Typeface::createSystemTypefaceFor (BinaryData::VeraBold_ttf, BinaryData::VeraBold_ttfSize));
font.setHeight (size);
return font;
};
Font getDefaultMonoFont (float size, Font::FontStyleFlags style) noexcept
{
Font font;
if (style == Font::FontStyleFlags::plain)
font = Font (Typeface::createSystemTypefaceFor (BinaryData::VeraMono_ttf, BinaryData::VeraMono_ttfSize));
else if (style == Font::FontStyleFlags::italic)
font = Font (Typeface::createSystemTypefaceFor (BinaryData::VeraMonoItalic_ttf, BinaryData::VeraMonoItalic_ttfSize));
else if (style == Font::FontStyleFlags::bold)
font = Font (Typeface::createSystemTypefaceFor (BinaryData::VeraMonoBold_ttf, BinaryData::VeraMonoBold_ttfSize));
font.setHeight (size);
return font;
};
Every time I use Font f = getDefaultFont (size,style); in my components
In OSX works ok, but in windows, I get laggy text rendering, for example laggy popups menu.
I don’t know about typefaces or text rendering engines, but I think that is because Typeface::createSystemTypefaceFor needs to “compile” every time the ttf file.
Is there a juce way to use custom embed fonts?
Thanks!