Fonts being displayed weird when using LookAndFeel::setDefaultSansSerifTypefaceName


#1

Using the latest tip, and Windows 8.1

Go to WidgetsDemo.cpp:463, and add the line:

getLookAndFeel().setDefaultSansSerifTypefaceName("Segoe UI");

Now launch the demo and go to the widgets page.

Open the Look-and-feel menu in the menubar and behold:

 

Notice 1: Setting the same line at MainDemoWindow.cpp:42 (just at the end of the ContentComp Ctor) prevents this issue and displays the fonts just fine.

Notice 2: In my application the distortion is a little different. The fonts are generally skinnier and the bold letters are corrupted:


#2

 

i know that if a glyph isnt present in the selected font, it will fallback to a default font. The "weirdness" is consistent across characters?

 

 


#3

That's pretty bizarre. There's certainly something a bit unusual about that font, but can't see why the characters are inconsistent..


#4

Well, this is the default, Microsoft font for Windows Vista, 7 and 8 (also Windows Phone).

And I'm not sure it has anything to do with the font. I'm guessing it's somehow related to Juce changing fonts after already rendering another font.

Here's how JuceDemo looks when you put the setDefault(...) line in the ContentComp Ctor. It looks perfectly fine.

 

Edit: This also happens with the super-popular free font, Open Sans:

http://www.google.com/fonts/#UsePlace:use/Collection:Open+Sans


#5

Ok, I had a look at this. The problem is because you're switching the default font while the program's already running. There's a cache which stores recently-used glyphs, and that will already contain cached versions of characters from the old font that had been drawn before you changed it. Because the default font uses a special symbolic name rather than a typeface name, the cache doesn't realise that it's different, so the old characters still get used for a while. Easy enough to fix, I'll just make sure it flushes the cache when you set the global font!


#6

Did the trick, thanks.

I posted a new discussion about a request regarding default font typeface style.