# LookAndFeel\_V2::getTextButtonFont

**URL:** <https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951>\
**Category:** General JUCE discussion\
**Created:** [June 3, 2014, 11:44pm UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951 "2014-06-03T23:44:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [June 3, 2014, 11:44pm UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951/1 "2014-06-03T23:44:24Z")

</div>

Before we could return the actual font of the TextButton but now it returns a new (default) Font set to the correct size… what happens if the font was not the default? (Since TextButton::getFont() is now private).

Rail

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 4, 2014, 8:24am UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951/2 "2014-06-04T08:24:30Z")

</div>

Sorry, I don't understand the question..? Surely you can override the L+F method to return any font or size you like?

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [June 4, 2014, 9:01am UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951/3 "2014-06-04T09:01:49Z")

</div>

Well my L&F used to have:

```auto
Font CToggleButtonLookAndFeel::getTextButtonFont (TextButton& button)
{
    Font f;

    f = button.getFont();

    f.setHeight (11.0f);

    return f;
}
```

but in the new tip TextButton::getFont() is private and you have replaced it with

```auto
Font LookAndFeel_V2::getTextButtonFont (TextButton&, int buttonHeight)
{
    return Font (jmin (15.0f, buttonHeight * 0.6f));
}
```

I would have thought it should be:

```auto
Font LookAndFeel_V2::getTextButtonFont (TextButton& button, int buttonHeight)
{
    Font f;

    f = button.getFont();

    f.setHeight (jmin (15.0f, buttonHeight * 0.6f));

    return f;
}
```

It just seems that getTextButtonFont() isn’t really returning the true TextButton font… say the TextButton font was changed to a different typeface before calling getTextButtonFont() it’ll return the wrong font.

This doesn’t affect my code, but it just struck me as “not right”…

Best,

Rail

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 4, 2014, 9:03am UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951/4 "2014-06-04T09:03:24Z")

</div>

Huh? Sorry, I don't understand..

I _removed_&nbsp;the TextButton::getFont() method.&nbsp;It no longer exists. That L+F method is now the only place where the font is defined, so it has&nbsp;complete control over the one that will be used.

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [June 4, 2014, 9:24am UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951/5 "2014-06-04T09:24:56Z")

</div>

Okay, I see what you’ve done… I was thinking the font was still a member of TextButton.

Cheers,

Rail

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [June 26, 2014, 1:13pm UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951/6 "2014-06-26T13:13:57Z")

</div>

While I can understand the logic, it's sometimes interresting to overide&nbsp;per instance some values.

Font is something that you may want to change on per Button basis and you don't want to have a custom LnF just for this as this is quite painful especially as the LnF is not referenced counted so you need to handle its lifetime.

I would'nt mind if you could reverse this.

LnF is great, but for the same reason that you allow colours to be defined on the component itself, I find that forcing some minor customization&nbsp;to be only possible&nbsp;in the L&F to be counter productive

&nbsp;

Thanks !

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 28, 2014, 2:45pm UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951/7 "2014-06-28T14:45:53Z")

</div>

What you're asking for would be a similar system&nbsp;to the way colours are handled,&nbsp;which works fine but would be a bit tricky&nbsp;to extend to fonts. If I was to add this, I certainly wouldn't just add it for this particular class, it'd need to be something that was more generally used, like the colour IDs are -&nbsp;but it'd take&nbsp;a lot of thinking about to implement it correctly, and wouldn't be a priority for me at the moment.

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [June 30, 2014, 7:36am UTC](https://forum.juce.com/t/lookandfeel-v2-gettextbuttonfont/12951/8 "2014-06-30T07:36:11Z")

</div>

Yep a bit indeed. I'll go the hard way in the meantime.

&nbsp;

Thanks !
