AttributedString ignores font.withHorizontalScale()

I’d really like to know if this is intended behaviour, because if so I can’t use AttributedStrings in various components, because I want to set font.withHorizontalScale() slightly on my main font.

Vanilla JUCE GUI App, Mac OSX Mojave, Juce 6.0.8 (problem exists before this however):

Project download: (10.3 KB)



void MainComponent::paint (juce::Graphics& g)
    g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));

    auto bounds = getLocalBounds().withHeight(30);

    g.setFont (juce::Font (16.0f));
    g.setColour (juce::Colours::white);
    g.drawText ("Regular String", bounds, juce::Justification::centred, true);
    juce::AttributedString attributedString { "Attributed String" };
    attributedString.setColour (juce::Colours::white);
    attributedString.setFont (juce::Font (16.0f));
    attributedString.setJustification (juce::Justification::centred);
    attributedString.setWordWrap (juce::AttributedString::WordWrap::none);
    juce::TextLayout textLayout;
    textLayout.createLayout (attributedString,
                             (float) bounds.getWidth(),
                             (float) bounds.getHeight());
    textLayout.draw (g, bounds.toFloat());
    g.setFont (juce::Font (16.0f).withHorizontalScale(2.0f));
    g.drawText ("Regular String with horizontal scale 2.0f", bounds, juce::Justification::centred, true);

    attributedString.setText("Attributed String with horizontal scale 2.0f");
    attributedString.setFont (juce::Font (16.0f).withHorizontalScale(2.0f));
    textLayout.createLayout (attributedString,
                             (float) bounds.getWidth(),
                             (float) bounds.getHeight());
    textLayout.draw (g, bounds.toFloat());

It seems recent JUCE programming is using AttributedString in more places, such as the AudioMIDI dialog list boxes (changed in Juce 6.0.8 to use AttributedString instead of g.drawText()) - which changes what I had going on there…

We’re currently investigating this issue.

Thank you for reporting.

1 Like

Awesome, thanks!