ScrollingFontTemplate doesn't keep the height of the font string container child frame synchronized with the height of the font string text region itself when the frame is either resized or has its font replaced, leading to scenarios where the scrollbox may either have large amounts of blank space surrounding the text or may alternatively clip the text on both ends.
When loaded the addon will create a panel in the centre of the screen with two scrolling font views. The one on the left is the unmodified (default) ScrollingFontTemplate, and the one on the right has a mixin applied which overrides the OnSizeChanged and SetFontObject methods to demonstrate a fix for this issue.
Both font views include debug texture backgrounds - a half-alpha red background is anchored to the FontStringContainer child, and a half-alpha blue background to the FontString itself. When both these child regions overlap you'll get a purple background. The expectation is that you'll mostly only ever see a purple background, indicating both child regions have matching dimensions.
A video demonstrating the issue when resizing can be seen below.
When the test panel is resized such that the text no longer wraps onto two lines, the view on the left doesn't update the height of the container to accommodate the now-smaller fontstring child - as such the red background becomes visible and the scrollable extent end up being too large for the text content, leading to a large blank space before and after the text.
When the text panel is shrunk such that the text wraps to three lines, the view on the left doesn't update the height of the container to accommodate the now-larger fontstring child - as such the blue background becomes visible and the scrollable extent ends up being too small for the text content, leading to clipping of the text.
Additionally, when toggling font size the same issue can be observed in the video below - when the font size is increased the fontstring height increases, but the container doesn't track that and as such ends up with the same clipping issue seen in the previous video.
The OnSizeChanged and SetFontObject methods of ScrollingFontMixin should update the height of the container to match the string height of the fontstring.
diff --git a/Interface/SharedXML/Scroll/ScrollTemplates.lua b/Interface/SharedXML/Scroll/ScrollTemplates.lua
index 9475ec30..134f6121 100644
--- a/Interface/SharedXML/Scroll/ScrollTemplates.lua
+++ b/Interface/SharedXML/Scroll/ScrollTemplates.lua
@@ -261,11 +261,12 @@ function ScrollingFontMixin:OnSizeChanged(width, height)
local scrollBox = self:GetScrollBox();
scrollBox:SetWidth(width);
- local fontStringContainer = self:GetFontStringContainer();
- fontStringContainer:SetWidth(width);
-
local fontString = self:GetFontString();
fontString:SetWidth(width);
+
+ local fontStringContainer = self:GetFontStringContainer();
+ fontStringContainer:SetWidth(width);
+ fontStringContainer:SetHeight(fontString:GetStringHeight());
end
function ScrollingFontMixin:GetScrollBox()
@@ -317,6 +318,9 @@ end
function ScrollingFontMixin:SetFontObject(fontName)
local fontString = self:GetFontString();
fontString:SetFontObject(fontName);
+
+ local fontStringContainer = self:GetFontStringContainer();
+ fontStringContainer:SetHeight(fontString:GetStringHeight());
local scrollBox = self:GetScrollBox();
local fontHeight = select(2, fontString:GetFont());
ScrollingFontTemplate doesn't keep the height of the font string container child frame synchronized with the height of the font string text region itself when the frame is either resized or has its font replaced, leading to scenarios where the scrollbox may either have large amounts of blank space surrounding the text or may alternatively clip the text on both ends.
Test case
A test case addon is provided here: Meorawr_ScrollingFontExtentBug.zip
When loaded the addon will create a panel in the centre of the screen with two scrolling font views. The one on the left is the unmodified (default) ScrollingFontTemplate, and the one on the right has a mixin applied which overrides the OnSizeChanged and SetFontObject methods to demonstrate a fix for this issue.
Both font views include debug texture backgrounds - a half-alpha red background is anchored to the FontStringContainer child, and a half-alpha blue background to the FontString itself. When both these child regions overlap you'll get a purple background. The expectation is that you'll mostly only ever see a purple background, indicating both child regions have matching dimensions.
A video demonstrating the issue when resizing can be seen below.
https://github.com/Stanzilla/WoWUIBugs/assets/287102/97c6f0ae-b0db-49a5-889e-7b27d2ea6a83
Additionally, when toggling font size the same issue can be observed in the video below - when the font size is increased the fontstring height increases, but the container doesn't track that and as such ends up with the same clipping issue seen in the previous video.
https://github.com/Stanzilla/WoWUIBugs/assets/287102/fd0f7740-d322-4ea6-91f1-aaed454201ec
Solution
The OnSizeChanged and SetFontObject methods of ScrollingFontMixin should update the height of the container to match the string height of the fontstring.