Add fallback settings to CSharp
This commit is contained in:
@@ -39,7 +39,7 @@ namespace FlaxEditor.Content.Create
|
||||
AnchorPreset = AnchorPresets.HorizontalStretchTop,
|
||||
Offsets = new Margin(0, 0, 0, 40),
|
||||
Parent = this,
|
||||
Font = new MultiFontReference(Style.Current.FontTitle)
|
||||
Font = new FontReference(Style.Current.FontTitle)
|
||||
};
|
||||
var infoLabel = new Label
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace FlaxEditor.Content.Import
|
||||
AnchorPreset = AnchorPresets.HorizontalStretchTop,
|
||||
Offsets = new Margin(0, 0, 0, 40),
|
||||
Parent = this,
|
||||
Font = new MultiFontReference(Style.Current.FontTitle)
|
||||
Font = new FontReference(Style.Current.FontTitle)
|
||||
};
|
||||
var infoLabel = new Label
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
// Title
|
||||
var title = new Label(2, 2, width - 4, 23.0f)
|
||||
{
|
||||
Font = new MultiFontReference(FlaxEngine.GUI.Style.Current.FontLarge),
|
||||
Font = new FontReference(FlaxEngine.GUI.Style.Current.FontLarge),
|
||||
Text = "Ragdoll Options",
|
||||
Parent = this
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
|
||||
// Add script button
|
||||
var buttonText = "Add script";
|
||||
var textSize = Style.Current.FontMedium.MeasureText(buttonText);
|
||||
var textSize = Render2D.MeasureText(Style.Current.FontMedium, buttonText);
|
||||
float addScriptButtonWidth = (textSize.X < 60.0f) ? 60.0f : textSize.X + 4;
|
||||
var buttonHeight = (textSize.Y < 18) ? 18 : textSize.Y + 4;
|
||||
_addScriptsButton = new Button
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
// Title
|
||||
var title = new Label(2, 2, DialogWidth - 4, TitleHeight)
|
||||
{
|
||||
Font = new MultiFontReference(style.FontLarge),
|
||||
Font = new FontReference(style.FontLarge),
|
||||
Text = "Anchor Presets",
|
||||
Parent = this
|
||||
};
|
||||
@@ -247,7 +247,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
// Info
|
||||
var info = new Label(0, title.Bottom, DialogWidth, InfoHeight)
|
||||
{
|
||||
Font = new MultiFontReference(style.FontSmall),
|
||||
Font = new FontReference(style.FontSmall),
|
||||
Text = "Shift: also set bounds\nControl: also set pivot",
|
||||
Parent = this
|
||||
};
|
||||
@@ -423,7 +423,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
// Set control type button
|
||||
var space = layout.Space(20);
|
||||
var buttonText = "Set Type";
|
||||
var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(buttonText);
|
||||
var textSize = Render2D.MeasureText(FlaxEngine.GUI.Style.Current.FontMedium, buttonText);
|
||||
float setTypeButtonWidth = (textSize.X < 60.0f) ? 60.0f : textSize.X + 4;
|
||||
var setTypeButton = new Button
|
||||
{
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
_linkButton.Clicked += ToggleLink;
|
||||
ToggleEnabled();
|
||||
SetLinkStyle();
|
||||
var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
|
||||
var textSize = Render2D.MeasureText(FlaxEngine.GUI.Style.Current.FontMedium, LinkedLabel.Text.Value);
|
||||
_linkButton.LocalX += textSize.X + 10;
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
|
||||
@@ -631,7 +631,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
TooltipText = "Edit...",
|
||||
Parent = _label,
|
||||
};
|
||||
var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(buttonText);
|
||||
var textSize = Render2D.MeasureText(FlaxEngine.GUI.Style.Current.FontMedium, buttonText);
|
||||
if (textSize.Y > button.Width)
|
||||
button.Width = textSize.Y + 2;
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace FlaxEditor.CustomEditors
|
||||
public LabelElement Header(string text)
|
||||
{
|
||||
var element = Label(text);
|
||||
element.Label.Font = new MultiFontReference(Style.Current.FontLarge);
|
||||
element.Label.Font = new FontReference(Style.Current.FontLarge);
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace FlaxEditor.CustomEditors
|
||||
{
|
||||
var element = Header(header.Text);
|
||||
if (header.FontSize != -1)
|
||||
element.Label.Font = new MultiFontReference(element.Label.Font, header.FontSize);
|
||||
element.Label.Font = new FontReference(element.Label.Font.Font, header.FontSize);
|
||||
if (header.Color != 0)
|
||||
element.Label.TextColor = Color.FromRGBA(header.Color);
|
||||
return element;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace FlaxEditor.GUI
|
||||
/// <summary>
|
||||
/// The title font.
|
||||
/// </summary>
|
||||
public MultiFont TitleFont;
|
||||
public Font TitleFont;
|
||||
|
||||
/// <summary>
|
||||
/// The column title text color.
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace FlaxEditor.GUI
|
||||
/// Gets or sets the font used to draw text.
|
||||
/// </summary>
|
||||
[EditorDisplay("Style"), EditorOrder(2000)]
|
||||
public MultiFontReference Font { get; set; }
|
||||
public FontReference Font { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the text.
|
||||
@@ -273,7 +273,7 @@ namespace FlaxEditor.GUI
|
||||
MaximumItemsInViewCount = 20;
|
||||
|
||||
var style = Style.Current;
|
||||
Font = new MultiFontReference(style.FontMedium);
|
||||
Font = new FontReference(style.FontMedium);
|
||||
TextColor = style.Foreground;
|
||||
BackgroundColor = style.BackgroundNormal;
|
||||
BackgroundColorHighlighted = BackgroundColor;
|
||||
@@ -554,7 +554,7 @@ namespace FlaxEditor.GUI
|
||||
var textRect = new Rectangle(margin, 0, clientRect.Width - boxSize - 2.0f * margin, clientRect.Height);
|
||||
Render2D.PushClip(textRect);
|
||||
var textColor = TextColor;
|
||||
Render2D.DrawText(Font.GetMultiFont(), text, textRect, enabled ? textColor : textColor * 0.5f, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, textScale);
|
||||
Render2D.DrawText(Font.GetFont(), text, textRect, enabled ? textColor : textColor * 0.5f, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, textScale);
|
||||
Render2D.PopClip();
|
||||
}
|
||||
|
||||
|
||||
@@ -236,9 +236,9 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
float width = 20;
|
||||
if (style.FontMedium)
|
||||
{
|
||||
width += style.FontMedium.MeasureText(Text).X;
|
||||
width += Render2D.MeasureText(style.FontMedium, Text).X;
|
||||
if (!string.IsNullOrEmpty(ShortKeys))
|
||||
width += 40 + style.FontMedium.MeasureText(ShortKeys).X;
|
||||
width += 40 + Render2D.MeasureText(style.FontMedium, ShortKeys).X;
|
||||
}
|
||||
|
||||
return Mathf.Max(width, base.MinimumWidth);
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace FlaxEditor.GUI
|
||||
private Color _contentsColor;
|
||||
private Color _linesColor;
|
||||
private Color _labelsColor;
|
||||
private MultiFont _labelsFont;
|
||||
private Font _labelsFont;
|
||||
|
||||
/// <summary>
|
||||
/// The keyframe UI points.
|
||||
|
||||
@@ -489,7 +489,7 @@ namespace FlaxEditor.GUI.Docking
|
||||
{
|
||||
var style = Style.Current;
|
||||
if (style?.FontMedium != null)
|
||||
_titleSize = style.FontMedium.MeasureText(_title);
|
||||
_titleSize = Render2D.MeasureText(style.FontMedium, _title);
|
||||
}
|
||||
|
||||
base.PerformLayoutBeforeChildren();
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace FlaxEditor.GUI
|
||||
|
||||
var windowIcon = FlaxEngine.Content.LoadAsyncInternal<Texture>(EditorAssets.WindowIcon);
|
||||
FontAsset windowIconsFont = FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.WindowIconsFont);
|
||||
MultiFont iconFont = new MultiFontReference([windowIconsFont], 9).GetMultiFont();
|
||||
Font iconFont = windowIconsFont?.CreateFont(9);
|
||||
|
||||
_window = mainWindow.RootWindow.Window;
|
||||
_window.HitTest += OnHitTest;
|
||||
@@ -108,7 +108,7 @@ namespace FlaxEditor.GUI
|
||||
_closeButton = new Button
|
||||
{
|
||||
Text = ((char)EditorAssets.SegMDL2Icons.ChromeClose).ToString(),
|
||||
Font = new MultiFontReference(iconFont),
|
||||
Font = new FontReference(iconFont),
|
||||
BackgroundColor = Color.Transparent,
|
||||
BorderColor = Color.Transparent,
|
||||
BorderColorHighlighted = Color.Transparent,
|
||||
@@ -124,7 +124,7 @@ namespace FlaxEditor.GUI
|
||||
_minimizeButton = new Button
|
||||
{
|
||||
Text = ((char)EditorAssets.SegMDL2Icons.ChromeMinimize).ToString(),
|
||||
Font = new MultiFontReference(iconFont),
|
||||
Font = new FontReference(iconFont),
|
||||
BackgroundColor = Color.Transparent,
|
||||
BorderColor = Color.Transparent,
|
||||
BorderColorHighlighted = Color.Transparent,
|
||||
@@ -139,7 +139,7 @@ namespace FlaxEditor.GUI
|
||||
_maximizeButton = new Button
|
||||
{
|
||||
Text = ((char)(_window.IsMaximized ? EditorAssets.SegMDL2Icons.ChromeRestore : EditorAssets.SegMDL2Icons.ChromeMaximize)).ToString(),
|
||||
Font = new MultiFontReference(iconFont),
|
||||
Font = new FontReference(iconFont),
|
||||
BackgroundColor = Color.Transparent,
|
||||
BorderColor = Color.Transparent,
|
||||
BorderColorHighlighted = Color.Transparent,
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace FlaxEditor.GUI
|
||||
float width = 18;
|
||||
|
||||
if (style.FontMedium)
|
||||
width += style.FontMedium.MeasureText(Text).X;
|
||||
width += Render2D.MeasureText(style.FontMedium, Text).X;
|
||||
|
||||
Width = width;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace FlaxEditor.GUI
|
||||
|
||||
if (style.FontMedium)
|
||||
{
|
||||
Width = style.FontMedium.MeasureText(Text).X + 2 * DefaultMargin;
|
||||
Width = Render2D.MeasureText(style.FontMedium, Text).X + 2 * DefaultMargin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
Depth = -1;
|
||||
|
||||
if (Height < Style.Current.FontMedium.MaxHeight)
|
||||
Height = Style.Current.FontMedium.MaxHeight + 4;
|
||||
if (Height < Style.Current.FontMedium.Height)
|
||||
Height = Style.Current.FontMedium.Height + 4;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -345,7 +345,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
if (_previewValue != null)
|
||||
{
|
||||
// Based on Track.Draw for track text placement
|
||||
var left = _xOffset + 16 + Style.Current.FontSmall.MeasureText(Title ?? Name).X;
|
||||
var left = _xOffset + 16 + Render2D.MeasureText(Style.Current.FontSmall, Title ?? Name).X;
|
||||
if (Icon.IsValid)
|
||||
left += 18;
|
||||
if (IsExpanded)
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace FlaxEditor.GUI
|
||||
if (hasSprite)
|
||||
width += iconSize;
|
||||
if (!string.IsNullOrEmpty(_text) && style.FontMedium)
|
||||
width += style.FontMedium.MeasureText(_text).X + (hasSprite ? DefaultMargin : 0);
|
||||
width += Render2D.MeasureText(style.FontMedium, _text).X + (hasSprite ? DefaultMargin : 0);
|
||||
|
||||
Width = width;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
/// Gets or sets the font used to render text.
|
||||
/// </summary>
|
||||
[EditorDisplay("Style"), EditorOrder(2000)]
|
||||
public MultiFontReference TextFont { get; set; }
|
||||
public FontReference TextFont { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the background when tree node is selected.
|
||||
@@ -318,7 +318,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
BackgroundColorSelected = style.BackgroundSelected;
|
||||
BackgroundColorHighlighted = style.BackgroundHighlighted;
|
||||
BackgroundColorSelectedUnfocused = style.LightBackground;
|
||||
TextFont = new MultiFontReference(style.FontSmall);
|
||||
TextFont = new FontReference(style.FontSmall);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -573,10 +573,10 @@ namespace FlaxEditor.GUI.Tree
|
||||
{
|
||||
if (_textChanged)
|
||||
{
|
||||
var font = TextFont.GetMultiFont();
|
||||
var font = TextFont.GetFont();
|
||||
if (font)
|
||||
{
|
||||
_textWidth = font.MeasureText(_text).X;
|
||||
_textWidth = Render2D.MeasureText(font, _text).X;
|
||||
_textChanged = false;
|
||||
}
|
||||
}
|
||||
@@ -657,7 +657,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
}
|
||||
|
||||
// Draw text
|
||||
Render2D.DrawText(TextFont.GetMultiFont(), _text, textRect, _cachedTextColor, TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.DrawText(TextFont.GetFont(), _text, textRect, _cachedTextColor, TextAlignment.Near, TextAlignment.Center);
|
||||
|
||||
// Draw drag and drop effect
|
||||
if (IsDragOver && _tree.DraggedOverNode == this)
|
||||
|
||||
@@ -171,8 +171,10 @@ namespace FlaxEditor.Options
|
||||
get => _outputLogFont;
|
||||
set
|
||||
{
|
||||
if (value == null || !value.Font)
|
||||
_outputLogFont = new FontReference(ConsoleFont, 10);
|
||||
if (value == null)
|
||||
_outputLogFont = new FontReference(FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.InconsolataRegularFont), 10);
|
||||
else if (!value.Font)
|
||||
_outputLogFont.Font = FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.InconsolataRegularFont);
|
||||
else
|
||||
_outputLogFont = value;
|
||||
}
|
||||
@@ -234,30 +236,34 @@ namespace FlaxEditor.Options
|
||||
[EditorDisplay("Cook & Run"), EditorOrder(500)]
|
||||
public int NumberOfGameClientsToLaunch = 1;
|
||||
|
||||
private static FontAsset[] DefaultFonts =>
|
||||
[FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont),
|
||||
FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.CjkFont)];
|
||||
private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont);
|
||||
|
||||
private static FontAsset ConsoleFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont);
|
||||
|
||||
private MultiFontReference _titleFont = new MultiFontReference(DefaultFonts, 18);
|
||||
private MultiFontReference _largeFont = new MultiFontReference(DefaultFonts, 14);
|
||||
private MultiFontReference _mediumFont = new MultiFontReference(DefaultFonts, 9);
|
||||
private MultiFontReference _smallFont = new MultiFontReference(DefaultFonts, 9);
|
||||
private FontReference _titleFont = new FontReference(DefaultFont, 18);
|
||||
private FontReference _largeFont = new FontReference(DefaultFont, 14);
|
||||
private FontReference _mediumFont = new FontReference(DefaultFont, 9);
|
||||
private FontReference _smallFont = new FontReference(DefaultFont, 9);
|
||||
private FontReference _outputLogFont = new FontReference(ConsoleFont, 10);
|
||||
|
||||
/// <summary>
|
||||
/// The fallback fonts.
|
||||
/// </summary>
|
||||
public FontAsset[] Fallbacks = [FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.CjkFont)];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title font for editor UI.
|
||||
/// </summary>
|
||||
[EditorDisplay("Fonts"), EditorOrder(600), Tooltip("The title font for editor UI.")]
|
||||
public MultiFontReference TitleFont
|
||||
public FontReference TitleFont
|
||||
{
|
||||
get => _titleFont;
|
||||
set
|
||||
{
|
||||
if (value == null || !value.Verify())
|
||||
_titleFont = new MultiFontReference(DefaultFonts, 18);
|
||||
if (value == null)
|
||||
_titleFont = new FontReference(DefaultFont, 18);
|
||||
else if (!value.Font)
|
||||
_titleFont.Font = DefaultFont;
|
||||
else
|
||||
_titleFont = value;
|
||||
}
|
||||
@@ -267,13 +273,15 @@ namespace FlaxEditor.Options
|
||||
/// Gets or sets the large font for editor UI.
|
||||
/// </summary>
|
||||
[EditorDisplay("Fonts"), EditorOrder(610), Tooltip("The large font for editor UI.")]
|
||||
public MultiFontReference LargeFont
|
||||
public FontReference LargeFont
|
||||
{
|
||||
get => _largeFont;
|
||||
set
|
||||
{
|
||||
if (value == null || !value.Verify())
|
||||
_largeFont = new MultiFontReference(DefaultFonts, 14);
|
||||
if (value == null)
|
||||
_largeFont = new FontReference(DefaultFont, 14);
|
||||
else if (!value.Font)
|
||||
_largeFont.Font = DefaultFont;
|
||||
else
|
||||
_largeFont = value;
|
||||
}
|
||||
@@ -283,13 +291,15 @@ namespace FlaxEditor.Options
|
||||
/// Gets or sets the medium font for editor UI.
|
||||
/// </summary>
|
||||
[EditorDisplay("Fonts"), EditorOrder(620), Tooltip("The medium font for editor UI.")]
|
||||
public MultiFontReference MediumFont
|
||||
public FontReference MediumFont
|
||||
{
|
||||
get => _mediumFont;
|
||||
set
|
||||
{
|
||||
if (value == null || !value.Verify())
|
||||
_mediumFont = new MultiFontReference(DefaultFonts, 9);
|
||||
if (value == null)
|
||||
_mediumFont = new FontReference(DefaultFont, 9);
|
||||
else if (!value.Font)
|
||||
_mediumFont.Font = DefaultFont;
|
||||
else
|
||||
_mediumFont = value;
|
||||
}
|
||||
@@ -299,13 +309,15 @@ namespace FlaxEditor.Options
|
||||
/// Gets or sets the small font for editor UI.
|
||||
/// </summary>
|
||||
[EditorDisplay("Fonts"), EditorOrder(630), Tooltip("The small font for editor UI.")]
|
||||
public MultiFontReference SmallFont
|
||||
public FontReference SmallFont
|
||||
{
|
||||
get => _smallFont;
|
||||
set
|
||||
{
|
||||
if (value == null || !value.Verify())
|
||||
_smallFont = new MultiFontReference(DefaultFonts, 9);
|
||||
if (value == null)
|
||||
_smallFont = new FontReference(DefaultFont, 9);
|
||||
else if (!value.Font)
|
||||
_smallFont.Font = DefaultFont;
|
||||
else
|
||||
_smallFont = value;
|
||||
}
|
||||
|
||||
@@ -217,12 +217,14 @@ namespace FlaxEditor.Options
|
||||
if (styleName == ThemeOptions.LightDefault)
|
||||
{
|
||||
Style.Current = CreateLightStyle();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Style.Current = CreateDefaultStyle();
|
||||
}
|
||||
}
|
||||
|
||||
Render2D.Fallbacks = FallbackFonts.Create(Options.Interface.Fallbacks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -259,10 +261,10 @@ namespace FlaxEditor.Options
|
||||
},
|
||||
|
||||
// Fonts
|
||||
FontTitle = options.Interface.TitleFont.GetMultiFont(),
|
||||
FontLarge = options.Interface.LargeFont.GetMultiFont(),
|
||||
FontMedium = options.Interface.MediumFont.GetMultiFont(),
|
||||
FontSmall = options.Interface.SmallFont.GetMultiFont(),
|
||||
FontTitle = options.Interface.TitleFont.GetFont(),
|
||||
FontLarge = options.Interface.LargeFont.GetFont(),
|
||||
FontMedium = options.Interface.MediumFont.GetFont(),
|
||||
FontSmall = options.Interface.SmallFont.GetFont(),
|
||||
|
||||
// Icons
|
||||
ArrowDown = Editor.Icons.ArrowDown12,
|
||||
@@ -312,10 +314,10 @@ namespace FlaxEditor.Options
|
||||
ProgressNormal = new Color(0.03f, 0.65f, 0.12f, 1f),
|
||||
|
||||
// Fonts
|
||||
FontTitle = options.Interface.TitleFont.GetMultiFont(),
|
||||
FontLarge = options.Interface.LargeFont.GetMultiFont(),
|
||||
FontMedium = options.Interface.MediumFont.GetMultiFont(),
|
||||
FontSmall = options.Interface.SmallFont.GetMultiFont(),
|
||||
FontTitle = options.Interface.TitleFont.GetFont(),
|
||||
FontLarge = options.Interface.LargeFont.GetFont(),
|
||||
FontMedium = options.Interface.MediumFont.GetFont(),
|
||||
FontSmall = options.Interface.SmallFont.GetFont(),
|
||||
|
||||
// Icons
|
||||
ArrowDown = Editor.Icons.ArrowDown12,
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_textRect = new Rectangle(Float2.Zero, Size);
|
||||
|
||||
var style = Style.Current;
|
||||
var titleSize = style.FontLarge.MeasureText(Title);
|
||||
var titleSize = Render2D.MeasureText(style.FontLarge, Title);
|
||||
var width = Mathf.Max(100, titleSize.X + 50);
|
||||
Resize(width, 0);
|
||||
titleSize.X += 8.0f;
|
||||
@@ -1402,7 +1402,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
Title = StateTitle;
|
||||
var style = Style.Current;
|
||||
var titleSize = style.FontLarge.MeasureText(Title);
|
||||
var titleSize = Render2D.MeasureText(style.FontLarge, Title);
|
||||
var width = Mathf.Max(100, titleSize.X + 50);
|
||||
Resize(width, 0);
|
||||
titleSize.X += 8.0f;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
// Title
|
||||
var title = new Label(2, 2, width - 4, 23.0f)
|
||||
{
|
||||
Font = new MultiFontReference(Style.Current.FontLarge),
|
||||
Font = new FontReference(Style.Current.FontLarge),
|
||||
Text = transition.SurfaceName,
|
||||
Parent = this
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
Title = asset?.ShortName ?? "Animation";
|
||||
|
||||
var style = Style.Current;
|
||||
Resize(Mathf.Max(230, style.FontLarge.MeasureText(Title).X + 30), 160);
|
||||
Resize(Mathf.Max(230, Render2D.MeasureText(style.FontLarge, Title).X + 30), 160);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_debugRelevant = Behavior.GetNodeDebugRelevancy(instance, behavior);
|
||||
_debugInfo = Behavior.GetNodeDebugInfo(instance, behavior);
|
||||
if (!string.IsNullOrEmpty(_debugInfo))
|
||||
_debugInfoSize = Style.Current.FontSmall.MeasureText(_debugInfo);
|
||||
_debugInfoSize = Render2D.MeasureText(Style.Current.FontSmall, _debugInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
var height = 0.0f;
|
||||
var titleLabelFont = Style.Current.FontLarge;
|
||||
width = Mathf.Max(width, 100.0f);
|
||||
width = Mathf.Max(width, titleLabelFont.MeasureText(Title).X + 30);
|
||||
width = Mathf.Max(width, Render2D.MeasureText(titleLabelFont, Title).X + 30);
|
||||
if (_debugInfoSize.X > 0)
|
||||
{
|
||||
width = Mathf.Max(width, _debugInfoSize.X + 8.0f);
|
||||
|
||||
@@ -1407,7 +1407,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
// Title
|
||||
var title = new Label(2, 2, width - 4, 23.0f)
|
||||
{
|
||||
Font = new MultiFontReference(Style.Current.FontLarge),
|
||||
Font = new FontReference(Style.Current.FontLarge),
|
||||
Text = "Edit function signature",
|
||||
Parent = this
|
||||
};
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace FlaxEditor.Surface
|
||||
// Title
|
||||
var title = new Label(2, 2, width - 4, 23.0f)
|
||||
{
|
||||
Font = new MultiFontReference(Style.Current.FontLarge),
|
||||
Font = new FontReference(Style.Current.FontLarge),
|
||||
Text = "Edit attributes",
|
||||
Parent = this
|
||||
};
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
};
|
||||
|
||||
// Title bar
|
||||
var titleFontReference = new MultiFontReference(Style.Current.FontLarge);
|
||||
var titleFontReference = new FontReference(Style.Current.FontLarge);
|
||||
var titleLabel = new Label
|
||||
{
|
||||
Width = Width * 0.5f - 8f,
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
Render2D.DrawText(style.FontSmall, _archetype.Title, textRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
|
||||
if (_archetype.SubTitle != null)
|
||||
{
|
||||
var titleLength = style.FontSmall.MeasureText(_archetype.Title).X;
|
||||
var titleLength = Render2D.MeasureText(style.FontSmall, _archetype.Title).X;
|
||||
var subTitleRect = new Rectangle(textRect.X + titleLength, textRect.Y, textRect.Width - titleLength, textRect.Height);
|
||||
Render2D.DrawText(style.FontSmall, _archetype.SubTitle, subTitleRect, style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
|
||||
}
|
||||
|
||||
@@ -1428,7 +1428,7 @@ namespace FlaxEditor.Surface.Elements
|
||||
|
||||
if (_defaultValueEditor != null)
|
||||
{
|
||||
_defaultValueEditor.Location = new Float2(X + Width + 8 + Style.Current.FontSmall.MeasureText(Text).X, Y);
|
||||
_defaultValueEditor.Location = new Float2(X + Width + 8 + Render2D.MeasureText(Style.Current.FontSmall, Text).X, Y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1635,7 +1635,7 @@ namespace FlaxEditor.Surface.Elements
|
||||
{
|
||||
if (DefaultValueEditors[i].CanUse(this, ref _currentType))
|
||||
{
|
||||
var bounds = new Rectangle(X + Width + 8 + Style.Current.FontSmall.MeasureText(Text).X, Y, 90, Height);
|
||||
var bounds = new Rectangle(X + Width + 8 + Render2D.MeasureText(Style.Current.FontSmall, Text).X, Y, 90, Height);
|
||||
_editor = DefaultValueEditors[i];
|
||||
try
|
||||
{
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace FlaxEditor.Surface
|
||||
continue;
|
||||
if (child is InputBox inputBox)
|
||||
{
|
||||
var boxWidth = boxLabelFont.MeasureText(inputBox.Text).X + 20;
|
||||
var boxWidth = Render2D.MeasureText(boxLabelFont, inputBox.Text).X + 20;
|
||||
if (inputBox.DefaultValueEditor != null)
|
||||
boxWidth += inputBox.DefaultValueEditor.Width + 4;
|
||||
leftWidth = Mathf.Max(leftWidth, boxWidth);
|
||||
@@ -208,7 +208,7 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
else if (child is OutputBox outputBox)
|
||||
{
|
||||
rightWidth = Mathf.Max(rightWidth, boxLabelFont.MeasureText(outputBox.Text).X + 20);
|
||||
rightWidth = Mathf.Max(rightWidth, Render2D.MeasureText(boxLabelFont, outputBox.Text).X + 20);
|
||||
rightHeight = Mathf.Max(rightHeight, outputBox.Archetype.Position.Y - Constants.NodeMarginY - Constants.NodeHeaderSize + 20.0f);
|
||||
}
|
||||
else if (child is Control control)
|
||||
@@ -226,7 +226,7 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
}
|
||||
width = Mathf.Max(width, leftWidth + rightWidth + 10);
|
||||
width = Mathf.Max(width, titleLabelFont.MeasureText(Title).X + 30);
|
||||
width = Mathf.Max(width, Render2D.MeasureText(titleLabelFont, Title).X + 30);
|
||||
height = Mathf.Max(height, Mathf.Max(leftHeight, rightHeight));
|
||||
Resize(width, height);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace FlaxEditor.Tools.Foliage
|
||||
Parent = _noFoliagePanel,
|
||||
Enabled = false
|
||||
};
|
||||
var textSize = Style.Current.FontMedium.MeasureText(buttonText);
|
||||
var textSize = Render2D.MeasureText(Style.Current.FontMedium, buttonText);
|
||||
if (_createNewFoliage.Width < textSize.X)
|
||||
{
|
||||
_createNewFoliage.LocalX -= (textSize.X - _createNewFoliage.Width) / 2;
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
Parent = _noTerrainPanel,
|
||||
Enabled = false
|
||||
};
|
||||
var textSize = Style.Current.FontMedium.MeasureText(buttonText);
|
||||
var textSize = Render2D.MeasureText(Style.Current.FontMedium, buttonText);
|
||||
if (_createTerrainButton.Width < textSize.X)
|
||||
{
|
||||
_createTerrainButton.LocalX -= (textSize.X - _createTerrainButton.Width) / 2;
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
AnchorPreset = AnchorPresets.HorizontalStretchTop,
|
||||
Offsets = new Margin(0, 0, 0, 40),
|
||||
Parent = this,
|
||||
Font = new MultiFontReference(Style.Current.FontTitle)
|
||||
Font = new FontReference(Style.Current.FontTitle)
|
||||
};
|
||||
var infoLabel = new Label
|
||||
{
|
||||
|
||||
108
Source/Editor/Utilities/TextRenderUtils.cs
Normal file
108
Source/Editor/Utilities/TextRenderUtils.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using FlaxEngine.GUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
public static class TextRenderUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws a text using the global fallback defined in styles.
|
||||
/// </summary>
|
||||
/// <param name="font">The font to use.</param>
|
||||
/// <param name="text">The text to render.</param>
|
||||
/// <param name="layoutRect">The size and position of the area in which the text is drawn.</param>
|
||||
/// <param name="color">The text color.</param>
|
||||
/// <param name="horizontalAlignment">The horizontal alignment of the text in a layout rectangle.</param>
|
||||
/// <param name="verticalAlignment">The vertical alignment of the text in a layout rectangle.</param>
|
||||
/// <param name="textWrapping">Describes how wrap text inside a layout rectangle.</param>
|
||||
/// <param name="baseLinesGapScale">The scale for distance one baseline from another. Default is 1.</param>
|
||||
/// <param name="scale">The text drawing scale. Default is 1.</param>
|
||||
public static void DrawTextWithFallback(Font font, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f)
|
||||
{
|
||||
var layout = new TextLayoutOptions
|
||||
{
|
||||
Bounds = layoutRect,
|
||||
HorizontalAlignment = horizontalAlignment,
|
||||
VerticalAlignment = verticalAlignment,
|
||||
TextWrapping = textWrapping,
|
||||
Scale = scale,
|
||||
BaseLinesGapScale = baseLinesGapScale,
|
||||
};
|
||||
|
||||
|
||||
Render2D.DrawText(font, Style.Current.Fallbacks, text, color, ref layout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a text using the global fallback defined in styles. Given material must have GUI domain and a public parameter named Font (texture parameter used for a font atlas sampling).
|
||||
/// </summary>
|
||||
/// <param name="font">The font to use.</param>
|
||||
/// <param name="customMaterial">Custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture.</param>
|
||||
/// <param name="text">The text to render.</param>
|
||||
/// <param name="layoutRect">The size and position of the area in which the text is drawn.</param>
|
||||
/// <param name="color">The text color.</param>
|
||||
/// <param name="horizontalAlignment">The horizontal alignment of the text in a layout rectangle.</param>
|
||||
/// <param name="verticalAlignment">The vertical alignment of the text in a layout rectangle.</param>
|
||||
/// <param name="textWrapping">Describes how wrap text inside a layout rectangle.</param>
|
||||
/// <param name="baseLinesGapScale">The scale for distance one baseline from another. Default is 1.</param>
|
||||
/// <param name="scale">The text drawing scale. Default is 1.</param>
|
||||
public static void DrawTextWithFallback(Font font, MaterialBase customMaterial, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f)
|
||||
{
|
||||
var layout = new TextLayoutOptions
|
||||
{
|
||||
Bounds = layoutRect,
|
||||
HorizontalAlignment = horizontalAlignment,
|
||||
VerticalAlignment = verticalAlignment,
|
||||
TextWrapping = textWrapping,
|
||||
Scale = scale,
|
||||
BaseLinesGapScale = baseLinesGapScale,
|
||||
};
|
||||
|
||||
Render2D.DrawText(font, Style.Current.Fallbacks, text, color, ref layout, customMaterial);
|
||||
}
|
||||
|
||||
public static Float2 MeasureTextWithFallback(Font font, string text)
|
||||
{
|
||||
return font.MeasureText(Style.Current.Fallbacks, text);
|
||||
}
|
||||
|
||||
public static Float2 MeasureTextWithFallback(Font font, string text, ref TextRange textRange)
|
||||
{
|
||||
return font.MeasureText(Style.Current.Fallbacks, text, ref textRange);
|
||||
}
|
||||
|
||||
public static Float2 MeasureTextWithFallback(Font font, string text, ref TextLayoutOptions layout)
|
||||
{
|
||||
return font.MeasureText(Style.Current.Fallbacks, text, ref layout);
|
||||
}
|
||||
|
||||
public static Float2 MeasureTextWithFallback(Font font, string text, ref TextRange textRange, ref TextLayoutOptions layout)
|
||||
{
|
||||
return font.MeasureText(Style.Current.Fallbacks, text, ref textRange, ref layout);
|
||||
}
|
||||
|
||||
public static Float2 GetCharPositionWithFallback(Font font, string text, int index)
|
||||
{
|
||||
return font.GetCharPosition(Style.Current.Fallbacks, text, index);
|
||||
}
|
||||
|
||||
public static Float2 GetCharPositionWithFallback(Font font, string text, ref TextRange textRange, int index)
|
||||
{
|
||||
return font.GetCharPosition(Style.Current.Fallbacks, text, ref textRange, index);
|
||||
}
|
||||
|
||||
public static Float2 GetCharPositionWithFallback(Font font, string text, int index, ref TextLayoutOptions layout)
|
||||
{
|
||||
return font.GetCharPosition(Style.Current.Fallbacks, text, index, ref layout);
|
||||
}
|
||||
|
||||
public static Float2 GetCharPositionWithFallback(Font font, string text, ref TextRange textRange, int index, ref TextLayoutOptions layout)
|
||||
{
|
||||
return font.GetCharPosition(Style.Current.Fallbacks, text, ref textRange, index, ref layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -548,9 +548,9 @@ namespace FlaxEditor.Viewport
|
||||
#region Camera settings widget
|
||||
|
||||
var largestText = "Relative Panning";
|
||||
var textSize = Style.Current.FontMedium.MeasureText(largestText);
|
||||
var textSize = Render2D.MeasureText(Style.Current.FontMedium, largestText);
|
||||
var xLocationForExtras = textSize.X + 5;
|
||||
var cameraSpeedTextWidth = Style.Current.FontMedium.MeasureText("0.00").X;
|
||||
var cameraSpeedTextWidth = Render2D.MeasureText(Style.Current.FontMedium, "0.00").X;
|
||||
|
||||
// Camera Settings Widget
|
||||
_cameraWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);
|
||||
@@ -801,7 +801,7 @@ namespace FlaxEditor.Viewport
|
||||
#region View mode widget
|
||||
|
||||
largestText = "Brightness";
|
||||
textSize = Style.Current.FontMedium.MeasureText(largestText);
|
||||
textSize = Render2D.MeasureText(Style.Current.FontMedium, largestText);
|
||||
xLocationForExtras = textSize.X + 5;
|
||||
|
||||
var viewMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperLeft);
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace FlaxEditor.Viewport.Widgets
|
||||
var style = Style.Current;
|
||||
|
||||
if (style != null && style.FontMedium)
|
||||
Width = CalculateButtonWidth(_forcedTextWidth > 0.0f ? _forcedTextWidth : style.FontMedium.MeasureText(_text).X, Icon.IsValid);
|
||||
Width = CalculateButtonWidth(_forcedTextWidth > 0.0f ? _forcedTextWidth : Render2D.MeasureText(style.FontMedium, _text).X, Icon.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace FlaxEditor.Windows
|
||||
var nameLabel = new Label(icon.Right + 10, icon.Top, 200, 34)
|
||||
{
|
||||
Text = "Flax Engine",
|
||||
Font = new MultiFontReference(Style.Current.FontTitle),
|
||||
Font = new FontReference(Style.Current.FontTitle),
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
VerticalAlignment = TextAlignment.Center,
|
||||
Parent = this
|
||||
@@ -54,7 +54,7 @@ namespace FlaxEditor.Windows
|
||||
Parent = this
|
||||
};
|
||||
var buttonText = "Copy version info";
|
||||
var fontSize = Style.Current.FontMedium.MeasureText(buttonText);
|
||||
var fontSize = Render2D.MeasureText(Style.Current.FontMedium, buttonText);
|
||||
var copyVersionButton = new Button(Width - fontSize.X - 8, 6, fontSize.X + 4, 20)
|
||||
{
|
||||
Text = buttonText,
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
protected override void OnAssetLinked()
|
||||
{
|
||||
Asset.WaitForLoaded();
|
||||
_textPreview.Font = new MultiFontReference([Asset], 30);
|
||||
_textPreview.Font = new FontReference(Asset, 30);
|
||||
_inputText.Text = string.Format("This is a sample text using font {0}.", Asset.FamilyName);
|
||||
var options = Asset.Options;
|
||||
_proxy.Set(ref options);
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace FlaxEditor.Windows
|
||||
var textRect = new Rectangle(margin, 0, clientRect.Width - boxSize - 2.0f * margin, clientRect.Height);
|
||||
Render2D.PushClip(textRect);
|
||||
var textColor = TextColor;
|
||||
Render2D.DrawText(Font.GetMultiFont(), "View", textRect, enabled ? textColor : textColor * 0.5f, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, textScale);
|
||||
Render2D.DrawText(Font.GetFont(), "View", textRect, enabled ? textColor : textColor * 0.5f, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, textScale);
|
||||
Render2D.PopClip();
|
||||
|
||||
// Arrow
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace FlaxEditor.Windows
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
AnchorPreset = AnchorPresets.HorizontalStretchTop,
|
||||
Text = desc.Name,
|
||||
Font = new MultiFontReference(Style.Current.FontLarge),
|
||||
Font = new FontReference(Style.Current.FontLarge),
|
||||
Parent = this,
|
||||
Bounds = new Rectangle(tmp1, margin, Width - tmp1 - margin, 28),
|
||||
};
|
||||
@@ -120,9 +120,9 @@ namespace FlaxEditor.Windows
|
||||
url = desc.HomepageUrl;
|
||||
else if (!string.IsNullOrEmpty(desc.RepositoryUrl))
|
||||
url = desc.RepositoryUrl;
|
||||
versionLabel.Font.ForEach(x => x.Font.WaitForLoaded());
|
||||
var font = versionLabel.Font.GetMultiFont();
|
||||
var authorWidth = font.MeasureText(desc.Author).X + 8;
|
||||
versionLabel.Font.Font.WaitForLoaded();
|
||||
var font = versionLabel.Font.GetFont();
|
||||
var authorWidth = Render2D.MeasureText(font, desc.Author).X + 8;
|
||||
var authorLabel = new ClickableLabel
|
||||
{
|
||||
HorizontalAlignment = TextAlignment.Far,
|
||||
@@ -392,7 +392,6 @@ namespace FlaxEditor.Windows
|
||||
}
|
||||
|
||||
Editor.Log("Plugin project has been cloned.");
|
||||
|
||||
try
|
||||
{
|
||||
// Start git submodule clone
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace FlaxEditor.Windows.Profiler
|
||||
Render2D.DrawRectangle(bounds, color * 0.5f);
|
||||
|
||||
if (_nameLength < 0 && style.FontMedium)
|
||||
_nameLength = style.FontMedium.MeasureText(_name).X;
|
||||
_nameLength = Render2D.MeasureText(style.FontMedium, _name).X;
|
||||
|
||||
if (_nameLength < bounds.Width + 4)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
/// <summary>
|
||||
/// Combine the primary fonts with the fallback fonts to get a font list
|
||||
/// </summary>
|
||||
API_PROPERTY() FORCE_INLINE Array<Font*>& GetFontList(float size) {
|
||||
API_FUNCTION() FORCE_INLINE Array<Font*>& GetFontList(float size) {
|
||||
Array<Font*>* result;
|
||||
if (_cache.TryGet(size, result)) {
|
||||
return *result;
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to multiple font references
|
||||
/// </summary>
|
||||
public class MultiFontReference : List<FontReference>
|
||||
{
|
||||
public MultiFontReference()
|
||||
{
|
||||
_cachedFont = null;
|
||||
}
|
||||
|
||||
public MultiFontReference(IEnumerable<FontReference> other)
|
||||
{
|
||||
AddRange(other);
|
||||
_cachedFont = null;
|
||||
}
|
||||
|
||||
public MultiFontReference(MultiFontReference other)
|
||||
{
|
||||
AddRange(other);
|
||||
_cachedFont = other._cachedFont;
|
||||
}
|
||||
|
||||
public MultiFontReference(MultiFontReference other, float size)
|
||||
{
|
||||
AddRange(other.Select(x => new FontReference(x) { Size = size }));
|
||||
_cachedFont = null;
|
||||
}
|
||||
|
||||
public MultiFontReference(MultiFont other)
|
||||
{
|
||||
AddRange(other.Fonts.Select(x => new FontReference(x)));
|
||||
_cachedFont = other;
|
||||
}
|
||||
|
||||
public MultiFontReference(FontAsset[] assets, float size)
|
||||
{
|
||||
AddRange(assets.Select(x => new FontReference(x, size)));
|
||||
_cachedFont = null;
|
||||
}
|
||||
|
||||
[EditorOrder(0), Tooltip("The font asset to use as characters source.")]
|
||||
public MultiFont GetMultiFont()
|
||||
{
|
||||
if (_cachedFont)
|
||||
return _cachedFont;
|
||||
var fontList = this.Where(x => x.Font).Select(x => x.GetFont()).ToArray();
|
||||
_cachedFont = MultiFont.Create(fontList);
|
||||
return _cachedFont;
|
||||
}
|
||||
|
||||
public bool Verify()
|
||||
{
|
||||
foreach (var i in this)
|
||||
{
|
||||
if (!i.Font)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[NoSerialize]
|
||||
private MultiFont _cachedFont;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
using FlaxEngine.GUI;
|
||||
using System;
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
partial class Render2D
|
||||
{
|
||||
public static FallbackFonts Fallbacks
|
||||
{
|
||||
get; set;
|
||||
} = null;
|
||||
|
||||
/// <summary>
|
||||
/// Pushes transformation layer.
|
||||
/// </summary>
|
||||
@@ -111,7 +117,8 @@ namespace FlaxEngine
|
||||
/// <param name="textWrapping">Describes how wrap text inside a layout rectangle.</param>
|
||||
/// <param name="baseLinesGapScale">The scale for distance one baseline from another. Default is 1.</param>
|
||||
/// <param name="scale">The text drawing scale. Default is 1.</param>
|
||||
public static void DrawText(Font font, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f)
|
||||
/// <param name="useFallback">Whether to use fallback fonts for chars not renderable by the font.</param>
|
||||
public static void DrawText(Font font, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f, bool useFallback = true)
|
||||
{
|
||||
var layout = new TextLayoutOptions
|
||||
{
|
||||
@@ -122,7 +129,15 @@ namespace FlaxEngine
|
||||
Scale = scale,
|
||||
BaseLinesGapScale = baseLinesGapScale,
|
||||
};
|
||||
DrawText(font, text, color, ref layout);
|
||||
|
||||
if (useFallback && Fallbacks != null)
|
||||
{
|
||||
DrawText(font, Fallbacks, text, color, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText(font, text, color, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -138,7 +153,8 @@ namespace FlaxEngine
|
||||
/// <param name="textWrapping">Describes how wrap text inside a layout rectangle.</param>
|
||||
/// <param name="baseLinesGapScale">The scale for distance one baseline from another. Default is 1.</param>
|
||||
/// <param name="scale">The text drawing scale. Default is 1.</param>
|
||||
public static void DrawText(Font font, MaterialBase customMaterial, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f)
|
||||
/// <param name="useFallback">Whether to use fallback fonts for chars not renderable by the font.</param>
|
||||
public static void DrawText(Font font, MaterialBase customMaterial, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f, bool useFallback = true)
|
||||
{
|
||||
var layout = new TextLayoutOptions
|
||||
{
|
||||
@@ -149,63 +165,63 @@ namespace FlaxEngine
|
||||
Scale = scale,
|
||||
BaseLinesGapScale = baseLinesGapScale,
|
||||
};
|
||||
DrawText(font, text, color, ref layout, customMaterial);
|
||||
|
||||
if (useFallback && Fallbacks != null)
|
||||
{
|
||||
DrawText(font, Fallbacks, text, color, ref layout, customMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText(font, text, color, ref layout, customMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a text.
|
||||
/// </summary>
|
||||
/// <param name="fonts">The fonts to use, ordered by priority.</param>
|
||||
/// <param name="text">The text to render.</param>
|
||||
/// <param name="layoutRect">The size and position of the area in which the text is drawn.</param>
|
||||
/// <param name="color">The text color.</param>
|
||||
/// <param name="horizontalAlignment">The horizontal alignment of the text in a layout rectangle.</param>
|
||||
/// <param name="verticalAlignment">The vertical alignment of the text in a layout rectangle.</param>
|
||||
/// <param name="textWrapping">Describes how wrap text inside a layout rectangle.</param>
|
||||
/// <param name="baseLinesGapScale">The scale for distance one baseline from another. Default is 1.</param>
|
||||
/// <param name="scale">The text drawing scale. Default is 1.</param>
|
||||
public static void DrawText(MultiFont fonts, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f)
|
||||
public static Float2 MeasureText(Font font, string text, bool useFallback = true)
|
||||
{
|
||||
var layout = new TextLayoutOptions
|
||||
if (useFallback && Fallbacks != null)
|
||||
{
|
||||
Bounds = layoutRect,
|
||||
HorizontalAlignment = horizontalAlignment,
|
||||
VerticalAlignment = verticalAlignment,
|
||||
TextWrapping = textWrapping,
|
||||
Scale = scale,
|
||||
BaseLinesGapScale = baseLinesGapScale,
|
||||
};
|
||||
|
||||
|
||||
DrawText(fonts, text, color, ref layout);
|
||||
return font.MeasureText(Style.Current.Fallbacks, text);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.MeasureText(text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a text using a custom material shader. Given material must have GUI domain and a public parameter named Font (texture parameter used for a font atlas sampling).
|
||||
/// </summary>
|
||||
/// <param name="fonts">The fonts to use, ordered by priority.</param>
|
||||
/// <param name="customMaterial">Custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture.</param>
|
||||
/// <param name="text">The text to render.</param>
|
||||
/// <param name="layoutRect">The size and position of the area in which the text is drawn.</param>
|
||||
/// <param name="color">The text color.</param>
|
||||
/// <param name="horizontalAlignment">The horizontal alignment of the text in a layout rectangle.</param>
|
||||
/// <param name="verticalAlignment">The vertical alignment of the text in a layout rectangle.</param>
|
||||
/// <param name="textWrapping">Describes how wrap text inside a layout rectangle.</param>
|
||||
/// <param name="baseLinesGapScale">The scale for distance one baseline from another. Default is 1.</param>
|
||||
/// <param name="scale">The text drawing scale. Default is 1.</param>
|
||||
public static void DrawText(MultiFont fonts, MaterialBase customMaterial, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f)
|
||||
public static Float2 MeasureText(Font font, string text, ref TextRange textRange, bool useFallback = true)
|
||||
{
|
||||
var layout = new TextLayoutOptions
|
||||
if (useFallback && Fallbacks != null)
|
||||
{
|
||||
Bounds = layoutRect,
|
||||
HorizontalAlignment = horizontalAlignment,
|
||||
VerticalAlignment = verticalAlignment,
|
||||
TextWrapping = textWrapping,
|
||||
Scale = scale,
|
||||
BaseLinesGapScale = baseLinesGapScale,
|
||||
};
|
||||
return font.MeasureText(Style.Current.Fallbacks, text, ref textRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.MeasureText(text, ref textRange);
|
||||
}
|
||||
}
|
||||
|
||||
DrawText(fonts, text, color, ref layout, customMaterial);
|
||||
public static Float2 MeasureText(Font font, string text, ref TextLayoutOptions layout, bool useFallback = true)
|
||||
{
|
||||
if (useFallback && Fallbacks != null)
|
||||
{
|
||||
return font.MeasureText(Style.Current.Fallbacks, text, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.MeasureText(text, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
public static Float2 MeasureText(Font font, string text, ref TextRange textRange, ref TextLayoutOptions layout, bool useFallback = true)
|
||||
{
|
||||
if (useFallback && Fallbacks != null)
|
||||
{
|
||||
return font.MeasureText(Style.Current.Fallbacks, text, ref textRange, ref layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
return font.MeasureText(text, ref textRange, ref layout);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -294,12 +294,12 @@ namespace FlaxEngine
|
||||
style.DragWindow = style.BackgroundSelected * 0.7f;
|
||||
|
||||
// Use optionally bundled default font (matches Editor)
|
||||
FontAsset[] defaultFont = [Content.LoadAsyncInternal<FontAsset>("Editor/Fonts/Roboto-Regular"), Content.LoadAsyncInternal<FontAsset>("Editor/Fonts/NotoSansSC-Regular")];
|
||||
FontAsset defaultFont = Content.LoadAsyncInternal<FontAsset>("Editor/Fonts/Roboto-Regular");
|
||||
|
||||
style.FontTitle = new MultiFontReference(defaultFont, 18).GetMultiFont();
|
||||
style.FontLarge = new MultiFontReference(defaultFont, 14).GetMultiFont();
|
||||
style.FontMedium = new MultiFontReference(defaultFont, 9).GetMultiFont();
|
||||
style.FontSmall = new MultiFontReference(defaultFont, 9).GetMultiFont();
|
||||
style.FontTitle = new FontReference(defaultFont, 18).GetFont();
|
||||
style.FontLarge = new FontReference(defaultFont, 14).GetFont();
|
||||
style.FontMedium = new FontReference(defaultFont, 9).GetFont();
|
||||
style.FontSmall = new FontReference(defaultFont, 9).GetFont();
|
||||
|
||||
Style.Current = style;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// The font.
|
||||
/// </summary>
|
||||
protected MultiFontReference _font;
|
||||
protected FontReference _font;
|
||||
|
||||
/// <summary>
|
||||
/// The text.
|
||||
@@ -44,7 +44,7 @@ namespace FlaxEngine.GUI
|
||||
/// Gets or sets the font used to draw button text.
|
||||
/// </summary>
|
||||
[EditorDisplay("Text Style"), EditorOrder(2022), ExpandGroups]
|
||||
public MultiFontReference Font
|
||||
public FontReference Font
|
||||
{
|
||||
get => _font;
|
||||
set => _font = value;
|
||||
@@ -156,7 +156,7 @@ namespace FlaxEngine.GUI
|
||||
var style = Style.Current;
|
||||
if (style != null)
|
||||
{
|
||||
_font = new MultiFontReference(style.FontMedium);
|
||||
_font = new FontReference(style.FontMedium);
|
||||
TextColor = style.Foreground;
|
||||
BackgroundColor = style.BackgroundNormal;
|
||||
BorderColor = style.BorderNormal;
|
||||
@@ -262,7 +262,7 @@ namespace FlaxEngine.GUI
|
||||
Render2D.DrawRectangle(clientRect, borderColor, BorderThickness);
|
||||
|
||||
// Draw text
|
||||
Render2D.DrawText(_font?.GetMultiFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
|
||||
Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace FlaxEngine.GUI
|
||||
/// Gets or sets the font used to draw text.
|
||||
/// </summary>
|
||||
[EditorDisplay("Text Style"), EditorOrder(2021)]
|
||||
public MultiFontReference Font { get; set; }
|
||||
public FontReference Font { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.
|
||||
@@ -359,7 +359,7 @@ namespace FlaxEngine.GUI
|
||||
: base(0, 0, 120, 18.0f)
|
||||
{
|
||||
var style = Style.Current;
|
||||
Font = new MultiFontReference(style.FontMedium);
|
||||
Font = new FontReference(style.FontMedium);
|
||||
TextColor = style.Foreground;
|
||||
BackgroundColor = style.BackgroundNormal;
|
||||
BackgroundColorHighlighted = BackgroundColor;
|
||||
@@ -476,7 +476,7 @@ namespace FlaxEngine.GUI
|
||||
var font = Font.GetFont();
|
||||
for (int i = 0; i < _items.Count; i++)
|
||||
{
|
||||
itemsWidth = Mathf.Max(itemsWidth, itemsMargin + 4 + font.MeasureText(_items[i]).X);
|
||||
itemsWidth = Mathf.Max(itemsWidth, itemsMargin + 4 + Render2D.MeasureText(font, _items[i]).X);
|
||||
}
|
||||
*/
|
||||
var itemsWidth = Width;
|
||||
@@ -674,7 +674,7 @@ namespace FlaxEngine.GUI
|
||||
var textRect = new Rectangle(margin, 0, clientRect.Width - boxSize - 2.0f * margin, clientRect.Height);
|
||||
Render2D.PushClip(textRect);
|
||||
var textColor = TextColor;
|
||||
Render2D.DrawText(Font.GetMultiFont(), FontMaterial, _items[_selectedIndex], textRect, enabled ? textColor : textColor * 0.5f, TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.DrawText(Font.GetFont(), FontMaterial, _items[_selectedIndex], textRect, enabled ? textColor : textColor * 0.5f, TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.PopClip();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// The font.
|
||||
/// </summary>
|
||||
protected MultiFontReference _font;
|
||||
protected FontReference _font;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
@@ -86,7 +86,7 @@ namespace FlaxEngine.GUI
|
||||
/// Gets or sets the font.
|
||||
/// </summary>
|
||||
[EditorDisplay("Text Style"), EditorOrder(2024)]
|
||||
public MultiFontReference Font
|
||||
public FontReference Font
|
||||
{
|
||||
get => _font;
|
||||
set
|
||||
@@ -192,7 +192,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
AutoFocus = false;
|
||||
var style = Style.Current;
|
||||
Font = new MultiFontReference(style.FontMedium);
|
||||
Font = new FontReference(style.FontMedium);
|
||||
TextColor = style.Foreground;
|
||||
TextColorHighlighted = style.Foreground;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
AutoFocus = false;
|
||||
var style = Style.Current;
|
||||
Font = new MultiFontReference(style.FontMedium);
|
||||
Font = new FontReference(style.FontMedium);
|
||||
TextColor = style.Foreground;
|
||||
TextColorHighlighted = style.Foreground;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
|
||||
Render2D.DrawText(_font.GetMultiFont(), Material, _text, rect, color, hAlignment, wAlignment, Wrapping, BaseLinesGapScale, scale);
|
||||
Render2D.DrawText(_font.GetFont(), Material, _text, rect, color, hAlignment, wAlignment, Wrapping, BaseLinesGapScale, scale);
|
||||
|
||||
if (ClipText)
|
||||
Render2D.PopClip();
|
||||
@@ -246,7 +246,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
if (_autoWidth || _autoHeight || _autoFitText)
|
||||
{
|
||||
var font = _font.GetMultiFont();
|
||||
var font = _font.GetFont();
|
||||
if (font)
|
||||
{
|
||||
// Calculate text size
|
||||
@@ -256,7 +256,7 @@ namespace FlaxEngine.GUI
|
||||
layout.Bounds.Size.X = Width - Margin.Width;
|
||||
else if (_autoWidth && !_autoHeight)
|
||||
layout.Bounds.Size.Y = Height - Margin.Height;
|
||||
_textSize = font.MeasureText(_text, ref layout);
|
||||
_textSize = Render2D.MeasureText(font, _text, ref layout);
|
||||
_textSize.Y *= BaseLinesGapScale;
|
||||
|
||||
// Check if size is controlled via text
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace FlaxEngine.GUI
|
||||
var style = Style.Current;
|
||||
_textStyle = new TextBlockStyle
|
||||
{
|
||||
Font = new FontReference(style.FontMedium.Fonts.First()),
|
||||
Font = new FontReference(style.FontMedium),
|
||||
Color = style.Foreground,
|
||||
BackgroundSelectedBrush = new SolidColorBrush(style.BackgroundSelected),
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
@@ -40,7 +41,7 @@ namespace FlaxEngine.GUI
|
||||
/// Gets or sets the font.
|
||||
/// </summary>
|
||||
[EditorDisplay("Text Style"), EditorOrder(2024)]
|
||||
public MultiFontReference Font { get; set; }
|
||||
public FontReference Font { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.
|
||||
@@ -90,7 +91,7 @@ namespace FlaxEngine.GUI
|
||||
_layout.Bounds = new Rectangle(DefaultMargin, 1, Width - 2 * DefaultMargin, Height - 2);
|
||||
|
||||
var style = Style.Current;
|
||||
Font = new MultiFontReference(style.FontMedium);
|
||||
Font = new FontReference(style.FontMedium);
|
||||
TextColor = style.Foreground;
|
||||
WatermarkTextColor = style.ForegroundDisabled;
|
||||
SelectionColor = style.BackgroundSelected;
|
||||
@@ -99,33 +100,33 @@ namespace FlaxEngine.GUI
|
||||
/// <inheritdoc />
|
||||
public override Float2 GetTextSize()
|
||||
{
|
||||
var font = Font.GetMultiFont();
|
||||
var font = Font.GetFont();
|
||||
if (font == null)
|
||||
{
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
return font.MeasureText(_text, ref _layout);
|
||||
return Render2D.MeasureText(font, _text, ref _layout);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Float2 GetCharPosition(int index, out float height)
|
||||
{
|
||||
var font = Font.GetMultiFont();
|
||||
var font = Font.GetFont();
|
||||
if (font == null)
|
||||
{
|
||||
height = Height;
|
||||
return Float2.Zero;
|
||||
}
|
||||
|
||||
height = font.MaxHeight / DpiScale;
|
||||
height = font.Height / DpiScale;
|
||||
return font.GetCharPosition(_text, index, ref _layout);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int HitTestText(Float2 location)
|
||||
{
|
||||
var font = Font.GetMultiFont();
|
||||
var font = Font.GetFont();
|
||||
if (font == null)
|
||||
{
|
||||
return 0;
|
||||
@@ -148,7 +149,7 @@ namespace FlaxEngine.GUI
|
||||
// Cache data
|
||||
var rect = new Rectangle(Float2.Zero, Size);
|
||||
bool enabled = EnabledInHierarchy;
|
||||
var font = Font.GetMultiFont();
|
||||
var font = Font.GetFont();
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
@@ -172,7 +173,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
var leftEdge = font.GetCharPosition(_text, SelectionLeft, ref _layout);
|
||||
var rightEdge = font.GetCharPosition(_text, SelectionRight, ref _layout);
|
||||
float fontHeight = font.MaxHeight / DpiScale;
|
||||
float fontHeight = font.Height / DpiScale;
|
||||
|
||||
// Draw selection background
|
||||
float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
|
||||
@@ -212,11 +213,25 @@ namespace FlaxEngine.GUI
|
||||
var color = TextColor;
|
||||
if (!enabled)
|
||||
color *= 0.6f;
|
||||
Render2D.DrawText(font, _text, color, ref _layout, TextMaterial);
|
||||
if (Render2D.Fallbacks != null)
|
||||
{
|
||||
Render2D.DrawText(font, Render2D.Fallbacks, _text, color, ref _layout, TextMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
Render2D.DrawText(font, _text, color, ref _layout, TextMaterial);
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_watermarkText) && !IsFocused)
|
||||
{
|
||||
Render2D.DrawText(font, _watermarkText, WatermarkTextColor, ref _layout, TextMaterial);
|
||||
if (Render2D.Fallbacks != null)
|
||||
{
|
||||
Render2D.DrawText(font, Render2D.Fallbacks, _watermarkText, WatermarkTextColor, ref _layout, TextMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
Render2D.DrawText(font, _watermarkText, WatermarkTextColor, ref _layout, TextMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
// Caret
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace FlaxEngine.GUI
|
||||
/// Gets or sets the font used to render panel header text.
|
||||
/// </summary>
|
||||
[EditorDisplay("Header Text Style"), EditorOrder(2020), ExpandGroups]
|
||||
public MultiFontReference HeaderTextFont { get; set; }
|
||||
public FontReference HeaderTextFont { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data.
|
||||
@@ -238,7 +238,7 @@ namespace FlaxEngine.GUI
|
||||
var style = Style.Current;
|
||||
HeaderColor = style.BackgroundNormal;
|
||||
HeaderColorMouseOver = style.BackgroundHighlighted;
|
||||
HeaderTextFont = new MultiFontReference(style.FontMedium);
|
||||
HeaderTextFont = new FontReference(style.FontMedium);
|
||||
HeaderTextColor = style.Foreground;
|
||||
ArrowImageOpened = new SpriteBrush(style.ArrowDown);
|
||||
ArrowImageClosed = new SpriteBrush(style.ArrowRight);
|
||||
@@ -375,7 +375,7 @@ namespace FlaxEngine.GUI
|
||||
textColor *= 0.6f;
|
||||
}
|
||||
|
||||
Render2D.DrawText(HeaderTextFont.GetMultiFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.DrawText(HeaderTextFont.GetFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
|
||||
|
||||
if (!_isClosed && EnableContainmentLines)
|
||||
{
|
||||
|
||||
@@ -15,61 +15,67 @@ namespace FlaxEngine.GUI
|
||||
public static Style Current { get; set; }
|
||||
|
||||
[Serialize]
|
||||
private MultiFontReference _fontTitle;
|
||||
private FontReference _fontTitle;
|
||||
|
||||
/// <summary>
|
||||
/// The font title.
|
||||
/// </summary>
|
||||
[NoSerialize]
|
||||
[EditorOrder(10)]
|
||||
public MultiFont FontTitle
|
||||
public Font FontTitle
|
||||
{
|
||||
get => _fontTitle?.GetMultiFont();
|
||||
set => _fontTitle = new MultiFontReference(value);
|
||||
get => _fontTitle?.GetFont();
|
||||
set => _fontTitle = new FontReference(value);
|
||||
}
|
||||
|
||||
[Serialize]
|
||||
private MultiFontReference _fontLarge;
|
||||
private FontReference _fontLarge;
|
||||
|
||||
/// <summary>
|
||||
/// The font large.
|
||||
/// </summary>
|
||||
[NoSerialize]
|
||||
[EditorOrder(20)]
|
||||
public MultiFont FontLarge
|
||||
public Font FontLarge
|
||||
{
|
||||
get => _fontLarge?.GetMultiFont();
|
||||
set => _fontLarge = new MultiFontReference(value);
|
||||
get => _fontLarge?.GetFont();
|
||||
set => _fontLarge = new FontReference(value);
|
||||
}
|
||||
|
||||
[Serialize]
|
||||
private MultiFontReference _fontMedium;
|
||||
private FontReference _fontMedium;
|
||||
|
||||
/// <summary>
|
||||
/// The font medium.
|
||||
/// </summary>
|
||||
[NoSerialize]
|
||||
[EditorOrder(30)]
|
||||
public MultiFont FontMedium
|
||||
public Font FontMedium
|
||||
{
|
||||
get => _fontMedium?.GetMultiFont();
|
||||
set => _fontMedium = new MultiFontReference(value);
|
||||
get => _fontMedium?.GetFont();
|
||||
set => _fontMedium = new FontReference(value);
|
||||
}
|
||||
|
||||
[Serialize]
|
||||
private MultiFontReference _fontSmall;
|
||||
private FontReference _fontSmall;
|
||||
|
||||
/// <summary>
|
||||
/// The font small.
|
||||
/// </summary>
|
||||
[NoSerialize]
|
||||
[EditorOrder(40)]
|
||||
public MultiFont FontSmall
|
||||
public Font FontSmall
|
||||
{
|
||||
get => _fontSmall?.GetMultiFont();
|
||||
set => _fontSmall = new MultiFontReference(value);
|
||||
get => _fontSmall?.GetFont();
|
||||
set => _fontSmall = new FontReference(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fallback fonts to use if the primary font can't render the char.
|
||||
/// </summary>
|
||||
[EditorOrder(50)]
|
||||
public FallbackFonts Fallbacks;
|
||||
|
||||
/// <summary>
|
||||
/// The background color.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user