Font style disappearing from code (but still shown in projucer Graphics window)


#1

Hi all. Apologies if this has been reported previously but a search did not turn up a previous thread.

I’m encountering a strange problem in the Projucer, using JUCE v5.2.0.

I create a new Text graphical element. I select a font, and then a non-default Style (“heavy” in my case). Everything seems great, the text displays in the correct style, and if I check the code it generates correct code:

ex: …setFont (Font (“Futura PT”, 31.00f, Font::plain).withTypefaceStyle (“Heavy”)

So, I go about my business, Projucing around, and then I go back and see that ".withTypefaceStyle(“Heavy”) has disappeared from the code. And indeed when I build my project the text displays without the Heavy style.

The crazy part is that the Projucer Graphics window still shows the text correctly (rendered as Heavy, and with Heavy selected in the Style drop-down selector when the text is selected).


#2

You can only make modifications to code within the specified comment tags:

void NewComponent::paint (Graphics& g)
{
    //[UserPrePaint] Add your own custom painting code here..
    //[/UserPrePaint]

    g.fillAll (Colours::white);

    g.setColour (Colours::black);
    g.setFont (Font (15.00f, Font::plain));
    g.drawText (TRANS("Your text goes here"),
                168, 304, 200, 30,
                Justification::centred, true);

    //[UserPaint] Add your own custom painting code here..
    //[/UserPaint]
}

The fact that the Projucer is still showing it in Heavy sounds like and edge case bug since if you are editing the code within the auto-generated areas and shouldn’t be.


#3

I guess I wasn’t clear – I’m talking about code that the Projucer is generating automatically. When I create a graphical text element in the Projucer and set it to have a certain font and style, then the Projucer should generate the correct code specifying that font and style.

The bug I am describing is that this Projucer-generated code will not have the .withTypefaceStyle argument, even though the Projucer graphical editor shows that the style is selected and renders the text graphically in the correct style.

More specifically, the Projucer-generated code WILL in fact have the .withTypefaceStyle(“Heavy”) at first… but then when I build the project, that .withTypefaceStyle goes missing, and when I look at the code again it’s no longer there. At some point the Projucer seems to be generating incorrect code that omits the style. Doesn’t always happen and I’m not sure what triggers it.

In my project i switched to using Label subcomponents instead of Graphics Text elements and that seems to be a work-around… I was only having this problem with graphics text.