Fonts demo super-slow


#1

I just installed Windows 7, and I’ve tried the JUCE demo in Release build on it. The fonts demo is super-slow, when I move the scrollbar it takes about 1 second to react. Just wanted to know if that’s normal or not… ?


#2

Could be that the cache is getting flushed with each new font and being forced to regenerate the glyphs needlessly.

Trying calling the new function Jules added to set the size of the type cache to some very large number and see if it helps.


#3

In my version of Juce:

class GlyphCache default is for 120 glyphs (per typeface) in the constructor

juce_LowLevelGraphicsSoftwareRenderer.cpp:

class LowLevelGraphicsSoftwareRenderer::GlyphCache  : private DeletedAtShutdown
{
public:
    GlyphCache()
        : accessCounter (0), hits (0), misses (0)
    {
        addNewGlyphSlots (120);
    }

class TypefaceCache default is to cache 10 typefaces in the constructor.

juce_Font.cpp

class TypefaceCache  : public DeletedAtShutdown
{
public:
    TypefaceCache()
        : counter (0)
    {
        setSize (10);
    }

TypefaceCache is a singleton so modify the Juce demo at startup to call

TypefaceCache::getInstance()->setSize (1000);

(I’m not 100% sure my syntax is right for that last statement)

See if that helps. If not, chance class GlyphCache constructor to 256 glyphs.

If you are still having problems, maybe you are using Direct2D instead or otherwise bypassing the software renderer because of your build settings?


#4

I see this as well on Windows 7 so it’s not just you.
I’m pretty sure TheVinn is on the mark. Each font is not going to be in the glyph cache so for every line in that list box, JUCE has to get the outlines from the font file, create the paths and render them. The cache is going to fill up fast and become useless since there is barely any glyph reuse.

I wouldn’t be surprised if you saw this slowness on XP and when using the software renderer on Mac OS X.
The Direct2D renderer is still incomplete last time I check so I doubt that is cause.


#5

No, on XP it’s very fast. I don’t feel any lag when moving the scrollbar there (at least not with the JUCE152 release build, maybe something changed in 153, but that seems unlikely to make such a difference).
I want to add that with Windows 7 everything is slower : Same machine, JUCE Compile time: 2-3 higher than on XP, I think they added some brakes here and there so the PC market still has a reason to exist :wink:


#6

Or maybe on XP you just have fewer fonts. Did you try my changes?


#7

No I didn’t try your changes, because obviously it is something else that is the problem here, since the same original JUCE code works well on XP but not on Win 7.