After exploring alittle into a problem of UMG Combobox’es not having a Font selection, I decide to fix this. And made a UE patch.
diff --git a/Engine/Source/Runtime/SlateCore/Public/Styling/SlateTypes.h b/Engine/Source/Runtime/SlateCore/Public/Styling/SlateTypes.h
index 3ba2b20..5fbe517 100644
--- a/Engine/Source/Runtime/SlateCore/Public/Styling/SlateTypes.h
+++ b/Engine/Source/Runtime/SlateCore/Public/Styling/SlateTypes.h
@@ -424,6 +424,17 @@ struct SLATECORE_API FComboBoxStyle : public FSlateWidgetStyle
UPROPERTY()
FName SelectionChangeSound_DEPRECATED;
+ /** Font family and size to be used when displaying this text. */
+ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Appearance)
+ FSlateFontInfo Font;
+ FComboBoxStyle& SetFont(const FSlateFontInfo& InFont) { Font = InFont; return *this; }
+ FComboBoxStyle& SetFont(const FName& InFontName, uint16 InSize) { Font = FSlateFontInfo(InFontName, InSize); return *this; }
+
+ /** The foreground color of text. */
+ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Appearance)
+ FSlateColor ForegroundColor;
+ FComboBoxStyle& SetForegroundColor(const FSlateColor& InForegroundColor) { ForegroundColor = InForegroundColor; return *this; }
+
/**
* Used to upgrade the deprecated FName sound properties into the new-style FSlateSound properties
*/
diff --git a/Engine/Source/Runtime/UMG/Private/Components/ComboBoxString.cpp b/Engine/Source/Runtime/UMG/Private/Components/ComboBoxString.cpp
index 4a906f5..f2204e1 100644
--- a/Engine/Source/Runtime/UMG/Private/Components/ComboBoxString.cpp
+++ b/Engine/Source/Runtime/UMG/Private/Components/ComboBoxString.cpp
@@ -60,11 +60,11 @@ TSharedRef<SWidget> UComboBoxString::RebuildWidget()
SAssignNew(ComoboBoxContent, SBox)
];
- if ( InitialIndex != -1 )
- {
+ //if ( InitialIndex != -1 )
+ //{ // This is needed to recreate amty combobox field with properly set up fonts
// Generate the widget for the initially selected widget if needed
ComoboBoxContent->SetContent(HandleGenerateWidget(CurrentOptionPtr));
- }
+ //}
return MyComboBox.ToSharedRef();
}
@@ -204,7 +204,7 @@ TSharedRef<SWidget> UComboBoxString::HandleGenerateWidget(TSharedPtr<FString> It
}
// If a row wasn't generated just create the default one, a simple text block of the item's name.
- return SNew(STextBlock).Text(FText::FromString(StringItem));
+ return SNew(STextBlock).Font(WidgetStyle.Font).ColorAndOpacity(WidgetStyle.ForegroundColor).Text(FText::FromString(StringItem));
}
void UComboBoxString::HandleSelectionChanged(TSharedPtr<FString> Item, ESelectInfo::Type SelectionType)
diff --git a/Treadwater b/Treadwater
--- a/Treadwater
+++ b/Treadwater
@@ -1 +1 @@
-Subproject commit 258dfad463a1a37a013de07e620f9c0c6179a914
+Subproject commit 258dfad463a1a37a013de07e620f9c0c6179a914-dirty
Yes, it is actually not a bug report, but i’ve seen many people ask here for font option in combobox, so I share my solution.