Long text doesn't fit into scale box

I’m currently trying to archive something like a termnial monitor.

For that I have a TextBlock representing the whole terminal. That text contains exactly as much Lines as the “terminal height” and each line is filled with white space to fill the “terminal width”. I also use a mono space font so the cordinates wont misalign after some time.

This TextBlock now sits in a Scale Box so I can handle any kind of terminal size and aspect ratios.

The problem now is, when i display that text, it still clips a little bit on each edge.

More weird is though, in the editor, this changed depending on how much you zoom. The text size relative to the block size changes depending on the zoom. How much looks like random. Sometimes it clips, sometimes it fits and sometimes there is a lot of spacing.

If you have more characters in one line to display the difference is more visible.

I also now checked that with a text block in a size box with overrriden width. If i decrease the font scale and again display a lot of text… the actual drawn text width again changes depending on the zoom.

I mean, that is not a problem since word wrapping still looks just fine but in a scale box, were the desired size then probably is just wrong, this is problem.

It might just how i in the end used it, but it looks to me like a bug in engine or something else.

To reproduce (UMG or Slate, same behaviour):

  • Create a SizeBox, override the width with a given value.
  • Insert a ScaleBox.
  • Insert a TextBlock
  • add one line with a lot of characters to the text of the textblock
  • done (now zoom in editor or change the size of the size box to see the weird text width/scale changes)

Scale with unecessery space:

Scale with clipping (note the missing “block”, yes it is in the text field, and yes word wrapping is off):

I also noticed that this happens with, as far as I tested, every Text rendering widget.

I would very appretiate any information about possible fixes without engine changes, but they are also okay if there is realy no other way.

FVector2D STextBlock::ComputeDesiredSize(float LayoutScaleMultiplier) const

	if (bSimpleTextMode)
		const FVector2D LocalShadowOffset = GetShadowOffset();

		const float LocalOutlineSize = GetFont().OutlineSettings.OutlineSize;

		// Account for the outline width impacting both size of the text by multiplying by 2
		// Outline size in Y is accounted for in MaxHeight calculation in Measure()
		const FVector2D ComputedOutlineSize(LocalOutlineSize * 2, LocalOutlineSize);
		const FVector2D TextSize = FSlateApplication::Get().GetRenderer()->GetFontMeasureService()->Measure(GetText(), GetFont()) + ComputedOutlineSize + LocalShadowOffset;

		CachedSimpleDesiredSize = FVector2D(FMath::Max(MinDesiredWidth.Get(0.0f), TextSize.X), TextSize.Y);
		return CachedSimpleDesiredSize.GetValue();
		// ComputeDesiredSize will also update the text layout cache if required
		const FVector2D TextSize = TextLayoutCache->ComputeDesiredSize(
			FSlateTextBlockLayout::FWidgetArgs(BoundText, HighlightText, WrapTextAt, AutoWrapText, WrappingPolicy, Margin, LineHeightPercentage, Justification),
			LayoutScaleMultiplier, GetComputedTextStyle()

		// [XXX] Layout의 최소 너비값을 구한다.
	float MinDesiredSizeX = MinDesiredWidth.Get(0.0F) > 0.0F || isinf(GetDesiredSize().X) ? MinDesiredWidth.Get(0.0F) : GetDesiredSize().X;
	return FVector2D(FMath::Max(MinDesiredSizeX, TextSize.X), TextSize.Y);

I modified MinDesriedWidth to DesiredSize().X as temporary expedient.

mutable TAttribute MinDesiredWidth;

return FVector2D(FMath::Max(MinDesiredWidth.Get(0.0F), TextSize.X), TextSize.Y);

I just stumbled across the same issue as the OP. Is there any fix for that or and idea how to fix it?