You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts. UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game. The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk. The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI. UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas. [CL 2342203 by Jamie Dale in Main branch]
146 lines
3.7 KiB
C++
146 lines
3.7 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "UMGPrivatePCH.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UMG"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UMultiLineEditableTextBox
|
|
|
|
UMultiLineEditableTextBox::UMultiLineEditableTextBox(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
ForegroundColor = FLinearColor::Black;
|
|
BackgroundColor = FLinearColor::White;
|
|
ReadOnlyForegroundColor = FLinearColor::Black;
|
|
|
|
// HACK Special font initialization hack since there are no font assets yet for slate.
|
|
Font = FSlateFontInfo(TEXT("Slate/Fonts/Roboto-Bold.ttf"), 12);
|
|
|
|
bAutoWrapText = true;
|
|
|
|
SMultiLineEditableTextBox::FArguments Defaults;
|
|
WidgetStyle = *Defaults._Style;
|
|
TextStyle = *Defaults._TextStyle;
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::ReleaseSlateResources(bool bReleaseChildren)
|
|
{
|
|
Super::ReleaseSlateResources(bReleaseChildren);
|
|
|
|
MyEditableTextBlock.Reset();
|
|
}
|
|
|
|
TSharedRef<SWidget> UMultiLineEditableTextBox::RebuildWidget()
|
|
{
|
|
MyEditableTextBlock = SNew(SMultiLineEditableTextBox)
|
|
.Style(&WidgetStyle)
|
|
.TextStyle(&TextStyle)
|
|
.Font(Font)
|
|
.Justification(Justification)
|
|
.ForegroundColor(ForegroundColor)
|
|
.BackgroundColor(BackgroundColor)
|
|
.ReadOnlyForegroundColor(ReadOnlyForegroundColor)
|
|
.AutoWrapText( bAutoWrapText )
|
|
.WrapTextAt( WrapTextAt )
|
|
// .MinDesiredWidth(MinimumDesiredWidth)
|
|
// .Padding(Padding)
|
|
// .IsCaretMovedWhenGainFocus(IsCaretMovedWhenGainFocus)
|
|
// .SelectAllTextWhenFocused(SelectAllTextWhenFocused)
|
|
// .RevertTextOnEscape(RevertTextOnEscape)
|
|
// .ClearKeyboardFocusOnCommit(ClearKeyboardFocusOnCommit)
|
|
// .SelectAllTextOnCommit(SelectAllTextOnCommit)
|
|
// .OnTextChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnTextChanged))
|
|
// .OnTextCommitted(BIND_UOBJECT_DELEGATE(FOnTextCommitted, HandleOnTextCommitted))
|
|
;
|
|
|
|
return MyEditableTextBlock.ToSharedRef();
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::SynchronizeProperties()
|
|
{
|
|
Super::SynchronizeProperties();
|
|
|
|
MyEditableTextBlock->SetText(Text);
|
|
// MyEditableTextBlock->SetHintText(HintText);
|
|
// MyEditableTextBlock->SetIsReadOnly(IsReadOnly);
|
|
// MyEditableTextBlock->SetIsPassword(IsPassword);
|
|
// MyEditableTextBlock->SetColorAndOpacity(ColorAndOpacity);
|
|
|
|
// TODO UMG Complete making all properties settable on SMultiLineEditableTextBox
|
|
}
|
|
|
|
FText UMultiLineEditableTextBox::GetText() const
|
|
{
|
|
if ( MyEditableTextBlock.IsValid() )
|
|
{
|
|
return MyEditableTextBlock->GetText();
|
|
}
|
|
|
|
return Text;
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::SetText(FText InText)
|
|
{
|
|
Text = InText;
|
|
if ( MyEditableTextBlock.IsValid() )
|
|
{
|
|
MyEditableTextBlock->SetText(Text);
|
|
}
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::SetError(FText InError)
|
|
{
|
|
if ( MyEditableTextBlock.IsValid() )
|
|
{
|
|
MyEditableTextBlock->SetError(InError);
|
|
}
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::HandleOnTextChanged(const FText& Text)
|
|
{
|
|
OnTextChanged.Broadcast(Text);
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::HandleOnTextCommitted(const FText& Text, ETextCommit::Type CommitMethod)
|
|
{
|
|
OnTextCommitted.Broadcast(Text, CommitMethod);
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::PostLoad()
|
|
{
|
|
Super::PostLoad();
|
|
|
|
if ( GetLinkerUE4Version() < VER_UE4_DEPRECATE_UMG_STYLE_ASSETS )
|
|
{
|
|
if ( Style_DEPRECATED != nullptr )
|
|
{
|
|
const FEditableTextBoxStyle* StylePtr = Style_DEPRECATED->GetStyle<FEditableTextBoxStyle>();
|
|
if ( StylePtr != nullptr )
|
|
{
|
|
WidgetStyle = *StylePtr;
|
|
}
|
|
|
|
Style_DEPRECATED = nullptr;
|
|
}
|
|
}
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
|
|
const FSlateBrush* UMultiLineEditableTextBox::GetEditorIcon()
|
|
{
|
|
return FUMGStyle::Get().GetBrush("Widget.MultiLineEditableTextBox");
|
|
}
|
|
|
|
const FText UMultiLineEditableTextBox::GetPaletteCategory()
|
|
{
|
|
return LOCTEXT("Input", "Input");
|
|
}
|
|
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|