# AttributedString ignores font.withHorizontalScale()

**URL:** <https://forum.juce.com/t/attributedstring-ignores-font-withhorizontalscale/45178>\
**Category:** General JUCE discussion\
**Created:** [March 24, 2021, 3:03am UTC](https://forum.juce.com/t/attributedstring-ignores-font-withhorizontalscale/45178 "2021-03-24T03:03:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephenk/32/15198_2.png) [@stephenk](https://forum.juce.com/u/stephenk)\
**Post date:** [March 24, 2021, 3:03am UTC](https://forum.juce.com/t/attributedstring-ignores-font-withhorizontalscale/45178/1 "2021-03-24T03:03:02Z")

</div>

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:  
[AttributedStringTest.zip](https://forum.juce.com/uploads/short-url/aiyGdkvbFpxYedSEL0Xnp4AFcmA.zip) (10.3 KB)

![attr](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/2/2599fa7a2f5dcb8b24e34730d879bf90581961a3.png)

Code:

```auto
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);
    
    bounds.translate(0,30);
    juce::TextLayout textLayout;
    textLayout.createLayout (attributedString,
                             (float) bounds.getWidth(),
                             (float) bounds.getHeight());
    textLayout.draw (g, bounds.toFloat());
    
    bounds.translate(0,30);
    g.setFont (juce::Font (16.0f).withHorizontalScale(2.0f));
    g.drawText ("Regular String with horizontal scale 2.0f", bounds, juce::Justification::centred, true);

    bounds.translate(0,30);
    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…

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [March 24, 2021, 2:10pm UTC](https://forum.juce.com/t/attributedstring-ignores-font-withhorizontalscale/45178/2 "2021-03-24T14:10:39Z")

</div>

We’re currently investigating this issue.

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [March 25, 2021, 6:25pm UTC](https://forum.juce.com/t/attributedstring-ignores-font-withhorizontalscale/45178/3 "2021-03-25T18:25:12Z")

</div>

> <https://github.com/juce-framework/JUCE/commit/2367d648f45dc6b37fd1ba3816320bcdc06343de>

Thank you for reporting.

---

<div class="post-metadata">

**Author:** ![stephenk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephenk/32/15198_2.png) [@stephenk](https://forum.juce.com/u/stephenk)\
**Post date:** [March 25, 2021, 11:56pm UTC](https://forum.juce.com/t/attributedstring-ignores-font-withhorizontalscale/45178/4 "2021-03-25T23:56:22Z")

</div>

Awesome, thanks!
