x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

4.16 Slate FTextBox text cut off

Hi Epic,

since 4.16 every text is cut off from above, no matter what i try (padding, margin).

Product Version: UE 4.16
Tags:
more ▼

asked May 29 '17 at 10:30 PM in C++ Programming

avatar image

5v29n
61 12 15 20

avatar image Jamie Dale STAFF May 30 '17 at 12:45 AM

Font? Screenshot?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey Jamie,

with 4.16 i also switched to vs17 just for your info.

This is the construct code of my main menu:

 BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
 void SMTMainWidget::Construct(const FArguments& InArgs)
 {
     MTHUD = InArgs._MTHUD;
     UIScale.Bind(this, &SMTMainWidget::GetUIScale);
     MTGame = Cast<AMTGameMode>(MTHUD->GetWorld()->GetAuthGameMode());
 
     ChildSlot
     .HAlign(HAlign_Fill)
     .VAlign(VAlign_Fill)
     [
         SNew(SDPIScaler)
         .DPIScale(UIScale)
         [
             SNew(SOverlay)
             + SOverlay::Slot()
             .HAlign(HAlign_Fill)
             .VAlign(VAlign_Fill)
             [
                 SNew(SOverlay)// Stage selection
                 .Visibility(this, &SMTMainWidget::GetStageSelectedMenuVisibility)
                 + SOverlay::Slot()
                 .VAlign(VAlign_Fill)
                 .HAlign(HAlign_Fill)
                 [
                     SNew(SBox)
                     .HAlign(HAlign_Center)
                     .VAlign(VAlign_Center)
                     [
                         SNew(SCanvas)
                         + SCanvas::Slot()
                         .HAlign(HAlign_Center)
                         .VAlign(VAlign_Center)
                         .Size(FVector2D(192.0f, 192.0f))
                         .Position(FVector2D(-512.0f, 0.0f))
                         [
                             SNew(SButton)
                             .HAlign(HAlign_Center)
                             .VAlign(VAlign_Center)
                             .OnClicked(this, &SMTMainWidget::Prev)
                             [
                                 SNew(STextBlock)
                                 .Font(FSlateFontInfo("Arial", 96))
                                 .ColorAndOpacity(FLinearColor(255.0f, 255.0f, 0.0f, 1.0f))
                                 .ShadowColorAndOpacity(FLinearColor(0.0f, 0.0f, 0.0f, 0.5f))
                                 .ShadowOffset(FVector2D(4, 4))
                                 .Text(FText::FromString("<"))
                             ]
                         ]
                         + SCanvas::Slot()
                         .HAlign(HAlign_Center)
                         .VAlign(VAlign_Center)
                         .Position(FVector2D(0.0f, 0.0f))
                         .Size(FVector2D(512.0f, 192.0f))
                         [
                             SNew(SButton)
                             .HAlign(HAlign_Center)
                             .VAlign(VAlign_Center)
                             .OnClicked(this, &SMTMainWidget::StartStage)
                             [
                                 SNew(STextBlock)
                                 .Font(FSlateFontInfo("Arial", 96))
                                 .ColorAndOpacity(FLinearColor(255.0f, 255.0f, 0.0f, 1.0f))
                                 .ShadowColorAndOpacity(FLinearColor(0.0f, 0.0f, 0.0f, 0.5f))
                                 .ShadowOffset(FVector2D(4, 4))
                                 .Text(this, &SMTMainWidget::GetStageSelected)
                             ]
                         ]
                         + SCanvas::Slot()
                         .HAlign(HAlign_Center)
                         .VAlign(VAlign_Center)
                         .Position(FVector2D(512.0f, 0.0f))
                         .Size(FVector2D(192.0f, 192.0f))
                         [
                             SNew(SButton)
                             .HAlign(HAlign_Center)
                             .VAlign(VAlign_Center)
                             .OnClicked(this, &SMTMainWidget::Next)
                             [
                                 SNew(STextBlock)
                                 .Font(FSlateFontInfo("Arial", 96))
                                 .ColorAndOpacity(FLinearColor(255.0f, 255.0f, 0.0f, 1.0f))
                                 .ShadowColorAndOpacity(FLinearColor(0.0f, 0.0f, 0.0f, 0.5f))
                                 .ShadowOffset(FVector2D(4, 4))
                                 .Text(FText::FromString(">"))
                             ]
                         ]
                     ]
                 ]
             ]
             + SOverlay::Slot()// Pause button
             .HAlign(HAlign_Fill)
             .VAlign(VAlign_Fill)
             [
                 SNew(SOverlay)
                 .Visibility(this, &SMTMainWidget::GetPauseButtonVisibility)
                 +SOverlay::Slot()
                 .HAlign(HAlign_Fill)
                 .VAlign(VAlign_Fill)
                 [
                     SNew(SCanvas)
                     + SCanvas::Slot()
                     .HAlign(HAlign_Left)
                     .VAlign(VAlign_Top)
                     .Position(FVector2D(64.0f, 64.0f))
                     .Size(FVector2D(160.0f, 160.0f))
                     [
                         SNew(SButton)
                         .HAlign(HAlign_Fill)
                         .VAlign(VAlign_Fill)
                         .OnClicked(this, &SMTMainWidget::PauseMatch)
                         [
                             SNew(STextBlock)
                             .Margin(70) <-------------------------- i added this for testing but i'm not used to it (how do i set margin for e.g. left only ?)
                             .Font(FSlateFontInfo("Arial", 64))
                             .ColorAndOpacity(FLinearColor(255.0f, 255.0f, 0.0f, 1.0f))
                             .ShadowColorAndOpacity(FLinearColor(0.0f, 0.0f, 0.0f, 0.5f))
                             .ShadowOffset(FVector2D(4, 4))
                             .Text(FText::FromString("||"))
                         ]
                     ]
                 ]
             ]
             + SOverlay::Slot()// Pause menu
             .HAlign(HAlign_Fill)
             .VAlign(VAlign_Fill)
             [
                 SNew(SBox)
                 .Visibility(this, &SMTMainWidget::GetPauseMenuVisibility)
                 .HAlign(HAlign_Center)
                 .VAlign(VAlign_Center)
                 [
                     SNew(SCanvas)
                     + SCanvas::Slot()// Continue button
                     .HAlign(HAlign_Center)
                     .VAlign(VAlign_Center)
                     .Position(FVector2D(0.0f, 0.0f))
                     .Size(FVector2D(512.0f, 192.0f))
                     [
                         SNew(SButton)
                         .Visibility(this, &SMTMainWidget::GetContinueButtonVisibility)
                         .HAlign(HAlign_Center)
                         .VAlign(VAlign_Center)
                         .OnClicked(this, &SMTMainWidget::ContinueStage)
                         [
                             SNew(STextBlock)
                             .Font(FSlateFontInfo("Arial", 64))
                             .ColorAndOpacity(FLinearColor(255.0f, 255.0f, 0.0f, 1.0f))
                             .ShadowColorAndOpacity(FLinearColor(0.0f, 0.0f, 0.0f, 0.5f))
                             .ShadowOffset(FVector2D(4, 4))
                             .Text(FText::FromString("Continue"))
                         ]
                     ]
                     + SCanvas::Slot()// Main menu (abort match) button
                     .HAlign(HAlign_Center)
                     .VAlign(VAlign_Center)
                     .Position(FVector2D(0.0f, 240.0f))
                     .Size(FVector2D(512.0f, 192.0f))
                     [
                         SNew(SButton)
                         .HAlign(HAlign_Center)
                         .VAlign(VAlign_Center)
                         .OnClicked(this, &SMTMainWidget::AbortMatch)
                         [
                             SNew(STextBlock)
                             .Font(FSlateFontInfo("Arial", 64))
                             .ColorAndOpacity(FLinearColor(255.0f, 255.0f, 0.0f, 1.0f))
                             .ShadowColorAndOpacity(FLinearColor(0.0f, 0.0f, 0.0f, 0.5f))
                             .ShadowOffset(FVector2D(4, 4))
                             .Text(FText::FromString("Main Menu"))
                         ]
                     ]
                 ]
             ]
         ]
     ];
 }
 END_SLATE_FUNCTION_BUILD_OPTIMIZATION

In 4.15 everything was as expected, but with the switch to 4.16 the texts were offset. (I'm just learning slate, so i will appreciate any critics)

Result:

alt text

I have no experience with style so far, so i'm getting FSlateFontInfo warnings as expected, if that is, what you mean with "Font?". ;)

thx

[I only was able to post it as answer, because for comments i had -3xxx characters left]

more ▼

answered May 30 '17 at 09:31 AM

avatar image

5v29n
61 12 15 20

avatar image Jamie Dale STAFF May 30 '17 at 01:34 PM

Ah, I see your issue.

 FSlateFontInfo("Arial", 96)

That is not the correct way to specify a font for Slate. It needs a path to a TTF or OTF file, not just the name of your system font, eg)

 FSlateFontInfo(FPaths::GameContentDir() / TEXT("Fonts/MyFont.ttf"), 96)

As it stands you've been relying on our fallback fonts, and I did recently fix a bug where the fallback fonts would report a height of 0 which caused the issue you're seeing.

avatar image 5v29n Jun 01 '17 at 08:37 AM

Somehow i knew it would be this, but i can't verify it at the moment. In my attempt to transition to 4.16 i've encountered some problems, but i will let you know, when i can test it.

thx

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question