Font issue

I’m on Windows7 x64, a call to Font::getDefaultSansSerifFontName() returns “” and Font::getDefaultSerifFontName() returns “”.
If i use the first call when creating a font for the Label::setFont() call i can’t get Italics, if i don’t use the name (just use the size/flags constructor) i can’t get italics.
If i use the getDefaultSerifFontName() to the Font constructor i get Italics.

Also the default header component for a TableListBox looks weird at first (it looks ok after i move it around or move some other components over it, i guess it needs to repaint)

the listBox is created with

addAndMakeVisible (propertyList = new TableListBox (T("Property List"), this));
propertyList->setName (T("propertyList"));

propertyList->getHeader().addColumn (T("Property name"), 1, 200);
propertyList->getHeader().addColumn (T("Value"), 2, 100);

Hey!! I have noticed some strange behavior with fonts and the header / content of list controls!!! There is something definitely weird going on with Juce, the low level graphics renderer, and the font engine…I noticed when I was working on my FreeType faces.

I tried to set the font used by the header Component to bold, and at a different size and sometimes I would see weird stuff like you. This is even after I turned off my custom typeface.

I am 90% certain there is an obscure bug having to do with fonts and the header / list control but of course when I study the code I can see nothing wrong.

yep - read the comments for those functions and it explains why.

Your problems sound like a bug that was in the codebase a week or two ago, but which I fixed (it was basically because the glyph cache was mixing up some of the its glyphs). Are you on the latest version?

Looking at my code (and it’s been a while) I seem to remember that somehow, when I would change attributes of the Graphics passed to my override of LookAndFeel::drawTableHeaderColumn(), sometimes text would draw differently in my TableListBoxModel::paintCell ().

I can’t reproduce any of it sadly but I just thought I would throw this out there.

i’m always at the tip so yes it’s the latest version 1.53.45

and i know the functions should return those values i just wanted to say they do :slight_smile: but the thing is i can’t get the Italic font type to work, i set it in the old Jucer for a label and it’s not italic after i build
that component, that’s the problem. So i guess my question is how do i make the Font (size,flags) font constructor make the default font italic since the Font::italic flag does not work.

also in the TreeView component i use underline flag on the font, i keep two fonts in the class like so

labelFont			= Font(14, Font::plain);
labelUnderlineFont	= labelFont;

and later

void CtrlrLuaEditorBrowserItemComponent::mouseEnter (const MouseEvent& e)
    //[UserCode_mouseEnter] -- Add your code here...
	hookName->setFont (labelUnderlineFont);

void CtrlrLuaEditorBrowserItemComponent::mouseExit (const MouseEvent& e)
    //[UserCode_mouseExit] -- Add your code here...
	hookName->setFont (labelFont);

and set the font to the label depending if the mouse is over or not, but the first time the component is shown it looks like (focus on the luaObject item):
after i move the mouse over it and exit the mouse (should return to it’s original font) it looks like this:

it’s a bit bigger (though it’s the same font and no resize() calls have been made to any component, i just moved the mouse over it),

I really don’t understand what’s going on there - I tried it myself, and the Font::italic flag definitely does work! Perhaps you could give me a few tweaks to the juce demo that make it happen, and I’ll try it?

i can’t really reproduce this in the juce demo, but i don’t know what happens in my code that might affect things, i’ll try to backtrace what has changed in my app, almost all components i use are JUCER generated.

Thanks - give me a shout if you find any clues.

I found the bug ! It kept me busy for the afternoon because it is quite subtle: in the SharedFontInternal::SharedFontInternal (const float height_, const int styleFlags_) constructor, the typeface is initialised with TypefaceCache::getInstance()->getDefaultTypeface() , which is of course wrong when the styleFlags is bold or italic.

Jesus H…no wonder! I was using a bold style on my column header font!

Aha! Thanks very much, I’ll get that fixed pronto!

This is still an issue, by the way.

When I use:
g.setFont(Font(“Arial”, 12, Font::italic));

I get the proper italicized font

… but using…
g.setFont(Font(12, Font::italic));

… I get the shared (non-italicized) version.

Now that I think about it, this wasn’t an issue 6 months ago. Not sure when it crept back in.

Which OS?

I don’t know if this is the same issue, but I’m creating a label in a component using default font, italic. It shows up correctly in Jucer, but when I build my plugin and bring up its editor in GarageBand, the text is non-italic. OSX 10.8.2, “current” Jucer & Introjucer prebuilt binaries, Introjucer-updated modules.

That’s a bit odd. Is it just garageband, or other hosts too?

Also happens in Reaper. I don’t have any other DAWs installed on this machine.


The OSX default font is Lucida Grande, but just having a look at the font, I’m amazed to find that it doesn’t actually have an italic version (!)

I guess I’ll need to add some code to fake-up an italic font using a shear transform if the system doesn’t have one… Will get that sorted out asap.

[quote=“jules”]The OSX default font is Lucida Grande, but just having a look at the font, I’m amazed to find that it doesn’t actually have an italic version (!)

I guess I’ll need to add some code to fake-up an italic font using a shear transform if the system doesn’t have one… Will get that sorted out asap.[/quote]

Why/how does it show italic in Jucer, though? (It does look like a shear, there, rather than a separate style.)

Oh - OSX 10.7