Hi Epic,
since 4.16 every text is cut off from above, no matter what i try (padding, margin).
Hi Epic,
since 4.16 every text is cut off from above, no matter what i try (padding, margin).
Font? Screenshot?
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:
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]
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.
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