Sizing widgets in verse

I’m converting my widget blueprint to verse so that I can change its values with devices. I use size boxes to scale my text widgets currently:
widget_h
I don’t see a size box, so is there another way I can make my text blocks have a certain size?

1 Like

You should be able to set the width and height of a button, but changing the font size is not possible yet

I reread my post and i am not explaining well at all, sorry about that. Im trying to make my text force itself to be a certain size like it is in the widget blueprint (which has SizeBoxes), but without a size box im not sure how i can do that. heres my current UI in verse.

It’s been a year and i still don’t see any option to change a text_block’s font size. Am I missing something?

Nope, sadly theres still no way to change the font size. . .

2 Likes

This needs to be added. Please add Font size to Verse API reference page for the text_base class | Fortnite Documentation | Epic Developer Community

1 Like

A proper size_box widget has not been added as of July 2025, but you can use a workaround:

  1. Use an overlay widget and put a text_block and a color_block inside it.
  2. Have your text_block fill both horizontal and vertical
  3. Set the DefaultDesiredSize component of the color_block widget to whatever you need
  4. Set DefaultOpacity to 0.0 to make it inivisible

Here is a little example:

Widget := overlay:
  Slots := array:

    overlay_slot:
      HorizontalAlignment := horizontal_alignment.Center
      VerticalAlignment := vertical_alignment.Center
      Widget := color_block:
        DefaultOpacity := 0.0
        DefaultDesiredSize := vector2{X:=32.0, Y:=60.0}

    overlay_slot:
      HorizontalAlignment := horizontal_alignment.Fill
      VerticalAlignment := vertical_alignment.Fill
      Widget := NameTextBlock
2 Likes

(post deleted by author)

I tried that out and couldn’t get it to work. The text overflowed the color block, and then the overlay sized to the text (since it was the largest slot). The text size was unchanged from its original. Am I missing something?

using { /Fortnite.com/UI }
using { /Verse.org/Colors }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }

text_widget := class()
{
    var fontHeight<private>: float = 12.0
    var lineWidth<private>: float = 200.0
    var textBlock<private>: text_block = text_block{}
    var maybeWidget<private>: ?widget = false

    Create(InText: string, InFontHeight: float, InLineWidth: float):void=
    {
        set fontHeight = InFontHeight
        set lineWidth = InLineWidth

        set textBlock = text_block
        {
            DefaultText := StringToMessage(InText),
            DefaultTextColor := NamedColors.White,
            DefaultShadowColor := NamedColors.Black,
            DefaultShadowOffset := option{vector2{X := 1.0, Y := 1.0}},
            DefaultTextOpacity := 1.0,
            DefaultShadowOpacity := 0.8
        }

        TheOverlay := overlay {

            Slots := array {

                overlay_slot{
                    HorizontalAlignment := horizontal_alignment.Center,
                    VerticalAlignment := vertical_alignment.Center,
                    Widget := color_block
                    {
                        DefaultColor := NamedColors.Red,
                        DefaultOpacity := 1.0,
                        DefaultDesiredSize := vector2{X:=lineWidth, Y:=fontHeight}
                    }
                },

                overlay_slot
                {
                    HorizontalAlignment := horizontal_alignment.Fill,
                    VerticalAlignment := vertical_alignment.Fill,
                    Widget := textBlock
                }
            }
        }
        
        set maybeWidget = option{TheOverlay}
    }

    GetWidget<public>()<transacts>:?widget=
    {
        maybeWidget
    }

    SetText(InText: string):void=
    {
        textBlock.SetText(StringToMessage(InText))
    }
}

Hi, I think you misunderstood this post. This is not about setting the font size of a text, this is a workaround to use a size box in verse (which is currently only available in widget blueprints), like using a rock if you don’t have a hammer.

In this case, a size box is being used to determine the minimum height of a text block, which means that if its text has less lines than intended, the space available will remain the same. This is useful because there is no way to set a minimum desired height for a text block

Currently there’s no way to set text’s font size of a text_block created in verse.

Oh, okay. Thanks for explaining. I was thinking you figured out a way to scale the text. :man_facepalming: :slight_smile:

1 Like