From 283ea129585e406e405e55c79e06cf60663369a3 Mon Sep 17 00:00:00 2001 From: attila Date: Mon, 12 May 2025 18:14:51 +0200 Subject: [PATCH] Fix addFittedText overflowing the bounds when line spacing and height multiple is non-default --- modules/juce_graphics/fonts/juce_GlyphArrangement.cpp | 5 ++++- modules/juce_graphics/fonts/juce_GlyphArrangement.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp index 94f38550bc..6bf8572a0f 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp @@ -336,7 +336,10 @@ static auto createFittedText (const Font& f, while (numLines < maximumLines) { ++numLines; - auto newFontHeight = height / (float) numLines; + + const auto a = baseOptions.getAdditiveLineSpacing(); + auto newFontHeight = ((height + a) / (float) numLines - a) + / baseOptions.getLeading(); if (newFontHeight < font.getHeight()) font.setHeight (jmax (8.0f, newFontHeight)); diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.h b/modules/juce_graphics/fonts/juce_GlyphArrangement.h index 8d7e7476dc..07c1a1b02a 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.h +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.h @@ -125,6 +125,8 @@ private: class JUCE_API GlyphArrangement final { public: + using Options = GlyphArrangementOptions; + //============================================================================== /** Creates an empty arrangement. */ GlyphArrangement();