diff --git a/Source/Editor/Content/GUI/ContentView.cs b/Source/Editor/Content/GUI/ContentView.cs
index 1091c9cef..259be104b 100644
--- a/Source/Editor/Content/GUI/ContentView.cs
+++ b/Source/Editor/Content/GUI/ContentView.cs
@@ -598,7 +598,7 @@ namespace FlaxEditor.Content.GUI
// Check if it's an empty thing
if (_items.Count == 0)
{
- FallbackTextUtils.DrawText(style.FontSmall, IsSearching ? "No results" : "Empty", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, IsSearching ? "No results" : "Empty", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
}
diff --git a/Source/Editor/Content/Items/ContentItem.cs b/Source/Editor/Content/Items/ContentItem.cs
index 0842dfff7..604caa704 100644
--- a/Source/Editor/Content/Items/ContentItem.cs
+++ b/Source/Editor/Content/Items/ContentItem.cs
@@ -745,7 +745,7 @@ namespace FlaxEditor.Content
// Draw short name
Render2D.PushClip(ref textRect);
- FallbackTextUtils.DrawText(style.FontMedium, ShowFileExtension || view.ShowFileExtensions ? FileName : ShortName, textRect, style.Foreground, nameAlignment, TextAlignment.Center, TextWrapping.WrapWords, 1f, 0.95f);
+ Render2D.DrawText(style.FontMedium, ShowFileExtension || view.ShowFileExtensions ? FileName : ShortName, textRect, style.Foreground, nameAlignment, TextAlignment.Center, TextWrapping.WrapWords, 1f, 0.95f);
Render2D.PopClip();
}
diff --git a/Source/Editor/Content/Tree/ContentTreeNode.cs b/Source/Editor/Content/Tree/ContentTreeNode.cs
index 2f378e7f5..e2cd1e771 100644
--- a/Source/Editor/Content/Tree/ContentTreeNode.cs
+++ b/Source/Editor/Content/Tree/ContentTreeNode.cs
@@ -150,8 +150,8 @@ namespace FlaxEditor.Content
var textRect = TextRect;
for (int i = 0; i < ranges.Length; i++)
{
- var start = FallbackTextUtils.GetCharPosition(font, text, ranges[i].StartIndex);
- var end = FallbackTextUtils.GetCharPosition(font, text, ranges[i].EndIndex);
+ var start = font.GetCharPosition(text, ranges[i].StartIndex);
+ var end = font.GetCharPosition(text, ranges[i].EndIndex);
_highlights.Add(new Rectangle(start.X + textRect.X, textRect.Y, end.X - start.X, textRect.Height));
}
isThisVisible = true;
diff --git a/Source/Editor/CustomEditors/Dedicated/MeshReferenceEditor.cs b/Source/Editor/CustomEditors/Dedicated/MeshReferenceEditor.cs
index 66c1c791f..4099e5aee 100644
--- a/Source/Editor/CustomEditors/Dedicated/MeshReferenceEditor.cs
+++ b/Source/Editor/CustomEditors/Dedicated/MeshReferenceEditor.cs
@@ -109,7 +109,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
{
// Draw name
Render2D.PushClip(nameRect);
- FallbackTextUtils.DrawText(style.FontMedium, _valueName, nameRect, isEnabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, _valueName, nameRect, isEnabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
Render2D.PopClip();
// Draw deselect button
@@ -118,7 +118,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
else
{
// Draw info
- FallbackTextUtils.DrawText(style.FontMedium, "-", nameRect, isEnabled ? Color.OrangeRed : Color.DarkOrange, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "-", nameRect, isEnabled ? Color.OrangeRed : Color.DarkOrange, TextAlignment.Near, TextAlignment.Center);
}
// Draw picker button
diff --git a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs
index 017fd7655..d7bfbbad7 100644
--- a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs
+++ b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs
@@ -42,7 +42,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
// Add script button
var buttonText = "Add script";
- var textSize = FallbackTextUtils.MeasureText(Style.Current.FontMedium, buttonText);
+ var textSize = Style.Current.FontMedium.MeasureText(buttonText);
float addScriptButtonWidth = (textSize.X < 60.0f) ? 60.0f : textSize.X + 4;
var buttonHeight = (textSize.Y < 18) ? 18 : textSize.Y + 4;
_addScriptsButton = new Button
@@ -86,7 +86,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
var size = Size;
// Info
- FallbackTextUtils.DrawText(style.FontSmall, "Drag scripts here", new Rectangle(2, _addScriptsButton.Height + 4, size.X - 4, size.Y - 4 - 20), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, "Drag scripts here", new Rectangle(2, _addScriptsButton.Height + 4, size.X - 4, size.Y - 4 - 20), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
// Check if drag is over
if (IsDragOver && _dragHandlers != null && _dragHandlers.HasValidDrag)
diff --git a/Source/Editor/CustomEditors/Dedicated/SplineEditor.cs b/Source/Editor/CustomEditors/Dedicated/SplineEditor.cs
index fa4379db1..7b9b65c5c 100644
--- a/Source/Editor/CustomEditors/Dedicated/SplineEditor.cs
+++ b/Source/Editor/CustomEditors/Dedicated/SplineEditor.cs
@@ -226,7 +226,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
if (!enabled)
color *= 0.6f;
Render2D.DrawSprite(tab._customIcon, iconRect, color);
- FallbackTextUtils.DrawText(style.FontMedium, tab._customText, new Rectangle(0, iconSize, size.X, textHeight), color, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, tab._customText, new Rectangle(0, iconSize, size.X, textHeight), color, TextAlignment.Center, TextAlignment.Center);
}
}
diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
index 4efbee259..296560507 100644
--- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
+++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
@@ -423,7 +423,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
// Set control type button
var space = layout.Space(20);
var buttonText = "Set Type";
- var textSize = FallbackTextUtils.MeasureText(FlaxEngine.GUI.Style.Current.FontMedium, buttonText);
+ var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(buttonText);
float setTypeButtonWidth = (textSize.X < 60.0f) ? 60.0f : textSize.X + 4;
var setTypeButton = new Button
{
diff --git a/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs b/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs
index d8d16027b..4c153e759 100644
--- a/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs
@@ -100,7 +100,7 @@ namespace FlaxEditor.CustomEditors.Editors
_linkButton.Clicked += ToggleLink;
ToggleEnabled();
SetLinkStyle();
- var textSize = FallbackTextUtils.MeasureText(FlaxEngine.GUI.Style.Current.FontMedium, LinkedLabel.Text.Value);
+ var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
_linkButton.LocalX += textSize.X + 10;
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
{
diff --git a/Source/Editor/CustomEditors/Editors/FlaxObjectRefEditor.cs b/Source/Editor/CustomEditors/Editors/FlaxObjectRefEditor.cs
index 2f64ea159..731da3817 100644
--- a/Source/Editor/CustomEditors/Editors/FlaxObjectRefEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/FlaxObjectRefEditor.cs
@@ -199,7 +199,7 @@ namespace FlaxEditor.CustomEditors.Editors
{
// Draw name
Render2D.PushClip(nameRect);
- FallbackTextUtils.DrawText(style.FontMedium, _valueName, nameRect, isEnabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, _valueName, nameRect, isEnabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
Render2D.PopClip();
// Draw deselect button
@@ -208,7 +208,7 @@ namespace FlaxEditor.CustomEditors.Editors
else
{
// Draw info
- FallbackTextUtils.DrawText(style.FontMedium, "-", nameRect, isEnabled ? Color.OrangeRed : Color.DarkOrange, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "-", nameRect, isEnabled ? Color.OrangeRed : Color.DarkOrange, TextAlignment.Near, TextAlignment.Center);
}
// Draw picker button
diff --git a/Source/Editor/CustomEditors/Editors/TagEditor.cs b/Source/Editor/CustomEditors/Editors/TagEditor.cs
index bbece7e04..dbd5d124c 100644
--- a/Source/Editor/CustomEditors/Editors/TagEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/TagEditor.cs
@@ -631,7 +631,7 @@ namespace FlaxEditor.CustomEditors.Editors
TooltipText = "Edit...",
Parent = _label,
};
- var textSize = FallbackTextUtils.MeasureText(FlaxEngine.GUI.Style.Current.FontMedium, buttonText);
+ var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(buttonText);
if (textSize.Y > button.Width)
button.Width = textSize.Y + 2;
diff --git a/Source/Editor/CustomEditors/Editors/TypeEditor.cs b/Source/Editor/CustomEditors/Editors/TypeEditor.cs
index 4d0b90383..38800a738 100644
--- a/Source/Editor/CustomEditors/Editors/TypeEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/TypeEditor.cs
@@ -160,13 +160,13 @@ namespace FlaxEditor.CustomEditors.Editors
// Draw name
Render2D.PushClip(nameRect);
- FallbackTextUtils.DrawText(style.FontMedium, _valueName, nameRect, style.Foreground, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, _valueName, nameRect, style.Foreground, TextAlignment.Near, TextAlignment.Center);
Render2D.PopClip();
}
else
{
// Draw info
- FallbackTextUtils.DrawText(style.FontMedium, "-", nameRect, Color.OrangeRed, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "-", nameRect, Color.OrangeRed, TextAlignment.Near, TextAlignment.Center);
}
// Draw picker button
diff --git a/Source/Editor/GUI/AssetPicker.cs b/Source/Editor/GUI/AssetPicker.cs
index 2abe5db38..84f58daf1 100644
--- a/Source/Editor/GUI/AssetPicker.cs
+++ b/Source/Editor/GUI/AssetPicker.cs
@@ -139,7 +139,7 @@ namespace FlaxEditor.GUI
float sizeForTextLeft = Width - button1Rect.Right;
if (sizeForTextLeft > 30)
{
- FallbackTextUtils.DrawText(
+ Render2D.DrawText(
style.FontSmall,
Validator.SelectedItem.ShortName,
new Rectangle(button1Rect.Right + 2, 0, sizeForTextLeft, ButtonsSize),
@@ -161,7 +161,7 @@ namespace FlaxEditor.GUI
var name = Validator.SelectedAsset.GetType().Name;
if (Validator.SelectedAsset.IsVirtual)
name += " (virtual)";
- FallbackTextUtils.DrawText(
+ Render2D.DrawText(
style.FontSmall,
name,
new Rectangle(button1Rect.Right + 2, 0, sizeForTextLeft, ButtonsSize),
@@ -174,7 +174,7 @@ namespace FlaxEditor.GUI
{
// No element selected
Render2D.FillRectangle(iconRect, style.BackgroundNormal);
- FallbackTextUtils.DrawText(style.FontMedium, "No asset\nselected", iconRect, Color.Orange, TextAlignment.Center, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, Height / DefaultIconSize);
+ Render2D.DrawText(style.FontMedium, "No asset\nselected", iconRect, Color.Orange, TextAlignment.Center, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, Height / DefaultIconSize);
}
// Check if drag is over
diff --git a/Source/Editor/GUI/ComboBox.cs b/Source/Editor/GUI/ComboBox.cs
index 8f3a7cb4b..0417cc7e3 100644
--- a/Source/Editor/GUI/ComboBox.cs
+++ b/Source/Editor/GUI/ComboBox.cs
@@ -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;
- FallbackTextUtils.DrawText(Font.GetFont(), 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();
}
diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuButton.cs b/Source/Editor/GUI/ContextMenu/ContextMenuButton.cs
index 035e997e9..e371f7c4b 100644
--- a/Source/Editor/GUI/ContextMenu/ContextMenuButton.cs
+++ b/Source/Editor/GUI/ContextMenu/ContextMenuButton.cs
@@ -128,12 +128,12 @@ namespace FlaxEditor.GUI.ContextMenu
base.Draw();
// Draw text
- FallbackTextUtils.DrawText(style.FontMedium, Text, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, Text, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
if (!string.IsNullOrEmpty(ShortKeys))
{
// Draw short keys
- FallbackTextUtils.DrawText(style.FontMedium, ShortKeys, textRect, textColor, TextAlignment.Far, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, ShortKeys, textRect, textColor, TextAlignment.Far, TextAlignment.Center);
}
// Draw icon
@@ -235,9 +235,9 @@ namespace FlaxEditor.GUI.ContextMenu
float width = 20;
if (style.FontMedium)
{
- width += FallbackTextUtils.MeasureText(style.FontMedium, Text).X;
+ width += style.FontMedium.MeasureText(Text).X;
if (!string.IsNullOrEmpty(ShortKeys))
- width += 40 + FallbackTextUtils.MeasureText(style.FontMedium, ShortKeys).X;
+ width += 40 + style.FontMedium.MeasureText(ShortKeys).X;
}
return Mathf.Max(width, base.MinimumWidth);
diff --git a/Source/Editor/GUI/CurveEditor.cs b/Source/Editor/GUI/CurveEditor.cs
index f4839acd5..22deec120 100644
--- a/Source/Editor/GUI/CurveEditor.cs
+++ b/Source/Editor/GUI/CurveEditor.cs
@@ -832,7 +832,7 @@ namespace FlaxEditor.GUI
50,
LabelsSize
);
- FallbackTextUtils.DrawText(_labelsFont, label, labelRect, _labelsColor.AlphaMultiplied(strength), TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, 0.7f);
+ Render2D.DrawText(_labelsFont, label, labelRect, _labelsColor.AlphaMultiplied(strength), TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, 0.7f);
}
}
}
diff --git a/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs b/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs
index 8b1881faf..27878a763 100644
--- a/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs
+++ b/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs
@@ -281,33 +281,33 @@ namespace FlaxEditor.GUI.Dialogs
// RGBA
var rgbaR = new Rectangle(_cRed.Left - ChannelTextWidth, _cRed.Y, 10000, _cRed.Height);
- FallbackTextUtils.DrawText(style.FontMedium, "R", rgbaR, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "R", rgbaR, textColor, TextAlignment.Near, TextAlignment.Center);
rgbaR.Location.Y = _cGreen.Y;
- FallbackTextUtils.DrawText(style.FontMedium, "G", rgbaR, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "G", rgbaR, textColor, TextAlignment.Near, TextAlignment.Center);
rgbaR.Location.Y = _cBlue.Y;
- FallbackTextUtils.DrawText(style.FontMedium, "B", rgbaR, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "B", rgbaR, textColor, TextAlignment.Near, TextAlignment.Center);
rgbaR.Location.Y = _cAlpha.Y;
- FallbackTextUtils.DrawText(style.FontMedium, "A", rgbaR, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "A", rgbaR, textColor, TextAlignment.Near, TextAlignment.Center);
// HSV left
var hsvHl = new Rectangle(_cHue.Left - ChannelTextWidth, _cHue.Y, 10000, _cHue.Height);
- FallbackTextUtils.DrawText(style.FontMedium, "H", hsvHl, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "H", hsvHl, textColor, TextAlignment.Near, TextAlignment.Center);
hsvHl.Location.Y = _cSaturation.Y;
- FallbackTextUtils.DrawText(style.FontMedium, "S", hsvHl, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "S", hsvHl, textColor, TextAlignment.Near, TextAlignment.Center);
hsvHl.Location.Y = _cValue.Y;
- FallbackTextUtils.DrawText(style.FontMedium, "V", hsvHl, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "V", hsvHl, textColor, TextAlignment.Near, TextAlignment.Center);
// HSV right
var hsvHr = new Rectangle(_cHue.Right + 2, _cHue.Y, 10000, _cHue.Height);
- FallbackTextUtils.DrawText(style.FontMedium, "°", hsvHr, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "°", hsvHr, textColor, TextAlignment.Near, TextAlignment.Center);
hsvHr.Location.Y = _cSaturation.Y;
- FallbackTextUtils.DrawText(style.FontMedium, "%", hsvHr, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "%", hsvHr, textColor, TextAlignment.Near, TextAlignment.Center);
hsvHr.Location.Y = _cValue.Y;
- FallbackTextUtils.DrawText(style.FontMedium, "%", hsvHr, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "%", hsvHr, textColor, TextAlignment.Near, TextAlignment.Center);
// Hex
var hex = new Rectangle(_cHex.Left - 26, _cHex.Y, 10000, _cHex.Height);
- FallbackTextUtils.DrawText(style.FontMedium, "Hex", hex, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, "Hex", hex, textColor, TextAlignment.Near, TextAlignment.Center);
// Color difference
var newRect = new Rectangle(_cOK.X, _cHex.Bottom + PickerMargin, _cCancel.Right - _cOK.Left, 0);
diff --git a/Source/Editor/GUI/Docking/DockPanelProxy.cs b/Source/Editor/GUI/Docking/DockPanelProxy.cs
index 0b36b85fa..e6e57de8e 100644
--- a/Source/Editor/GUI/Docking/DockPanelProxy.cs
+++ b/Source/Editor/GUI/Docking/DockPanelProxy.cs
@@ -208,7 +208,7 @@ namespace FlaxEditor.GUI.Docking
}
// Draw text
- FallbackTextUtils.DrawText(
+ Render2D.DrawText(
style.FontMedium,
tab.Title,
new Rectangle(DockPanel.DefaultLeftTextMargin + iconWidth, 0, Width - DockPanel.DefaultLeftTextMargin - DockPanel.DefaultButtonsSize - 2 * DockPanel.DefaultButtonsMargin, DockPanel.DefaultHeaderHeight),
@@ -271,7 +271,7 @@ namespace FlaxEditor.GUI.Docking
}
// Draw text
- FallbackTextUtils.DrawText(
+ Render2D.DrawText(
style.FontMedium,
tab.Title,
new Rectangle(x + DockPanel.DefaultLeftTextMargin + iconWidth, 0, 10000, DockPanel.DefaultHeaderHeight),
diff --git a/Source/Editor/GUI/Docking/DockWindow.cs b/Source/Editor/GUI/Docking/DockWindow.cs
index 561c898a0..dd4e39ce2 100644
--- a/Source/Editor/GUI/Docking/DockWindow.cs
+++ b/Source/Editor/GUI/Docking/DockWindow.cs
@@ -488,7 +488,7 @@ namespace FlaxEditor.GUI.Docking
{
var style = Style.Current;
if (style?.FontMedium != null)
- _titleSize = FallbackTextUtils.MeasureText(style.FontMedium, _title);
+ _titleSize = style.FontMedium.MeasureText(_title);
}
base.PerformLayoutBeforeChildren();
diff --git a/Source/Editor/GUI/ItemsListContextMenu.cs b/Source/Editor/GUI/ItemsListContextMenu.cs
index d3c433a47..42d236991 100644
--- a/Source/Editor/GUI/ItemsListContextMenu.cs
+++ b/Source/Editor/GUI/ItemsListContextMenu.cs
@@ -86,8 +86,8 @@ namespace FlaxEditor.GUI
var font = style.FontSmall;
for (int i = 0; i < ranges.Length; i++)
{
- var start = FallbackTextUtils.GetCharPosition(font, Name, ranges[i].StartIndex);
- var end = FallbackTextUtils.GetCharPosition(font, Name, ranges[i].EndIndex);
+ var start = font.GetCharPosition(Name, ranges[i].StartIndex);
+ var end = font.GetCharPosition(Name, ranges[i].EndIndex);
_highlights.Add(new Rectangle(start.X + 2, 0, end.X - start.X, Height));
}
Visible = true;
@@ -136,7 +136,7 @@ namespace FlaxEditor.GUI
}
// Draw name
- FallbackTextUtils.DrawText(style.FontSmall, Name, textRect, TintColor * (Enabled ? style.Foreground : style.ForegroundDisabled), TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, Name, textRect, TintColor * (Enabled ? style.Foreground : style.ForegroundDisabled), TextAlignment.Near, TextAlignment.Center);
}
///
diff --git a/Source/Editor/GUI/MainMenuButton.cs b/Source/Editor/GUI/MainMenuButton.cs
index 43849f4ab..117922361 100644
--- a/Source/Editor/GUI/MainMenuButton.cs
+++ b/Source/Editor/GUI/MainMenuButton.cs
@@ -72,7 +72,7 @@ namespace FlaxEditor.GUI
}
// Draw text
- FallbackTextUtils.DrawText(style.FontMedium, Text, clientRect, enabled && hasChildItems ? style.Foreground : style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, Text, clientRect, enabled && hasChildItems ? style.Foreground : style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
///
@@ -102,7 +102,7 @@ namespace FlaxEditor.GUI
float width = 18;
if (style.FontMedium)
- width += FallbackTextUtils.MeasureText(style.FontMedium, Text).X;
+ width += style.FontMedium.MeasureText(Text).X;
Width = width;
}
diff --git a/Source/Editor/GUI/NavigationButton.cs b/Source/Editor/GUI/NavigationButton.cs
index 8dedf72fd..18e862304 100644
--- a/Source/Editor/GUI/NavigationButton.cs
+++ b/Source/Editor/GUI/NavigationButton.cs
@@ -57,7 +57,7 @@ namespace FlaxEditor.GUI
}
// Draw text
- FallbackTextUtils.DrawText(style.FontMedium, Text, textRect, EnabledInHierarchy ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, Text, textRect, EnabledInHierarchy ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
}
///
@@ -67,7 +67,7 @@ namespace FlaxEditor.GUI
if (style.FontMedium)
{
- Width = FallbackTextUtils.MeasureText(style.FontMedium, Text).X + 2 * DefaultMargin;
+ Width = style.FontMedium.MeasureText(Text).X + 2 * DefaultMargin;
}
}
}
diff --git a/Source/Editor/GUI/Row.cs b/Source/Editor/GUI/Row.cs
index 9868ab456..43785c735 100644
--- a/Source/Editor/GUI/Row.cs
+++ b/Source/Editor/GUI/Row.cs
@@ -38,7 +38,7 @@ namespace FlaxEditor.GUI
{
Depth = -1;
- var mediumHeight = FallbackTextUtils.GetMaxHeight(Style.Current.FontMedium);
+ var mediumHeight = Style.Current.FontMedium.GetMaxHeight();
if (Height < mediumHeight)
Height = mediumHeight + 4;
}
@@ -99,7 +99,7 @@ namespace FlaxEditor.GUI
rect.Width -= leftDepthMargin;
Render2D.PushClip(rect);
- FallbackTextUtils.DrawText(style.FontMedium, text, rect, style.Foreground, column.CellAlignment, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, text, rect, style.Foreground, column.CellAlignment, TextAlignment.Center);
Render2D.PopClip();
x += width;
diff --git a/Source/Editor/GUI/StatusBar.cs b/Source/Editor/GUI/StatusBar.cs
index 7770af9a1..f8f7ae839 100644
--- a/Source/Editor/GUI/StatusBar.cs
+++ b/Source/Editor/GUI/StatusBar.cs
@@ -56,7 +56,7 @@ namespace FlaxEditor.GUI
Render2D.DrawSprite(style.StatusBarSizeGrip, new Rectangle(Width - 12, 10, 12, 12), style.Foreground);
// Draw status text
- FallbackTextUtils.DrawText(style.FontSmall, Text, new Rectangle(4, 0, Width - 20, Height), TextColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, Text, new Rectangle(4, 0, Width - 20, Height), TextColor, TextAlignment.Near, TextAlignment.Center);
}
}
}
diff --git a/Source/Editor/GUI/StyleValueEditor.cs b/Source/Editor/GUI/StyleValueEditor.cs
index db6696152..a89902177 100644
--- a/Source/Editor/GUI/StyleValueEditor.cs
+++ b/Source/Editor/GUI/StyleValueEditor.cs
@@ -157,7 +157,7 @@ namespace FlaxEditor.GUI
{
Rectangle textRectangle = r;
textRectangle.X = 4;
- FallbackTextUtils.DrawText(style.FontMedium, "No Style", textRectangle, style.Foreground);
+ Render2D.DrawText(style.FontMedium, "No Style", textRectangle, style.Foreground);
}
}
diff --git a/Source/Editor/GUI/Table.cs b/Source/Editor/GUI/Table.cs
index 2358557c3..1d22ddb15 100644
--- a/Source/Editor/GUI/Table.cs
+++ b/Source/Editor/GUI/Table.cs
@@ -130,7 +130,7 @@ namespace FlaxEditor.GUI
var style = Style.Current;
var font = column.TitleFont ?? style.FontMedium;
- FallbackTextUtils.DrawText(font, column.Title, rect, column.TitleColor, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(font, column.Title, rect, column.TitleColor, TextAlignment.Center, TextAlignment.Center);
if (columnIndex < _columns.Length - 1)
{
diff --git a/Source/Editor/GUI/Tabs/Tabs.cs b/Source/Editor/GUI/Tabs/Tabs.cs
index 5995c7ef5..3c70363e7 100644
--- a/Source/Editor/GUI/Tabs/Tabs.cs
+++ b/Source/Editor/GUI/Tabs/Tabs.cs
@@ -98,7 +98,7 @@ namespace FlaxEditor.GUI.Tabs
// Draw text
if (!string.IsNullOrEmpty(Tab.Text))
{
- FallbackTextUtils.DrawText(style.FontMedium, Tab.Text, new Rectangle(tabRect.X + textOffset, tabRect.Y, tabRect.Width - textOffset, tabRect.Height), style.Foreground, Tabs.TabsTextHorizontalAlignment, Tabs.TabsTextVerticalAlignment);
+ Render2D.DrawText(style.FontMedium, Tab.Text, new Rectangle(tabRect.X + textOffset, tabRect.Y, tabRect.Width - textOffset, tabRect.Height), style.Foreground, Tabs.TabsTextHorizontalAlignment, Tabs.TabsTextVerticalAlignment);
}
}
}
diff --git a/Source/Editor/GUI/Timeline/GUI/Background.cs b/Source/Editor/GUI/Timeline/GUI/Background.cs
index 05c1121c0..b9eff562a 100644
--- a/Source/Editor/GUI/Timeline/GUI/Background.cs
+++ b/Source/Editor/GUI/Timeline/GUI/Background.cs
@@ -301,7 +301,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
default: throw new ArgumentOutOfRangeException();
}
var labelRect = new Rectangle(x + 2, -verticalLinesHeaderExtend * 0.8f + timeAxisHeaderOffset, 50, verticalLinesHeaderExtend);
- FallbackTextUtils.DrawText(style.FontSmall, labelText, labelRect, labelColor, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, 0.8f);
+ Render2D.DrawText(style.FontSmall, labelText, labelRect, labelColor, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, 0.8f);
}
}
}
diff --git a/Source/Editor/GUI/Timeline/Track.cs b/Source/Editor/GUI/Timeline/Track.cs
index 20be8f0c2..f38917aa6 100644
--- a/Source/Editor/GUI/Timeline/Track.cs
+++ b/Source/Editor/GUI/Timeline/Track.cs
@@ -965,7 +965,7 @@ namespace FlaxEditor.GUI.Timeline
}
// Draw text
- FallbackTextUtils.DrawText(style.FontSmall, Title ?? Name, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, Title ?? Name, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
// Disabled overlay
DrawDisabled = Mute || (ParentTrack != null && ParentTrack.DrawDisabled);
diff --git a/Source/Editor/GUI/Timeline/Tracks/MemberTrack.cs b/Source/Editor/GUI/Timeline/Tracks/MemberTrack.cs
index dd79922ac..63787df2c 100644
--- a/Source/Editor/GUI/Timeline/Tracks/MemberTrack.cs
+++ b/Source/Editor/GUI/Timeline/Tracks/MemberTrack.cs
@@ -345,7 +345,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
if (_previewValue != null)
{
// Based on Track.Draw for track text placement
- var left = _xOffset + 16 + FallbackTextUtils.MeasureText(Style.Current.FontSmall, Title ?? Name).X;
+ var left = _xOffset + 16 + Style.Current.FontSmall.MeasureText(Title ?? Name).X;
if (Icon.IsValid)
left += 18;
if (IsExpanded)
diff --git a/Source/Editor/GUI/ToolStripButton.cs b/Source/Editor/GUI/ToolStripButton.cs
index c4f4603e2..e839a7356 100644
--- a/Source/Editor/GUI/ToolStripButton.cs
+++ b/Source/Editor/GUI/ToolStripButton.cs
@@ -136,7 +136,7 @@ namespace FlaxEditor.GUI
if (!string.IsNullOrEmpty(_text))
{
textRect.Size.X = Width - DefaultMargin - textRect.Left;
- FallbackTextUtils.DrawText(style.FontMedium, _text, textRect, enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, _text, textRect, enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
}
}
@@ -151,7 +151,7 @@ namespace FlaxEditor.GUI
if (hasSprite)
width += iconSize;
if (!string.IsNullOrEmpty(_text) && style.FontMedium)
- width += FallbackTextUtils.MeasureText(style.FontMedium, _text).X + (hasSprite ? DefaultMargin : 0);
+ width += style.FontMedium.MeasureText(_text).X + (hasSprite ? DefaultMargin : 0);
Width = width;
}
diff --git a/Source/Editor/GUI/Tree/TreeNode.cs b/Source/Editor/GUI/Tree/TreeNode.cs
index 6680e3608..703079469 100644
--- a/Source/Editor/GUI/Tree/TreeNode.cs
+++ b/Source/Editor/GUI/Tree/TreeNode.cs
@@ -575,7 +575,7 @@ namespace FlaxEditor.GUI.Tree
var font = TextFont.GetFont();
if (font)
{
- _textWidth = FallbackTextUtils.MeasureText(font, _text).X;
+ _textWidth = font.MeasureText(_text).X;
_textChanged = false;
}
}
@@ -656,7 +656,7 @@ namespace FlaxEditor.GUI.Tree
}
// Draw text
- FallbackTextUtils.DrawText(TextFont.GetFont(), _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)
diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs
index dc376a0a2..bf35105a5 100644
--- a/Source/Editor/Options/OptionsModule.cs
+++ b/Source/Editor/Options/OptionsModule.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using FlaxEditor.Content.Settings;
using FlaxEditor.Modules;
using FlaxEngine;
using FlaxEngine.GUI;
@@ -224,7 +225,11 @@ namespace FlaxEditor.Options
}
}
- FallbackTextUtils.Fallbacks = FallbackFonts.Create(Options.Interface.Fallbacks);
+ var graphicsSetttings = GameSettings.Load();
+ if (graphicsSetttings.EnableFontFallback && graphicsSetttings.FallbackFonts == null)
+ {
+ Render2D.FallbackFonts = graphicsSetttings.FallbackFonts = FontFallbackList.Create(Options.Interface.Fallbacks);
+ }
}
///
diff --git a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs
index eefd7f4dd..f64e46385 100644
--- a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs
+++ b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs
@@ -142,8 +142,8 @@ namespace FlaxEditor.SceneGraph.GUI
var textRect = TextRect;
for (int i = 0; i < ranges.Length; i++)
{
- var start = FallbackTextUtils.GetCharPosition(font, text, ranges[i].StartIndex);
- var end = FallbackTextUtils.GetCharPosition(font, text, ranges[i].EndIndex);
+ var start = font.GetCharPosition(text, ranges[i].StartIndex);
+ var end = font.GetCharPosition(text, ranges[i].EndIndex);
_highlights.Add(new Rectangle(start.X + textRect.X, textRect.Y, end.X - start.X, textRect.Height));
}
isThisVisible = true;
diff --git a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs
index be9a96a7d..621c7c25e 100644
--- a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs
+++ b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs
@@ -337,7 +337,7 @@ namespace FlaxEditor.Surface.Archetypes
_textRect = new Rectangle(Float2.Zero, Size);
var style = Style.Current;
- var titleSize = FallbackTextUtils.MeasureText(style.FontLarge, Title);
+ var titleSize = style.FontLarge.MeasureText(Title);
var width = Mathf.Max(100, titleSize.X + 50);
Resize(width, 0);
titleSize.X += 8.0f;
@@ -379,7 +379,7 @@ namespace FlaxEditor.Surface.Archetypes
}
// Name
- FallbackTextUtils.DrawText(style.FontLarge, Title, _textRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, Title, _textRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
}
///
@@ -1128,7 +1128,7 @@ namespace FlaxEditor.Surface.Archetypes
}
// Name
- FallbackTextUtils.DrawText(style.FontLarge, Title, _textRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, Title, _textRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
// Close button
Render2D.DrawSprite(style.Cross, _closeButtonRect, _closeButtonRect.Contains(_mousePosition) ? style.Foreground : style.ForegroundGrey);
@@ -1402,7 +1402,7 @@ namespace FlaxEditor.Surface.Archetypes
{
Title = StateTitle;
var style = Style.Current;
- var titleSize = FallbackTextUtils.MeasureText(style.FontLarge, Title);
+ var titleSize = style.FontLarge.MeasureText(Title);
var width = Mathf.Max(100, titleSize.X + 50);
Resize(width, 0);
titleSize.X += 8.0f;
diff --git a/Source/Editor/Surface/Archetypes/Animation.cs b/Source/Editor/Surface/Archetypes/Animation.cs
index dae16b425..40a3d2a63 100644
--- a/Source/Editor/Surface/Archetypes/Animation.cs
+++ b/Source/Editor/Surface/Archetypes/Animation.cs
@@ -77,7 +77,7 @@ namespace FlaxEditor.Surface.Archetypes
Title = asset?.ShortName ?? "Animation";
var style = Style.Current;
- Resize(Mathf.Max(230, FallbackTextUtils.MeasureText(style.FontLarge, Title).X + 30), 160);
+ Resize(Mathf.Max(230, style.FontLarge.MeasureText(Title).X + 30), 160);
}
///
diff --git a/Source/Editor/Surface/Archetypes/BehaviorTree.cs b/Source/Editor/Surface/Archetypes/BehaviorTree.cs
index b240685cc..f8cd7bb5a 100644
--- a/Source/Editor/Surface/Archetypes/BehaviorTree.cs
+++ b/Source/Editor/Surface/Archetypes/BehaviorTree.cs
@@ -100,7 +100,7 @@ namespace FlaxEditor.Surface.Archetypes
_debugRelevant = Behavior.GetNodeDebugRelevancy(instance, behavior);
_debugInfo = Behavior.GetNodeDebugInfo(instance, behavior);
if (!string.IsNullOrEmpty(_debugInfo))
- _debugInfoSize = FallbackTextUtils.MeasureText(Style.Current.FontSmall, _debugInfo);
+ _debugInfoSize = Style.Current.FontSmall.MeasureText(_debugInfo);
}
}
@@ -184,7 +184,7 @@ namespace FlaxEditor.Surface.Archetypes
if (!string.IsNullOrEmpty(_debugInfo))
{
var style = Style.Current;
- FallbackTextUtils.DrawText(style.FontSmall, _debugInfo, new Rectangle(4, _headerRect.Bottom + 4, _debugInfoSize), style.Foreground);
+ Render2D.DrawText(style.FontSmall, _debugInfo, new Rectangle(4, _headerRect.Bottom + 4, _debugInfoSize), style.Foreground);
}
// Debug relevancy outline
@@ -487,7 +487,7 @@ namespace FlaxEditor.Surface.Archetypes
var height = 0.0f;
var titleLabelFont = Style.Current.FontLarge;
width = Mathf.Max(width, 100.0f);
- width = Mathf.Max(width, FallbackTextUtils.MeasureText(titleLabelFont, Title).X + 30);
+ width = Mathf.Max(width, titleLabelFont.MeasureText(Title).X + 30);
if (_debugInfoSize.X > 0)
{
width = Mathf.Max(width, _debugInfoSize.X + 8.0f);
diff --git a/Source/Editor/Surface/Archetypes/ParticleModules.cs b/Source/Editor/Surface/Archetypes/ParticleModules.cs
index 6082e212e..e5be3d35d 100644
--- a/Source/Editor/Surface/Archetypes/ParticleModules.cs
+++ b/Source/Editor/Surface/Archetypes/ParticleModules.cs
@@ -113,7 +113,7 @@ namespace FlaxEditor.Surface.Archetypes
var idx = (int)ModuleType;
var headerRect = new Rectangle(0, 0, Width, 16.0f);
//Render2D.FillRectangle(headerRect, Color.Red);
- FallbackTextUtils.DrawText(style.FontMedium, Title, headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, Title, headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
DrawChildren();
diff --git a/Source/Editor/Surface/Archetypes/Particles.cs b/Source/Editor/Surface/Archetypes/Particles.cs
index bf7828960..40b38f7ce 100644
--- a/Source/Editor/Surface/Archetypes/Particles.cs
+++ b/Source/Editor/Surface/Archetypes/Particles.cs
@@ -154,7 +154,7 @@ namespace FlaxEditor.Surface.Archetypes
if (headerRect.Contains(mousePosition))
headerColor *= 1.07f;
Render2D.FillRectangle(headerRect, headerColor);
- FallbackTextUtils.DrawText(style.FontLarge, Names[idx], headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, Names[idx], headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
DrawChildren();
}
@@ -194,7 +194,7 @@ namespace FlaxEditor.Surface.Archetypes
if (_headerRect.Contains(ref _mousePosition))
headerColor *= 1.07f;
Render2D.FillRectangle(_headerRect, headerColor);
- FallbackTextUtils.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
DrawChildren();
diff --git a/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs b/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs
index f4976be67..207875a92 100644
--- a/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs
+++ b/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs
@@ -200,8 +200,8 @@ namespace FlaxEditor.Surface.ContextMenu
var font = style.FontSmall;
for (int i = 0; i < ranges.Length; i++)
{
- var start = FallbackTextUtils.GetCharPosition(font, _archetype.Title, ranges[i].StartIndex);
- var end = FallbackTextUtils.GetCharPosition(font, _archetype.Title, ranges[i].EndIndex);
+ var start = font.GetCharPosition(_archetype.Title, ranges[i].StartIndex);
+ var end = font.GetCharPosition(_archetype.Title, ranges[i].EndIndex);
_highlights.Add(new Rectangle(start.X + textRect.X, 0, end.X - start.X, Height));
if (ranges[i].StartIndex <= 0)
@@ -222,8 +222,8 @@ namespace FlaxEditor.Surface.ContextMenu
_highlights.Clear();
var style = Style.Current;
var font = style.FontSmall;
- var start = FallbackTextUtils.GetCharPosition(font, _archetype.Title, 0);
- var end = FallbackTextUtils.GetCharPosition(font, _archetype.Title, _archetype.Title.Length - 1);
+ var start = font.GetCharPosition(_archetype.Title, 0);
+ var end = font.GetCharPosition(_archetype.Title, _archetype.Title.Length - 1);
_highlights.Add(new Rectangle(start.X + textRect.X, 0, end.X - start.X, Height));
_isFullMatch = true;
Visible = true;
@@ -237,8 +237,8 @@ namespace FlaxEditor.Surface.ContextMenu
_highlights.Clear();
var style = Style.Current;
var font = style.FontSmall;
- var start = FallbackTextUtils.GetCharPosition(font, _archetype.Title, 0);
- var end = FallbackTextUtils.GetCharPosition(font, _archetype.Title, _archetype.Title.Length - 1);
+ var start = font.GetCharPosition(_archetype.Title, 0);
+ var end = font.GetCharPosition(_archetype.Title, _archetype.Title.Length - 1);
_highlights.Add(new Rectangle(start.X + textRect.X, 0, end.X - start.X, Height));
Visible = true;
@@ -283,19 +283,19 @@ namespace FlaxEditor.Surface.ContextMenu
}
// Draw name
- FallbackTextUtils.DrawText(style.FontSmall, _archetype.Title, textRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, _archetype.Title, textRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
if (_archetype.SubTitle != null)
{
- var titleLength = FallbackTextUtils.MeasureText(style.FontSmall, _archetype.Title).X;
+ var titleLength = style.FontSmall.MeasureText(_archetype.Title).X;
var subTitleRect = new Rectangle(textRect.X + titleLength, textRect.Y, textRect.Width - titleLength, textRect.Height);
- FallbackTextUtils.DrawText(style.FontSmall, _archetype.SubTitle, subTitleRect, style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, _archetype.SubTitle, subTitleRect, style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
}
// Reset transform and draw score mark
if (showScoreHit)
{
Render2D.PopTransform();
- FallbackTextUtils.DrawText(style.FontSmall, "> ", textRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, "> ", textRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
}
}
diff --git a/Source/Editor/Surface/Elements/InputBox.cs b/Source/Editor/Surface/Elements/InputBox.cs
index a5a99b932..2047bcd1a 100644
--- a/Source/Editor/Surface/Elements/InputBox.cs
+++ b/Source/Editor/Surface/Elements/InputBox.cs
@@ -1428,7 +1428,7 @@ namespace FlaxEditor.Surface.Elements
if (_defaultValueEditor != null)
{
- _defaultValueEditor.Location = new Float2(X + Width + 8 + FallbackTextUtils.MeasureText(Style.Current.FontSmall, Text).X, Y);
+ _defaultValueEditor.Location = new Float2(X + Width + 8 + Style.Current.FontSmall.MeasureText(Text).X, Y);
}
}
@@ -1443,7 +1443,7 @@ namespace FlaxEditor.Surface.Elements
// Draw text
var style = Style.Current;
var rect = new Rectangle(Width + 4, 0, 1410, Height);
- FallbackTextUtils.DrawText(style.FontSmall, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
}
///
@@ -1635,7 +1635,7 @@ namespace FlaxEditor.Surface.Elements
{
if (DefaultValueEditors[i].CanUse(this, ref _currentType))
{
- var bounds = new Rectangle(X + Width + 8 + FallbackTextUtils.MeasureText(Style.Current.FontSmall, Text).X, Y, 90, Height);
+ var bounds = new Rectangle(X + Width + 8 + Style.Current.FontSmall.MeasureText(Text).X, Y, 90, Height);
_editor = DefaultValueEditors[i];
try
{
diff --git a/Source/Editor/Surface/Elements/OutputBox.cs b/Source/Editor/Surface/Elements/OutputBox.cs
index 5fb123700..497e2001a 100644
--- a/Source/Editor/Surface/Elements/OutputBox.cs
+++ b/Source/Editor/Surface/Elements/OutputBox.cs
@@ -189,7 +189,7 @@ namespace FlaxEditor.Surface.Elements
// Draw text
var style = Style.Current;
var rect = new Rectangle(-100, 0, 100 - 2, Height);
- FallbackTextUtils.DrawText(style.FontSmall, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Far, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Far, TextAlignment.Center);
}
}
}
diff --git a/Source/Editor/Surface/Elements/TextView.cs b/Source/Editor/Surface/Elements/TextView.cs
index c52667fe3..284497396 100644
--- a/Source/Editor/Surface/Elements/TextView.cs
+++ b/Source/Editor/Surface/Elements/TextView.cs
@@ -25,7 +25,7 @@ namespace FlaxEditor.Surface.Elements
var style = Style.Current;
var color = Enabled ? style.Foreground : style.ForegroundDisabled;
- FallbackTextUtils.DrawText(style.FontSmall, Archetype.Text, new Rectangle(Float2.Zero, Size), color, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontSmall, Archetype.Text, new Rectangle(Float2.Zero, Size), color, TextAlignment.Near, TextAlignment.Center);
}
}
}
diff --git a/Source/Editor/Surface/SurfaceComment.cs b/Source/Editor/Surface/SurfaceComment.cs
index 26cc912ab..aad45190e 100644
--- a/Source/Editor/Surface/SurfaceComment.cs
+++ b/Source/Editor/Surface/SurfaceComment.cs
@@ -169,7 +169,7 @@ namespace FlaxEditor.Surface
// Header
Render2D.FillRectangle(_headerRect, headerColor);
- FallbackTextUtils.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
// Close button
Render2D.DrawSprite(style.Cross, _closeButtonRect, _closeButtonRect.Contains(_mousePosition) && Surface.CanEdit ? style.Foreground : style.ForegroundGrey);
diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs
index df706faa6..780ef81f0 100644
--- a/Source/Editor/Surface/SurfaceNode.cs
+++ b/Source/Editor/Surface/SurfaceNode.cs
@@ -199,7 +199,7 @@ namespace FlaxEditor.Surface
continue;
if (child is InputBox inputBox)
{
- var boxWidth = FallbackTextUtils.MeasureText(boxLabelFont, inputBox.Text).X + 20;
+ var boxWidth = boxLabelFont.MeasureText(inputBox.Text).X + 20;
if (inputBox.DefaultValueEditor != null)
boxWidth += inputBox.DefaultValueEditor.Width + 4;
leftWidth = Mathf.Max(leftWidth, boxWidth);
@@ -207,7 +207,7 @@ namespace FlaxEditor.Surface
}
else if (child is OutputBox outputBox)
{
- rightWidth = Mathf.Max(rightWidth, FallbackTextUtils.MeasureText(boxLabelFont, outputBox.Text).X + 20);
+ rightWidth = Mathf.Max(rightWidth, boxLabelFont.MeasureText(outputBox.Text).X + 20);
rightHeight = Mathf.Max(rightHeight, outputBox.Archetype.Position.Y - Constants.NodeMarginY - Constants.NodeHeaderSize + 20.0f);
}
else if (child is Control control)
@@ -225,7 +225,7 @@ namespace FlaxEditor.Surface
}
}
width = Mathf.Max(width, leftWidth + rightWidth + 10);
- width = Mathf.Max(width, FallbackTextUtils.MeasureText(titleLabelFont, Title).X + 30);
+ width = Mathf.Max(width, titleLabelFont.MeasureText(Title).X + 30);
height = Mathf.Max(height, Mathf.Max(leftHeight, rightHeight));
Resize(width, height);
}
@@ -1027,7 +1027,7 @@ namespace FlaxEditor.Surface
if (_headerRect.Contains(ref _mousePosition))
headerColor *= 1.07f;
Render2D.FillRectangle(_headerRect, headerColor);
- FallbackTextUtils.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
// Close button
if ((Archetype.Flags & NodeFlags.NoCloseButton) == 0 && Surface.CanEdit)
diff --git a/Source/Editor/Tools/Foliage/FoliageTab.cs b/Source/Editor/Tools/Foliage/FoliageTab.cs
index d36c3b6ed..1b46a42be 100644
--- a/Source/Editor/Tools/Foliage/FoliageTab.cs
+++ b/Source/Editor/Tools/Foliage/FoliageTab.cs
@@ -147,7 +147,7 @@ namespace FlaxEditor.Tools.Foliage
Parent = _noFoliagePanel,
Enabled = false
};
- var textSize = FallbackTextUtils.MeasureText(Style.Current.FontMedium, buttonText);
+ var textSize = Style.Current.FontMedium.MeasureText(buttonText);
if (_createNewFoliage.Width < textSize.X)
{
_createNewFoliage.LocalX -= (textSize.X - _createNewFoliage.Width) / 2;
diff --git a/Source/Editor/Tools/Terrain/CarveTab.cs b/Source/Editor/Tools/Terrain/CarveTab.cs
index e64a364f0..d51915acf 100644
--- a/Source/Editor/Tools/Terrain/CarveTab.cs
+++ b/Source/Editor/Tools/Terrain/CarveTab.cs
@@ -105,7 +105,7 @@ namespace FlaxEditor.Tools.Terrain
Parent = _noTerrainPanel,
Enabled = false
};
- var textSize = FallbackTextUtils.MeasureText(Style.Current.FontMedium, buttonText);
+ var textSize = Style.Current.FontMedium.MeasureText(buttonText);
if (_createTerrainButton.Width < textSize.X)
{
_createTerrainButton.LocalX -= (textSize.X - _createTerrainButton.Width) / 2;
diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs
index 515514131..c49392d01 100644
--- a/Source/Editor/Viewport/EditorViewport.cs
+++ b/Source/Editor/Viewport/EditorViewport.cs
@@ -548,9 +548,9 @@ namespace FlaxEditor.Viewport
#region Camera settings widget
var largestText = "Relative Panning";
- var textSize = FallbackTextUtils.MeasureText(Style.Current.FontMedium, largestText);
+ var textSize = Style.Current.FontMedium.MeasureText(largestText);
var xLocationForExtras = textSize.X + 5;
- var cameraSpeedTextWidth = FallbackTextUtils.MeasureText(Style.Current.FontMedium, "0.00").X;
+ var cameraSpeedTextWidth = Style.Current.FontMedium.MeasureText("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 = FallbackTextUtils.MeasureText(Style.Current.FontMedium, largestText);
+ textSize = Style.Current.FontMedium.MeasureText(largestText);
xLocationForExtras = textSize.X + 5;
var viewMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperLeft);
@@ -1233,8 +1233,8 @@ namespace FlaxEditor.Viewport
color = Color.Yellow;
var text = string.Format("FPS: {0}", fps);
var font = Style.Current.FontMedium;
- FallbackTextUtils.DrawText(font, text, new Rectangle(Float2.One, Size), Color.Black);
- FallbackTextUtils.DrawText(font, text, new Rectangle(Float2.Zero, Size), color);
+ Render2D.DrawText(font, text, new Rectangle(Float2.One, Size), Color.Black);
+ Render2D.DrawText(font, text, new Rectangle(Float2.Zero, Size), color);
}
}
@@ -1814,7 +1814,7 @@ namespace FlaxEditor.Viewport
{
var bounds = new Rectangle(Float2.Zero, Size);
Render2D.FillRectangle(bounds, new Color(0.0f, 0.0f, 0.0f, 0.2f));
- FallbackTextUtils.DrawText(Style.Current.FontLarge, "Debugger breakpoint hit...", bounds, Color.White, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(Style.Current.FontLarge, "Debugger breakpoint hit...", bounds, Color.White, TextAlignment.Center, TextAlignment.Center);
}
}
diff --git a/Source/Editor/Viewport/Previews/AnimationPreview.cs b/Source/Editor/Viewport/Previews/AnimationPreview.cs
index c4ada83c4..1679a36bc 100644
--- a/Source/Editor/Viewport/Previews/AnimationPreview.cs
+++ b/Source/Editor/Viewport/Previews/AnimationPreview.cs
@@ -96,11 +96,11 @@ namespace FlaxEditor.Viewport.Previews
var skinnedModel = SkinnedModel;
if (skinnedModel == null)
{
- FallbackTextUtils.DrawText(style.FontLarge, "Missing Base Model", new Rectangle(Float2.Zero, Size), Color.Red, TextAlignment.Center, TextAlignment.Center, TextWrapping.WrapWords);
+ Render2D.DrawText(style.FontLarge, "Missing Base Model", new Rectangle(Float2.Zero, Size), Color.Red, TextAlignment.Center, TextAlignment.Center, TextWrapping.WrapWords);
}
else if (!skinnedModel.IsLoaded)
{
- FallbackTextUtils.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
}
diff --git a/Source/Editor/Viewport/Previews/ModelPreview.cs b/Source/Editor/Viewport/Previews/ModelPreview.cs
index b31776bf6..a6496aafe 100644
--- a/Source/Editor/Viewport/Previews/ModelPreview.cs
+++ b/Source/Editor/Viewport/Previews/ModelPreview.cs
@@ -409,8 +409,8 @@ namespace FlaxEditor.Viewport.Previews
}
var font = Style.Current.FontMedium;
var pos = new Float2(10, 50);
- FallbackTextUtils.DrawText(font, text, new Rectangle(pos + Float2.One, Size), Color.Black);
- FallbackTextUtils.DrawText(font, text, new Rectangle(pos, Size), Color.White);
+ Render2D.DrawText(font, text, new Rectangle(pos + Float2.One, Size), Color.Black);
+ Render2D.DrawText(font, text, new Rectangle(pos, Size), Color.White);
}
}
diff --git a/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs b/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs
index a6eb721ce..c6ce5a7b5 100644
--- a/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs
+++ b/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs
@@ -254,7 +254,7 @@ namespace FlaxEditor.Viewport.Previews
if (_showParticlesCounter)
{
var count = _previewEffect.ParticlesCount;
- FallbackTextUtils.DrawText(
+ Render2D.DrawText(
Style.Current.FontSmall,
"Particles: " + count,
new Rectangle(Float2.Zero, Size),
diff --git a/Source/Editor/Viewport/Previews/SkinnedModelPreview.cs b/Source/Editor/Viewport/Previews/SkinnedModelPreview.cs
index 6c02c019a..8bcc506d9 100644
--- a/Source/Editor/Viewport/Previews/SkinnedModelPreview.cs
+++ b/Source/Editor/Viewport/Previews/SkinnedModelPreview.cs
@@ -161,8 +161,8 @@ namespace FlaxEditor.Viewport.Previews
}
var font = Style.Current.FontMedium;
var pos = new Float2(10, 50);
- FallbackTextUtils.DrawText(font, text, new Rectangle(pos + Float2.One, Size), Color.Black);
- FallbackTextUtils.DrawText(font, text, new Rectangle(pos, Size), Color.White);
+ Render2D.DrawText(font, text, new Rectangle(pos + Float2.One, Size), Color.Black);
+ Render2D.DrawText(font, text, new Rectangle(pos, Size), Color.White);
}
}
diff --git a/Source/Editor/Viewport/Previews/TexturePreview.cs b/Source/Editor/Viewport/Previews/TexturePreview.cs
index 5e7594e9c..ec10bb019 100644
--- a/Source/Editor/Viewport/Previews/TexturePreview.cs
+++ b/Source/Editor/Viewport/Previews/TexturePreview.cs
@@ -103,7 +103,7 @@ namespace FlaxEditor.Viewport.Previews
{
var bounds = new Rectangle(Float2.Zero, Size);
Render2D.FillRectangle(bounds, new Color(0.0f, 0.0f, 0.0f, 0.2f));
- FallbackTextUtils.DrawText(Style.Current.FontLarge, "Debugger breakpoint hit...", bounds, Color.White, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(Style.Current.FontLarge, "Debugger breakpoint hit...", bounds, Color.White, TextAlignment.Center, TextAlignment.Center);
}
Render2D.PopClip();
diff --git a/Source/Editor/Viewport/Widgets/ViewportWidgetButton.cs b/Source/Editor/Viewport/Widgets/ViewportWidgetButton.cs
index 43f990afb..77e94ae53 100644
--- a/Source/Editor/Viewport/Widgets/ViewportWidgetButton.cs
+++ b/Source/Editor/Viewport/Widgets/ViewportWidgetButton.cs
@@ -123,7 +123,7 @@ namespace FlaxEditor.Viewport.Widgets
}
// Draw text
- FallbackTextUtils.DrawText(style.FontMedium, _text, textRect, style.ForegroundViewport * (IsMouseOver ? 1.0f : 0.9f), TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, _text, textRect, style.ForegroundViewport * (IsMouseOver ? 1.0f : 0.9f), TextAlignment.Center, TextAlignment.Center);
}
///
@@ -163,7 +163,7 @@ namespace FlaxEditor.Viewport.Widgets
var style = Style.Current;
if (style != null && style.FontMedium)
- Width = CalculateButtonWidth(_forcedTextWidth > 0.0f ? _forcedTextWidth : FallbackTextUtils.MeasureText(style.FontMedium, _text).X, Icon.IsValid);
+ Width = CalculateButtonWidth(_forcedTextWidth > 0.0f ? _forcedTextWidth : style.FontMedium.MeasureText(_text).X, Icon.IsValid);
}
}
}
diff --git a/Source/Editor/Windows/AboutDialog.cs b/Source/Editor/Windows/AboutDialog.cs
index 8c38ed2a9..b059dadcb 100644
--- a/Source/Editor/Windows/AboutDialog.cs
+++ b/Source/Editor/Windows/AboutDialog.cs
@@ -53,7 +53,7 @@ namespace FlaxEditor.Windows
Parent = this
};
var buttonText = "Copy version info";
- var fontSize = FallbackTextUtils.MeasureText(Style.Current.FontMedium, buttonText);
+ var fontSize = Style.Current.FontMedium.MeasureText(buttonText);
var copyVersionButton = new Button(Width - fontSize.X - 8, 6, fontSize.X + 4, 20)
{
Text = buttonText,
diff --git a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
index eb4198fd8..12eac22b5 100644
--- a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
+++ b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
@@ -51,7 +51,7 @@ namespace FlaxEditor.Windows.Assets
var style = Style.Current;
if (_window.Asset == null || !_window.Asset.IsLoaded)
{
- FallbackTextUtils.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
}
}
diff --git a/Source/Editor/Windows/Assets/AnimationWindow.cs b/Source/Editor/Windows/Assets/AnimationWindow.cs
index 042cf2b37..8f88d93f6 100644
--- a/Source/Editor/Windows/Assets/AnimationWindow.cs
+++ b/Source/Editor/Windows/Assets/AnimationWindow.cs
@@ -61,7 +61,7 @@ namespace FlaxEditor.Windows.Assets
var animation = _window.Asset;
if (animation == null || !animation.IsLoaded)
{
- FallbackTextUtils.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
}
diff --git a/Source/Editor/Windows/Assets/ModelWindow.cs b/Source/Editor/Windows/Assets/ModelWindow.cs
index d48966043..c2764a5a6 100644
--- a/Source/Editor/Windows/Assets/ModelWindow.cs
+++ b/Source/Editor/Windows/Assets/ModelWindow.cs
@@ -48,7 +48,7 @@ namespace FlaxEditor.Windows.Assets
var asset = _window.Asset;
if (asset == null || !asset.IsLoaded)
{
- FallbackTextUtils.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
}
}
@@ -645,7 +645,7 @@ namespace FlaxEditor.Windows.Assets
if (!Proxy.Window._meshData.RequestMeshData(Proxy.Window._asset))
{
Invalidate();
- FallbackTextUtils.DrawText(Style.Current.FontMedium, "Loading...", new Rectangle(Float2.Zero, size), Color.White, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(Style.Current.FontMedium, "Loading...", new Rectangle(Float2.Zero, size), Color.White, TextAlignment.Center, TextAlignment.Center);
return;
}
diff --git a/Source/Editor/Windows/Assets/SkinnedModelWindow.cs b/Source/Editor/Windows/Assets/SkinnedModelWindow.cs
index 1e7192d9f..95827240c 100644
--- a/Source/Editor/Windows/Assets/SkinnedModelWindow.cs
+++ b/Source/Editor/Windows/Assets/SkinnedModelWindow.cs
@@ -50,7 +50,7 @@ namespace FlaxEditor.Windows.Assets
var asset = _window.Asset;
if (asset == null || !asset.IsLoaded)
{
- FallbackTextUtils.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, "Loading...", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
}
}
@@ -715,7 +715,7 @@ namespace FlaxEditor.Windows.Assets
if (!Proxy.Window.RequestMeshData())
{
Invalidate();
- FallbackTextUtils.DrawText(Style.Current.FontMedium, "Loading...", new Rectangle(Float2.Zero, size), Color.White, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(Style.Current.FontMedium, "Loading...", new Rectangle(Float2.Zero, size), Color.White, TextAlignment.Center, TextAlignment.Center);
return;
}
diff --git a/Source/Editor/Windows/ContentWindow.Search.cs b/Source/Editor/Windows/ContentWindow.Search.cs
index 67b7deddd..a1072d158 100644
--- a/Source/Editor/Windows/ContentWindow.Search.cs
+++ b/Source/Editor/Windows/ContentWindow.Search.cs
@@ -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;
- FallbackTextUtils.DrawText(Font.GetFont(), "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
diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs
index 91d4f9d8c..ab0c07ec5 100644
--- a/Source/Editor/Windows/DebugLogWindow.cs
+++ b/Source/Editor/Windows/DebugLogWindow.cs
@@ -140,11 +140,11 @@ namespace FlaxEditor.Windows
Render2D.PushClip(ref clientRect);
if (LogCount == 1)
{
- FallbackTextUtils.DrawText(style.FontMedium, Desc.Title, textRect, style.Foreground);
+ Render2D.DrawText(style.FontMedium, Desc.Title, textRect, style.Foreground);
}
else if (LogCount > 1)
{
- FallbackTextUtils.DrawText(style.FontMedium, $"{Desc.Title} ({LogCount})", textRect, style.Foreground);
+ Render2D.DrawText(style.FontMedium, $"{Desc.Title} ({LogCount})", textRect, style.Foreground);
}
Render2D.PopClip();
}
diff --git a/Source/Editor/Windows/GameWindow.cs b/Source/Editor/Windows/GameWindow.cs
index 2c0364995..4a8c11176 100644
--- a/Source/Editor/Windows/GameWindow.cs
+++ b/Source/Editor/Windows/GameWindow.cs
@@ -827,7 +827,7 @@ namespace FlaxEditor.Windows
if (Camera.MainCamera == null)
{
var style = Style.Current;
- FallbackTextUtils.DrawText(style.FontLarge, "No camera", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontLarge, "No camera", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
}
// Selected UI controls outline
@@ -866,8 +866,8 @@ namespace FlaxEditor.Windows
var alpha = Mathf.Saturate(-animTime / fadeOutTime);
var rect = new Rectangle(new Float2(6), Size - 12);
var text = "Press Shift+F11 to unlock the mouse";
- FallbackTextUtils.DrawText(style.FontSmall, text, rect + new Float2(1.0f), style.Background * alpha, TextAlignment.Near, TextAlignment.Far);
- FallbackTextUtils.DrawText(style.FontSmall, text, rect, style.Foreground * alpha, TextAlignment.Near, TextAlignment.Far);
+ Render2D.DrawText(style.FontSmall, text, rect + new Float2(1.0f), style.Background * alpha, TextAlignment.Near, TextAlignment.Far);
+ Render2D.DrawText(style.FontSmall, text, rect, style.Foreground * alpha, TextAlignment.Near, TextAlignment.Far);
}
timeout = 1.0f;
@@ -884,7 +884,7 @@ namespace FlaxEditor.Windows
{
var bounds = new Rectangle(Float2.Zero, Size);
Render2D.FillRectangle(bounds, new Color(0.0f, 0.0f, 0.0f, 0.2f));
- FallbackTextUtils.DrawText(Style.Current.FontLarge, "Debugger breakpoint hit...", bounds, Color.White, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(Style.Current.FontLarge, "Debugger breakpoint hit...", bounds, Color.White, TextAlignment.Center, TextAlignment.Center);
}
}
}
diff --git a/Source/Editor/Windows/Profiler/SingleChart.cs b/Source/Editor/Windows/Profiler/SingleChart.cs
index 25241b4c6..4f36692e5 100644
--- a/Source/Editor/Windows/Profiler/SingleChart.cs
+++ b/Source/Editor/Windows/Profiler/SingleChart.cs
@@ -138,8 +138,8 @@ namespace FlaxEditor.Windows.Profiler
var headerRect = new Rectangle(0, chartHeight, Width, TitleHeight);
var headerTextRect = new Rectangle(2, chartHeight, Width - 4, TitleHeight);
Render2D.FillRectangle(headerRect, style.BackgroundNormal);
- FallbackTextUtils.DrawText(style.FontMedium, Title, headerTextRect, style.ForegroundGrey, TextAlignment.Near, TextAlignment.Center);
- FallbackTextUtils.DrawText(style.FontMedium, _sample, headerTextRect, style.Foreground, TextAlignment.Far, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, Title, headerTextRect, style.ForegroundGrey, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, _sample, headerTextRect, style.Foreground, TextAlignment.Far, TextAlignment.Center);
}
private void OnClick(ref Float2 location)
diff --git a/Source/Editor/Windows/Profiler/Timeline.cs b/Source/Editor/Windows/Profiler/Timeline.cs
index f87efdace..59a7a0e26 100644
--- a/Source/Editor/Windows/Profiler/Timeline.cs
+++ b/Source/Editor/Windows/Profiler/Timeline.cs
@@ -85,12 +85,12 @@ namespace FlaxEditor.Windows.Profiler
Render2D.DrawRectangle(bounds, color * 0.5f);
if (_nameLength < 0 && style.FontMedium)
- _nameLength = FallbackTextUtils.MeasureText(style.FontMedium, _name).X;
+ _nameLength = style.FontMedium.MeasureText(_name).X;
if (_nameLength < bounds.Width + 4)
{
Render2D.PushClip(bounds);
- FallbackTextUtils.DrawText(style.FontMedium, _name, bounds, Style.Current.Foreground, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(style.FontMedium, _name, bounds, Style.Current.Foreground, TextAlignment.Center, TextAlignment.Center);
Render2D.PopClip();
}
}
@@ -115,7 +115,7 @@ namespace FlaxEditor.Windows.Profiler
var style = Style.Current;
var rect = new Rectangle(Float2.Zero, Size);
Render2D.PushClip(rect);
- FallbackTextUtils.DrawText(style.FontMedium, Name, rect, Style.Current.Foreground, TextAlignment.Center, TextAlignment.Center, TextWrapping.WrapChars);
+ Render2D.DrawText(style.FontMedium, Name, rect, Style.Current.Foreground, TextAlignment.Center, TextAlignment.Center, TextWrapping.WrapChars);
Render2D.PopClip();
}
}
diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs
index 2fd990861..63ba7b960 100644
--- a/Source/Editor/Windows/SceneTreeWindow.cs
+++ b/Source/Editor/Windows/SceneTreeWindow.cs
@@ -297,7 +297,7 @@ namespace FlaxEditor.Windows
}
if (overlayText != null)
{
- FallbackTextUtils.DrawText(style.FontLarge, overlayText, GetClientArea(), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center, textWrap);
+ Render2D.DrawText(style.FontLarge, overlayText, GetClientArea(), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center, textWrap);
}
base.Draw();
diff --git a/Source/Editor/Windows/SplashScreen.cpp b/Source/Editor/Windows/SplashScreen.cpp
index cbb51ae3c..cba59191e 100644
--- a/Source/Editor/Windows/SplashScreen.cpp
+++ b/Source/Editor/Windows/SplashScreen.cpp
@@ -258,7 +258,7 @@ void SplashScreen::OnDraw()
return;
// Title
- const auto titleLength = _titleFont->MeasureText(GetTitle());
+ const auto titleLength = _titleFont->MeasureTextInternal(GetTitle());
TextLayoutOptions layout;
layout.Bounds = Rectangle(10 * s, 10 * s, width - 10 * s, 50 * s);
layout.HorizontalAlignment = TextAlignment::Near;
diff --git a/Source/Editor/Windows/ToolboxWindow.cs b/Source/Editor/Windows/ToolboxWindow.cs
index f86341df3..e2b04669b 100644
--- a/Source/Editor/Windows/ToolboxWindow.cs
+++ b/Source/Editor/Windows/ToolboxWindow.cs
@@ -272,8 +272,8 @@ namespace FlaxEditor.Windows
var textRect = item.TextRect;
for (int i = 0; i < ranges.Length; i++)
{
- var start = FallbackTextUtils.GetCharPosition(font, text, ranges[i].StartIndex);
- var end = FallbackTextUtils.GetCharPosition(font, text, ranges[i].EndIndex);
+ var start = font.GetCharPosition(text, ranges[i].StartIndex);
+ var end = font.GetCharPosition(text, ranges[i].EndIndex);
highlights.Add(new Rectangle(start.X + textRect.X, textRect.Y, end.X - start.X, textRect.Height));
}
item.SetHighlights(highlights);
diff --git a/Source/Engine/Core/Config/GameSettings.h b/Source/Engine/Core/Config/GameSettings.h
index 6813f3ee2..675c26bd1 100644
--- a/Source/Engine/Core/Config/GameSettings.h
+++ b/Source/Engine/Core/Config/GameSettings.h
@@ -35,15 +35,6 @@ public:
API_FIELD(Attributes="EditorOrder(15), EditorDisplay(\"General\")")
String CopyrightNotice;
- ///
- /// The copyright note used for content signing (eg. source code header).
- ///
- API_FIELD(Attributes = "EditorOrder(1200), EditorDisplay(\"Other Settings\")")
- bool EnableFontFallback;
-
- API_FIELD(Attributes = "EditorOrder(1205), EditorDisplay(\"Other Settings\")")
- FontFallbackList* FontFallbacks;
-
///
/// The default application icon.
///
diff --git a/Source/Engine/Core/Config/GraphicsSettings.h b/Source/Engine/Core/Config/GraphicsSettings.h
index 81d80cb35..7abfbb048 100644
--- a/Source/Engine/Core/Config/GraphicsSettings.h
+++ b/Source/Engine/Core/Config/GraphicsSettings.h
@@ -6,6 +6,8 @@
#include "Engine/Graphics/Enums.h"
#include "Engine/Graphics/PostProcessSettings.h"
+class FontFallbackList;
+
///
/// Graphics rendering settings.
///
@@ -118,6 +120,18 @@ public:
API_FIELD(Attributes="EditorOrder(10000), EditorDisplay(\"Post Process Settings\", EditorDisplayAttribute.InlineStyle)")
PostProcessSettings PostProcessSettings;
+ ///
+ ///
+ ///
+ API_FIELD(Attributes = "EditorOrder(12000), EditorDisplay(\"Text Render Settings\", EditorDisplayAttribute.InlineStyle)")
+ bool EnableFontFallback = true;
+
+ ///
+ ///
+ ///
+ API_FIELD(Attributes = "EditorOrder(12005), EditorDisplay(\"Text Render Settings\", EditorDisplayAttribute.InlineStyle)")
+ FontFallbackList* FallbackFonts;
+
private:
///
/// Renamed UeeHDRProbes into UseHDRProbes
diff --git a/Source/Engine/Graphics/Graphics.cpp b/Source/Engine/Graphics/Graphics.cpp
index f91c58cea..20f29288b 100644
--- a/Source/Engine/Graphics/Graphics.cpp
+++ b/Source/Engine/Graphics/Graphics.cpp
@@ -8,6 +8,7 @@
#include "Engine/Core/Config/GraphicsSettings.h"
#include "Engine/Engine/CommandLine.h"
#include "Engine/Engine/EngineService.h"
+#include "Engine/Render2D/Render2D.h"
bool Graphics::UseVSync = false;
Quality Graphics::AAQuality = Quality::Medium;
@@ -69,6 +70,9 @@ void GraphicsSettings::Apply()
Graphics::GIQuality = GIQuality;
Graphics::PostProcessSettings = ::PostProcessSettings();
Graphics::PostProcessSettings.BlendWith(PostProcessSettings, 1.0f);
+
+ Render2D::EnableFontFallback = EnableFontFallback;
+ Render2D::FallbackFonts = FallbackFonts;
}
void Graphics::DisposeDevice()
diff --git a/Source/Engine/Render2D/FallbackTextUtils.cs b/Source/Engine/Render2D/FallbackTextUtils.cs
deleted file mode 100644
index 486a354bf..000000000
--- a/Source/Engine/Render2D/FallbackTextUtils.cs
+++ /dev/null
@@ -1,268 +0,0 @@
-
-using System.Runtime.CompilerServices;
-
-namespace FlaxEngine
-{
- ///
- /// A collection of functions to handle text rendering with fallback font
- ///
- public static class FallbackTextUtils
- {
- public static FallbackFonts Fallbacks
- {
- get; set;
- } = null;
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void DrawText(Font font, string text, Color color, ref TextLayoutOptions layout, MaterialBase customMaterial = null, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- Render2D.DrawText(font, Fallbacks, text, color, ref layout, customMaterial);
- }
- else
- {
- Render2D.DrawText(font, text, color, ref layout, customMaterial);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- 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
- {
- Bounds = layoutRect,
- HorizontalAlignment = horizontalAlignment,
- VerticalAlignment = verticalAlignment,
- TextWrapping = textWrapping,
- Scale = scale,
- BaseLinesGapScale = baseLinesGapScale,
- };
-
- if (Fallbacks != null && useFallback)
- {
- Render2D.DrawText(font, Fallbacks, text, color, ref layout);
- }
- else
- {
- Render2D.DrawText(font, text, color, ref layout);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- 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
- {
- Bounds = layoutRect,
- HorizontalAlignment = horizontalAlignment,
- VerticalAlignment = verticalAlignment,
- TextWrapping = textWrapping,
- Scale = scale,
- BaseLinesGapScale = baseLinesGapScale,
- };
-
- if (Fallbacks != null && useFallback)
- {
- Render2D.DrawText(font, Fallbacks, text, color, ref layout, customMaterial);
- }
- else
- {
- Render2D.DrawText(font, text, color, ref layout, customMaterial);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Float2 MeasureText(Font font, string text, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.MeasureText(Fallbacks, text);
- }
- else
- {
- return font.MeasureText(text);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Float2 MeasureText(Font font, string text, ref TextRange textRange, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.MeasureText(Fallbacks, text, ref textRange);
- }
- else
- {
- return font.MeasureText(text, ref textRange);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Float2 MeasureText(Font font, string text, ref TextLayoutOptions layout, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.MeasureText(Fallbacks, text, ref layout);
- }
- else
- {
- return font.MeasureText(text, ref layout);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Float2 MeasureText(Font font, string text, ref TextRange textRange, ref TextLayoutOptions layout, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.MeasureText(Fallbacks, text, ref textRange, ref layout);
- }
- else
- {
- return font.MeasureText(text, ref textRange, ref layout);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int HitTestText(Font font, string text, Float2 location, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.HitTestText(Fallbacks, text, location);
- }
- else
- {
- return font.HitTestText(text, location);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int HitTestText(Font font, string text, ref TextRange textRange, Float2 location, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.HitTestText(Fallbacks, text, ref textRange, location);
- }
- else
- {
- return font.HitTestText(text, ref textRange, location);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int HitTestText(Font font, string text, Float2 location, ref TextLayoutOptions layout, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.HitTestText(Fallbacks, text, location, ref layout);
- }
- else
- {
- return font.HitTestText(text, location, ref layout);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int HitTestText(Font font, string text, ref TextRange textRange, Float2 location, ref TextLayoutOptions layout, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.HitTestText(Fallbacks, text, ref textRange, location, ref layout);
- }
- else
- {
- return font.HitTestText(text, ref textRange, location, ref layout);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Float2 GetCharPosition(Font font, string text, int index, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.GetCharPosition(Fallbacks, text, index);
- }
- else
- {
- return font.GetCharPosition(text, index);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Float2 GetCharPosition(Font font, string text, ref TextRange textRange, int index, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.GetCharPosition(Fallbacks, text, ref textRange, index);
- }
- else
- {
- return font.GetCharPosition(text, ref textRange, index);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Float2 GetCharPosition(Font font, string text, int index, ref TextLayoutOptions layout, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.GetCharPosition(Fallbacks, text, index, ref layout);
- }
- else
- {
- return font.GetCharPosition(text, index, ref layout);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Float2 GetCharPosition(Font font, string text, ref TextRange textRange, int index, ref TextLayoutOptions layout, bool useFallback = true)
- {
- if (Fallbacks != null && useFallback)
- {
- return font.GetCharPosition(Fallbacks, text, ref textRange, index, ref layout);
- }
- else
- {
- return font.GetCharPosition(text, ref textRange, index, ref layout);
- }
- }
-
- ///
- /// Gets the max font height among the font and all fallback fonts of the same size.
- ///
- /// The primary font to use.
- /// The fallback fonts.
- /// The max height.
- public static float GetMaxHeight(Font font, FallbackFonts fallbacks)
- {
- float height = font.Height;
-
- var fallbackFonts = fallbacks.GetFontList(font.Size);
- foreach (var item in fallbackFonts)
- {
- height = Mathf.Max(height, item.Height);
- }
-
- return height;
- }
-
- ///
- /// Gets the max font height among the font and all fallback fonts of the same size.
- ///
- /// The primary font to use.
- /// Whether to enable fallback fonts, uses if true.
- /// The max height.
- public static float GetMaxHeight(Font font, bool useFallback = true)
- {
- if(Fallbacks != null && useFallback)
- {
- return GetMaxHeight(font, Fallbacks);
- }
- else
- {
- return font.Height;
- }
- }
- }
-}
diff --git a/Source/Engine/Render2D/Font.cpp b/Source/Engine/Render2D/Font.cpp
index 5d029ca5e..9f28aac01 100644
--- a/Source/Engine/Render2D/Font.cpp
+++ b/Source/Engine/Render2D/Font.cpp
@@ -103,6 +103,18 @@ void Font::Invalidate()
_characters.Clear();
}
+inline API_FUNCTION() float Font::GetMaxHeight(FontFallbackList* fallbacks) const
+{
+ float height = GetHeight();
+ auto& fallbackFonts = fallbacks->GetFontList(GetSize());
+ for (int32 i = 0; i < fallbackFonts.Count(); i++)
+ {
+ height = Math::Max(height, static_cast(fallbackFonts[i]->GetHeight()));
+ }
+
+ return height;
+}
+
void Font::ProcessText(const StringView& text, Array& outputLines, const TextLayoutOptions& layout)
{
float cursorX = 0;
@@ -548,7 +560,7 @@ void Font::ProcessText(FontFallbackList* fallbacks, const StringView& text, Arra
}
}
-Float2 Font::MeasureText(const StringView& text, const TextLayoutOptions& layout)
+Float2 Font::MeasureTextInternal(const StringView& text, const TextLayoutOptions& layout)
{
// Check if there is no need to do anything
if (text.IsEmpty())
@@ -569,7 +581,7 @@ Float2 Font::MeasureText(const StringView& text, const TextLayoutOptions& layout
return max;
}
-Float2 Font::MeasureText(FontFallbackList* fallbacks, const StringView& text, const TextLayoutOptions& layout)
+Float2 Font::MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text, const TextLayoutOptions& layout)
{
// Check if there is no need to do anything
if (text.IsEmpty())
@@ -590,7 +602,7 @@ Float2 Font::MeasureText(FontFallbackList* fallbacks, const StringView& text, co
return max;
}
-int32 Font::HitTestText(const StringView& text, const Float2& location, const TextLayoutOptions& layout)
+int32 Font::HitTestTextInternal(const StringView& text, const Float2& location, const TextLayoutOptions& layout)
{
// Check if there is no need to do anything
if (text.Length() <= 0)
@@ -664,7 +676,7 @@ int32 Font::HitTestText(const StringView& text, const Float2& location, const Te
return smallestIndex;
}
-int32 Font::HitTestText(FontFallbackList* fallbacks, const StringView& text, const Float2& location, const TextLayoutOptions& layout)
+int32 Font::HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, const Float2& location, const TextLayoutOptions& layout)
{
// Check if there is no need to do anything
if (text.Length() <= 0)
@@ -764,7 +776,7 @@ int32 Font::HitTestText(FontFallbackList* fallbacks, const StringView& text, con
return smallestIndex;
}
-Float2 Font::GetCharPosition(const StringView& text, int32 index, const TextLayoutOptions& layout)
+Float2 Font::GetCharPositionInternal(const StringView& text, int32 index, const TextLayoutOptions& layout)
{
// Check if there is no need to do anything
if (text.IsEmpty())
@@ -818,7 +830,7 @@ Float2 Font::GetCharPosition(const StringView& text, int32 index, const TextLayo
return rootOffset + Float2(lines.Last().Location.X + lines.Last().Size.X, static_cast((lines.Count() - 1) * baseLinesDistance));
}
-Float2 Font::GetCharPosition(FontFallbackList* fallbacks, const StringView& text, int32 index, const TextLayoutOptions& layout)
+Float2 Font::GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, int32 index, const TextLayoutOptions& layout)
{
// Check if there is no need to do anything
if (text.IsEmpty())
diff --git a/Source/Engine/Render2D/Font.h b/Source/Engine/Render2D/Font.h
index 6bb2849e2..1fb41d032 100644
--- a/Source/Engine/Render2D/Font.h
+++ b/Source/Engine/Render2D/Font.h
@@ -8,6 +8,7 @@
#include "Engine/Content/AssetReference.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "TextLayoutOptions.h"
+#include "Render2D.h"
class FontAsset;
class FontFallbackList;
@@ -402,7 +403,31 @@ public:
public:
///
- /// Processes text to get cached lines for rendering.
+ /// Gets the maximum height among the font and the fallback fonts.
+ ///
+ /// The fallback fonts.
+ /// The maximum height.
+ API_FUNCTION() float GetMaxHeight(FontFallbackList* fallbacks) const;
+
+ ///
+ /// Gets the maximum height among the font and the fallback fonts, uses the default font defined in .
+ ///
+ /// The fallback fonts.
+ /// The maximum height.
+ API_FUNCTION() FORCE_INLINE float GetMaxHeight() const
+ {
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts)
+ {
+ return GetMaxHeight(Render2D::FallbackFonts);
+ }
+ else
+ {
+ return GetHeight();
+ }
+ }
+
+ ///
+ /// Processes text to get cached lines for rendering, with font fallbacking disabled.
///
/// The input text.
/// The layout properties.
@@ -410,12 +435,12 @@ public:
void ProcessText(const StringView& text, Array& outputLines, API_PARAM(Ref) const TextLayoutOptions& layout);
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, with font fallbacking disabled.
///
/// The input text.
/// The layout properties.
/// The output lines list.
- API_FUNCTION() Array ProcessText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
+ API_FUNCTION() FORCE_INLINE Array ProcessText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
{
Array lines;
ProcessText(text, lines, layout);
@@ -423,13 +448,13 @@ public:
}
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, with font fallbacking disabled.
///
/// The input text.
/// The input text range (substring range of the input text parameter).
/// The layout properties.
/// The output lines list.
- API_FUNCTION() Array ProcessText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
+ API_FUNCTION() FORCE_INLINE Array ProcessText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
{
Array lines;
ProcessText(textRange.Substring(text), lines, layout);
@@ -437,7 +462,7 @@ public:
}
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, with font fallbacking disabled.
///
/// The input text.
/// The output lines list.
@@ -447,7 +472,7 @@ public:
}
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, with font fallbacking disabled.
///
/// The input text.
/// The input text range (substring range of the input text parameter).
@@ -458,7 +483,7 @@ public:
}
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, using custom fallback options.
///
/// The input text.
/// The layout properties.
@@ -466,12 +491,12 @@ public:
void ProcessText(FontFallbackList* fallbacks, const StringView& text, Array& outputLines, API_PARAM(Ref) const TextLayoutOptions& layout);
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, using custom fallback options.
///
/// The input text.
/// The layout properties.
/// The output lines list.
- API_FUNCTION() Array ProcessText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
+ API_FUNCTION() FORCE_INLINE Array ProcessText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout)
{
Array lines;
ProcessText(fallbacks, text, lines, layout);
@@ -479,13 +504,13 @@ public:
}
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, using custom fallback options.
///
/// The input text.
/// The input text range (substring range of the input text parameter).
/// The layout properties.
/// The output lines list.
- API_FUNCTION() Array ProcessText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
+ API_FUNCTION() FORCE_INLINE Array ProcessText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
{
Array lines;
ProcessText(fallbacks, textRange.Substring(text), lines, layout);
@@ -493,7 +518,7 @@ public:
}
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, using custom fallback options.
///
/// The input text.
/// The output lines list.
@@ -503,7 +528,7 @@ public:
}
///
- /// Processes text to get cached lines for rendering.
+ /// Processes text to get cached lines for rendering, using custom fallback options.
///
/// The input text.
/// The input text range (substring range of the input text parameter).
@@ -514,122 +539,293 @@ public:
}
///
- /// Measures minimum size of the rectangle that will be needed to draw given text.
+ /// Measures minimum size of the rectangle that will be needed to draw given text, with font fallbacking disabled.
///
/// The input text to test.
/// The layout properties.
/// The minimum size for that text and fot to render properly.
- API_FUNCTION() Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
+ API_FUNCTION() Float2 MeasureTextInternal(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
///
- /// Measures minimum size of the rectangle that will be needed to draw given text.
+ /// Measures minimum size of the rectangle that will be needed to draw given text, with font fallbacking disabled.
///
/// The input text to test.
/// The input text range (substring range of the input text parameter).
/// The layout properties.
/// The minimum size for that text and fot to render properly.
- API_FUNCTION() Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
+ API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
{
- return MeasureText(textRange.Substring(text), layout);
+ return MeasureTextInternal(textRange.Substring(text), layout);
}
///
- /// Measures minimum size of the rectangle that will be needed to draw given text
+ /// Measures minimum size of the rectangle that will be needed to draw given text, with font fallbacking disabled.
+ /// .
+ /// The input text to test.
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(const StringView& text)
+ {
+ return MeasureTextInternal(text, TextLayoutOptions());
+ }
+
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text, with font fallbacking disabled.
+ /// .
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange)
+ {
+ return MeasureTextInternal(textRange.Substring(text), TextLayoutOptions());
+ }
+
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The layout properties.
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() Float2 MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
+
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The layout properties.
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
+ {
+ return MeasureTextInternal(fallbacks, textRange.Substring(text), layout);
+ }
+
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text, using custom fallback options.
+ /// .
+ /// The input text to test.
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text)
+ {
+ return MeasureTextInternal(fallbacks, text, TextLayoutOptions());
+ }
+
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text, using custom fallback options.
+ /// .
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() FORCE_INLINE Float2 MeasureTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange)
+ {
+ return MeasureTextInternal(fallbacks, textRange.Substring(text), TextLayoutOptions());
+ }
+
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text, follows the fallback settings defined in .
+ ///
+ /// The input text to test.
+ /// The layout properties.
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout) {
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return MeasureTextInternal(Render2D::FallbackFonts, text, layout);
+ }
+ else {
+ return MeasureTextInternal(text, layout);
+ }
+ }
+
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text, follows the fallback settings defined in .
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The layout properties.
+ /// The minimum size for that text and fot to render properly.
+ API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
+ {
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return MeasureTextInternal(Render2D::FallbackFonts, textRange.Substring(text), layout);
+ }
+ else {
+ return MeasureTextInternal(textRange.Substring(text), layout);
+ }
+ }
+
+ ///
+ /// Measures minimum size of the rectangle that will be needed to draw given text, follows the fallback settings defined in .
/// .
/// The input text to test.
/// The minimum size for that text and fot to render properly.
API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text)
{
- return MeasureText(text, TextLayoutOptions());
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return MeasureTextInternal(Render2D::FallbackFonts, text, TextLayoutOptions());
+ }
+ else {
+ return MeasureTextInternal(text, TextLayoutOptions());
+ }
}
///
- /// Measures minimum size of the rectangle that will be needed to draw given text
+ /// Measures minimum size of the rectangle that will be needed to draw given text, follows the fallback settings defined in .
/// .
/// The input text to test.
/// The input text range (substring range of the input text parameter).
/// The minimum size for that text and fot to render properly.
API_FUNCTION() FORCE_INLINE Float2 MeasureText(const StringView& text, API_PARAM(Ref) const TextRange& textRange)
{
- return MeasureText(textRange.Substring(text), TextLayoutOptions());
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return MeasureTextInternal(Render2D::FallbackFonts, textRange.Substring(text), TextLayoutOptions());
+ }
+ else {
+ return MeasureTextInternal(textRange.Substring(text), TextLayoutOptions());
+ }
}
///
- /// Measures minimum size of the rectangle that will be needed to draw given text.
- ///
- /// The input text to test.
- /// The layout properties.
- /// The minimum size for that text and fot to render properly.
- API_FUNCTION() Float2 MeasureText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextLayoutOptions& layout);
-
- ///
- /// Measures minimum size of the rectangle that will be needed to draw given text.
- ///
- /// The input text to test.
- /// The input text range (substring range of the input text parameter).
- /// The layout properties.
- /// The minimum size for that text and fot to render properly.
- API_FUNCTION() Float2 MeasureText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, API_PARAM(Ref) const TextLayoutOptions& layout)
- {
- return MeasureText(fallbacks, textRange.Substring(text), layout);
- }
-
- ///
- /// Measures minimum size of the rectangle that will be needed to draw given text
- /// .
- /// The input text to test.
- /// The minimum size for that text and fot to render properly.
- API_FUNCTION() FORCE_INLINE Float2 MeasureText(FontFallbackList* fallbacks, const StringView& text)
- {
- return MeasureText(fallbacks, text, TextLayoutOptions());
- }
-
- ///
- /// Measures minimum size of the rectangle that will be needed to draw given text
- /// .
- /// The input text to test.
- /// The input text range (substring range of the input text parameter).
- /// The minimum size for that text and fot to render properly.
- API_FUNCTION() FORCE_INLINE Float2 MeasureText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange)
- {
- return MeasureText(fallbacks, textRange.Substring(text), TextLayoutOptions());
- }
-
- ///
- /// Calculates hit character index at given location.
+ /// Calculates hit character index at given location, with font fallbacking disabled.
///
/// The input text to test.
/// The input location to test.
/// The text layout properties.
/// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
- API_FUNCTION() int32 HitTestText(const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout);
+ API_FUNCTION() int32 HitTestTextInternal(const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout);
///
- /// Calculates hit character index at given location.
+ /// Calculates hit character index at given location, with font fallbacking disabled.
///
/// The input text to test.
/// The input text range (substring range of the input text parameter).
/// The input location to test.
/// The text layout properties.
/// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
- API_FUNCTION() int32 HitTestText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
+ API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
{
- return HitTestText(textRange.Substring(text), location, layout);
+ return HitTestTextInternal(textRange.Substring(text), location, layout);
}
///
- /// Calculates hit character index at given location.
+ /// Calculates hit character index at given location, with font fallbacking disabled.
+ ///
+ /// The input text to test.
+ /// The input location to test.
+ /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
+ API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(const StringView& text, const Float2& location)
+ {
+ return HitTestTextInternal(text, location, TextLayoutOptions());
+ }
+
+ ///
+ /// Calculates hit character index at given location, with font fallbacking disabled.
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The input location to test.
+ /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
+ API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
+ {
+ return HitTestTextInternal(textRange.Substring(text), location, TextLayoutOptions());
+ }
+
+ ///
+ /// Calculates hit character index at given location, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The input location to test.
+ /// The text layout properties.
+ /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
+ API_FUNCTION() int32 HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout);
+
+ ///
+ /// Calculates hit character index at given location, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The input location to test.
+ /// The text layout properties.
+ /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
+ API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
+ {
+ return HitTestTextInternal(fallbacks, textRange.Substring(text), location, layout);
+ }
+
+ ///
+ /// Calculates hit character index at given location, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The input location to test.
+ /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
+ API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, const Float2& location)
+ {
+ return HitTestTextInternal(fallbacks, text, location, TextLayoutOptions());
+ }
+
+ ///
+ /// Calculates hit character index at given location, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The input location to test.
+ /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
+ API_FUNCTION() FORCE_INLINE int32 HitTestTextInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
+ {
+ return HitTestTextInternal(fallbacks, textRange.Substring(text), location, TextLayoutOptions());
+ }
+
+ ///
+ /// Calculates hit character index at given location, follows the fallback settings defined in .
+ ///
+ /// The input text to test.
+ /// The input location to test.
+ /// The text layout properties.
+ /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
+ API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout) {
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return HitTestTextInternal(Render2D::FallbackFonts, text, location, layout);
+ }
+ else {
+ return HitTestTextInternal(text, location, layout);
+ }
+ }
+
+ ///
+ /// Calculates hit character index at given location, follows the fallback settings defined in .
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The input location to test.
+ /// The text layout properties.
+ /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
+ API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
+ {
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return HitTestTextInternal(Render2D::FallbackFonts, textRange.Substring(text), location, layout);
+ }
+ else {
+ return HitTestTextInternal(textRange.Substring(text), location, layout);
+ }
+
+ }
+
+ ///
+ /// Calculates hit character index at given location, follows the fallback settings defined in .
///
/// The input text to test.
/// The input location to test.
/// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, const Float2& location)
{
- return HitTestText(text, location, TextLayoutOptions());
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return HitTestTextInternal(Render2D::FallbackFonts, text, location, TextLayoutOptions());
+ }
+ else {
+ return HitTestTextInternal(text, location, TextLayoutOptions());
+ }
}
///
- /// Calculates hit character index at given location.
+ /// Calculates hit character index at given location, follows the fallback settings defined in .
///
/// The input text to test.
/// The input text range (substring range of the input text parameter).
@@ -637,89 +833,156 @@ public:
/// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
API_FUNCTION() FORCE_INLINE int32 HitTestText(const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
{
- return HitTestText(textRange.Substring(text), location, TextLayoutOptions());
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return HitTestTextInternal(Render2D::FallbackFonts, textRange.Substring(text), location, TextLayoutOptions());
+ }
+ else {
+ return HitTestTextInternal(textRange.Substring(text), location, TextLayoutOptions());
+ }
}
///
- /// Calculates hit character index at given location.
- ///
- /// The input text to test.
- /// The input location to test.
- /// The text layout properties.
- /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
- API_FUNCTION() int32 HitTestText(FontFallbackList* fallbacks, const StringView& text, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout);
-
- ///
- /// Calculates hit character index at given location.
- ///
- /// The input text to test.
- /// The input text range (substring range of the input text parameter).
- /// The input location to test.
- /// The text layout properties.
- /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
- API_FUNCTION() int32 HitTestText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location, API_PARAM(Ref) const TextLayoutOptions& layout)
- {
- return HitTestText(fallbacks, textRange.Substring(text), location, layout);
- }
-
- ///
- /// Calculates hit character index at given location.
- ///
- /// The input text to test.
- /// The input location to test.
- /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
- API_FUNCTION() FORCE_INLINE int32 HitTestText(FontFallbackList* fallbacks, const StringView& text, const Float2& location)
- {
- return HitTestText(fallbacks, text, location, TextLayoutOptions());
- }
-
- ///
- /// Calculates hit character index at given location.
- ///
- /// The input text to test.
- /// The input text range (substring range of the input text parameter).
- /// The input location to test.
- /// The selected character position index (can be equal to text length if location is outside of the layout rectangle).
- API_FUNCTION() FORCE_INLINE int32 HitTestText(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, const Float2& location)
- {
- return HitTestText(fallbacks, textRange.Substring(text), location, TextLayoutOptions());
- }
-
- ///
- /// Calculates character position for given text and character index.
+ /// Calculates character position for given text and character index, with font fallbacking disabled.
///
/// The input text to test.
/// The text position to get coordinates of.
/// The text layout properties.
/// The character position (upper left corner which can be used for a caret position).
- API_FUNCTION() Float2 GetCharPosition(const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
+ API_FUNCTION() Float2 GetCharPositionInternal(const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
///
- /// Calculates character position for given text and character index.
+ /// Calculates character position for given text and character index, with font fallbacking disabled.
///
/// The input text to test.
/// The input text range (substring range of the input text parameter).
/// The text position to get coordinates of.
/// The text layout properties.
/// The character position (upper left corner which can be used for a caret position).
- API_FUNCTION() Float2 GetCharPosition(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
+ API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
{
- return GetCharPosition(textRange.Substring(text), index, layout);
+ return GetCharPositionInternal(textRange.Substring(text), index, layout);
}
///
- /// Calculates character position for given text and character index
+ /// Calculates character position for given text and character index, with font fallbacking disabled.
+ ///
+ /// The input text to test.
+ /// The text position to get coordinates of.
+ /// The character position (upper left corner which can be used for a caret position).
+ API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(const StringView& text, int32 index)
+ {
+ return GetCharPositionInternal(text, index, TextLayoutOptions());
+ }
+
+ ///
+ /// Calculates character position for given text and character index, with font fallbacking disabled.
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The text position to get coordinates of.
+ /// The character position (upper left corner which can be used for a caret position).
+ API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
+ {
+ return GetCharPositionInternal(textRange.Substring(text), index, TextLayoutOptions());
+ }
+
+ ///
+ /// Calculates character position for given text and character index, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The text position to get coordinates of.
+ /// The text layout properties.
+ /// The character position (upper left corner which can be used for a caret position).
+ API_FUNCTION() Float2 GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
+
+ ///
+ /// Calculates character position for given text and character index, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The text position to get coordinates of.
+ /// The text layout properties.
+ /// The character position (upper left corner which can be used for a caret position).
+ API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
+ {
+ return GetCharPositionInternal(fallbacks, textRange.Substring(text), index, layout);
+ }
+
+ ///
+ /// Calculates character position for given text and character index, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The text position to get coordinates of.
+ /// The character position (upper left corner which can be used for a caret position).
+ API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, int32 index)
+ {
+ return GetCharPositionInternal(fallbacks, text, index, TextLayoutOptions());
+ }
+
+ ///
+ /// Calculates character position for given text and character index, using custom fallback options.
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The text position to get coordinates of.
+ /// The character position (upper left corner which can be used for a caret position).
+ API_FUNCTION() FORCE_INLINE Float2 GetCharPositionInternal(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
+ {
+ return GetCharPositionInternal(fallbacks, textRange.Substring(text), index, TextLayoutOptions());
+ }
+
+ ///
+ /// Calculates character position for given text and character index, follows the fallback settings defined in .
+ ///
+ /// The input text to test.
+ /// The text position to get coordinates of.
+ /// The text layout properties.
+ /// The character position (upper left corner which can be used for a caret position).
+ API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout) {
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return GetCharPositionInternal(Render2D::FallbackFonts, text, index, layout);
+ }
+ else {
+ return GetCharPositionInternal(text, index, layout);
+ }
+ }
+
+ ///
+ /// Calculates character position for given text and character index, follows the fallback settings defined in .
+ ///
+ /// The input text to test.
+ /// The input text range (substring range of the input text parameter).
+ /// The text position to get coordinates of.
+ /// The text layout properties.
+ /// The character position (upper left corner which can be used for a caret position).
+ API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
+ {
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return GetCharPositionInternal(Render2D::FallbackFonts, textRange.Substring(text), index, layout);
+ }
+ else {
+ return GetCharPositionInternal(textRange.Substring(text), index, layout);
+ }
+ }
+
+ ///
+ /// Calculates character position for given text and character index, follows the fallback settings defined in .
///
/// The input text to test.
/// The text position to get coordinates of.
/// The character position (upper left corner which can be used for a caret position).
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, int32 index)
{
- return GetCharPosition(text, index, TextLayoutOptions());
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return GetCharPositionInternal(Render2D::FallbackFonts, text, index, TextLayoutOptions());
+ }
+ else {
+ return GetCharPositionInternal(text, index, TextLayoutOptions());
+ }
}
///
- /// Calculates character position for given text and character index
+ /// Calculates character position for given text and character index, follows the fallback settings defined in .
///
/// The input text to test.
/// The input text range (substring range of the input text parameter).
@@ -727,52 +990,12 @@ public:
/// The character position (upper left corner which can be used for a caret position).
API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
{
- return GetCharPosition(textRange.Substring(text), index, TextLayoutOptions());
- }
-
- ///
- /// Calculates character position for given text and character index.
- ///
- /// The input text to test.
- /// The text position to get coordinates of.
- /// The text layout properties.
- /// The character position (upper left corner which can be used for a caret position).
- API_FUNCTION() Float2 GetCharPosition(FontFallbackList* fallbacks, const StringView& text, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout);
-
- ///
- /// Calculates character position for given text and character index.
- ///
- /// The input text to test.
- /// The input text range (substring range of the input text parameter).
- /// The text position to get coordinates of.
- /// The text layout properties.
- /// The character position (upper left corner which can be used for a caret position).
- API_FUNCTION() Float2 GetCharPosition(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index, API_PARAM(Ref) const TextLayoutOptions& layout)
- {
- return GetCharPosition(fallbacks, textRange.Substring(text), index, layout);
- }
-
- ///
- /// Calculates character position for given text and character index
- ///
- /// The input text to test.
- /// The text position to get coordinates of.
- /// The character position (upper left corner which can be used for a caret position).
- API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(FontFallbackList* fallbacks, const StringView& text, int32 index)
- {
- return GetCharPosition(fallbacks, text, index, TextLayoutOptions());
- }
-
- ///
- /// Calculates character position for given text and character index
- ///
- /// The input text to test.
- /// The input text range (substring range of the input text parameter).
- /// The text position to get coordinates of.
- /// The character position (upper left corner which can be used for a caret position).
- API_FUNCTION() FORCE_INLINE Float2 GetCharPosition(FontFallbackList* fallbacks, const StringView& text, API_PARAM(Ref) const TextRange& textRange, int32 index)
- {
- return GetCharPosition(fallbacks, textRange.Substring(text), index, TextLayoutOptions());
+ if (Render2D::EnableFontFallback && Render2D::FallbackFonts) {
+ return GetCharPositionInternal(Render2D::FallbackFonts, textRange.Substring(text), index, TextLayoutOptions());
+ }
+ else {
+ return GetCharPositionInternal(textRange.Substring(text), index, TextLayoutOptions());
+ }
}
///
diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp
index 351bb3700..fa52baff0 100644
--- a/Source/Engine/Render2D/Render2D.cpp
+++ b/Source/Engine/Render2D/Render2D.cpp
@@ -182,6 +182,8 @@ struct ClipMask
};
Render2D::RenderingFeatures Render2D::Features = RenderingFeatures::VertexSnapping;
+bool Render2D::EnableFontFallback = true;
+FontFallbackList* Render2D::FallbackFonts = nullptr;
namespace
{
diff --git a/Source/Engine/Render2D/Render2D.cs b/Source/Engine/Render2D/Render2D.cs
index 6e4f1dc1d..b36f155df 100644
--- a/Source/Engine/Render2D/Render2D.cs
+++ b/Source/Engine/Render2D/Render2D.cs
@@ -102,7 +102,7 @@ namespace FlaxEngine
}
///
- /// Draws a text.
+ /// Draws a text, follows the font fallback settings defined in .
///
/// The font to use.
/// The text to render.
@@ -128,7 +128,7 @@ namespace FlaxEngine
}
///
- /// 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).
+ /// 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). Follows the font fallback settings defined in .
///
/// The font to use.
/// Custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture.
diff --git a/Source/Engine/Render2D/Render2D.h b/Source/Engine/Render2D/Render2D.h
index fa59b1d79..5813d6f87 100644
--- a/Source/Engine/Render2D/Render2D.h
+++ b/Source/Engine/Render2D/Render2D.h
@@ -54,8 +54,6 @@ API_CLASS(Static) class FLAXENGINE_API Render2D
};
public:
- API_FIELD() static bool EnableFontFallback;
- API_FIELD() static FontFallbackList* FallbackFonts;
///
/// Checks if interface is during rendering phrase (Draw calls may be performed without failing).
@@ -72,6 +70,10 @@ public:
///
API_FIELD() static RenderingFeatures Features;
+ API_FIELD() static bool EnableFontFallback;
+
+ API_FIELD() static FontFallbackList* FallbackFonts;
+
///
/// Called when frame rendering begins by the graphics device.
///
diff --git a/Source/Engine/UI/GUI/Common/Button.cs b/Source/Engine/UI/GUI/Common/Button.cs
index feb34418b..02337411b 100644
--- a/Source/Engine/UI/GUI/Common/Button.cs
+++ b/Source/Engine/UI/GUI/Common/Button.cs
@@ -261,7 +261,7 @@ namespace FlaxEngine.GUI
Render2D.DrawRectangle(clientRect, borderColor, BorderThickness);
// Draw text
- FallbackTextUtils.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
+ Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
}
///
diff --git a/Source/Engine/UI/GUI/Common/Dropdown.cs b/Source/Engine/UI/GUI/Common/Dropdown.cs
index 3b298b136..ecca2978f 100644
--- a/Source/Engine/UI/GUI/Common/Dropdown.cs
+++ b/Source/Engine/UI/GUI/Common/Dropdown.cs
@@ -475,7 +475,7 @@ namespace FlaxEngine.GUI
var font = Font.GetFont();
for (int i = 0; i < _items.Count; i++)
{
- itemsWidth = Mathf.Max(itemsWidth, itemsMargin + 4 + FallbackTextUtils.MeasureText(font, _items[i]).X);
+ itemsWidth = Mathf.Max(itemsWidth, itemsMargin + 4 + font.MeasureText(_items[i]).X);
}
*/
var itemsWidth = Width;
@@ -673,7 +673,7 @@ namespace FlaxEngine.GUI
var textRect = new Rectangle(margin, 0, clientRect.Width - boxSize - 2.0f * margin, clientRect.Height);
Render2D.PushClip(textRect);
var textColor = TextColor;
- FallbackTextUtils.DrawText(Font.GetFont(), 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();
}
diff --git a/Source/Engine/UI/GUI/Common/Label.cs b/Source/Engine/UI/GUI/Common/Label.cs
index 3d1caad28..3c7c04fb2 100644
--- a/Source/Engine/UI/GUI/Common/Label.cs
+++ b/Source/Engine/UI/GUI/Common/Label.cs
@@ -233,7 +233,7 @@ namespace FlaxEngine.GUI
}
}
- FallbackTextUtils.DrawText(_font.GetFont(), 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();
@@ -254,7 +254,7 @@ namespace FlaxEngine.GUI
layout.Bounds.Size.X = Width - Margin.Width;
else if (_autoWidth && !_autoHeight)
layout.Bounds.Size.Y = Height - Margin.Height;
- _textSize = FallbackTextUtils.MeasureText(font, _text, ref layout);
+ _textSize = font.MeasureText(_text, ref layout);
_textSize.Y *= BaseLinesGapScale;
// Check if size is controlled via text
diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
index 8d7858af0..46f0fb1ad 100644
--- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
+++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs
@@ -154,7 +154,7 @@ namespace FlaxEngine.GUI
if (!font)
break;
height = font.Height / DpiScale;
- return textBlock.Bounds.Location + FallbackTextUtils.GetCharPosition(font, _text, ref textBlock.Range, index - textBlock.Range.StartIndex);
+ return textBlock.Bounds.Location + font.GetCharPosition(_text, ref textBlock.Range, index - textBlock.Range.StartIndex);
}
}
@@ -196,7 +196,7 @@ namespace FlaxEngine.GUI
var font = textBlock.Style.Font.GetFont();
if (!font && textBlock.Range.Length > 0)
break;
- return FallbackTextUtils.HitTestText(font, _text, ref textBlock.Range, location - textBlock.Bounds.Location) + textBlock.Range.StartIndex;
+ return font.HitTestText(_text, ref textBlock.Range, location - textBlock.Bounds.Location) + textBlock.Range.StartIndex;
}
}
@@ -288,8 +288,8 @@ namespace FlaxEngine.GUI
// Selection
if (hasSelection && textBlock.Style.BackgroundSelectedBrush != null && textBlock.Range.Intersect(ref selection))
{
- var leftEdge = selection.StartIndex <= textBlock.Range.StartIndex ? textBlock.Bounds.UpperLeft : FallbackTextUtils.GetCharPosition(font, _text, selection.StartIndex);
- var rightEdge = selection.EndIndex >= textBlock.Range.EndIndex ? textBlock.Bounds.UpperRight : FallbackTextUtils.GetCharPosition(font, _text, selection.EndIndex);
+ var leftEdge = selection.StartIndex <= textBlock.Range.StartIndex ? textBlock.Bounds.UpperLeft : font.GetCharPosition(_text, selection.StartIndex);
+ var rightEdge = selection.EndIndex >= textBlock.Range.EndIndex ? textBlock.Bounds.UpperRight : font.GetCharPosition(_text, selection.EndIndex);
float height = font.Height / DpiScale;
float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
alpha *= alpha;
diff --git a/Source/Engine/UI/GUI/Common/TextBox.cs b/Source/Engine/UI/GUI/Common/TextBox.cs
index b1861df56..3c0d55008 100644
--- a/Source/Engine/UI/GUI/Common/TextBox.cs
+++ b/Source/Engine/UI/GUI/Common/TextBox.cs
@@ -104,7 +104,7 @@ namespace FlaxEngine.GUI
return Float2.Zero;
}
- return FallbackTextUtils.MeasureText(font, _text, ref _layout);
+ return font.MeasureText(_text, ref _layout);
}
///
@@ -117,8 +117,8 @@ namespace FlaxEngine.GUI
return Float2.Zero;
}
- height = FallbackTextUtils.GetMaxHeight(font) / DpiScale;
- return FallbackTextUtils.GetCharPosition(font, _text, index, ref _layout);
+ height = font.GetMaxHeight() / DpiScale;
+ return font.GetCharPosition(_text, index, ref _layout);
}
///
@@ -130,7 +130,7 @@ namespace FlaxEngine.GUI
return 0;
}
- return FallbackTextUtils.HitTestText(font, _text, location, ref _layout);
+ return font.HitTestText(_text, location, ref _layout);
}
///
@@ -169,9 +169,9 @@ namespace FlaxEngine.GUI
// Check if sth is selected to draw selection
if (HasSelection)
{
- var leftEdge = FallbackTextUtils.GetCharPosition(font, _text, SelectionLeft, ref _layout);
- var rightEdge = FallbackTextUtils.GetCharPosition(font, _text, SelectionRight, ref _layout);
- float fontHeight = FallbackTextUtils.GetMaxHeight(font) / DpiScale;
+ var leftEdge = font.GetCharPosition(_text, SelectionLeft, ref _layout);
+ var rightEdge = font.GetCharPosition(_text, SelectionRight, ref _layout);
+ float fontHeight = font.GetMaxHeight() / DpiScale;
// Draw selection background
float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
@@ -211,11 +211,11 @@ namespace FlaxEngine.GUI
var color = TextColor;
if (!enabled)
color *= 0.6f;
- FallbackTextUtils.DrawText(font, _text, color, ref _layout, TextMaterial);
+ Render2D.DrawText(font, _text, color, ref _layout, TextMaterial);
}
else if (!string.IsNullOrEmpty(_watermarkText) && !IsFocused)
{
- FallbackTextUtils.DrawText(font, _watermarkText, WatermarkTextColor, ref _layout, TextMaterial);
+ Render2D.DrawText(font, _watermarkText, WatermarkTextColor, ref _layout, TextMaterial);
}
// Caret
diff --git a/Source/Engine/UI/GUI/Panels/DropPanel.cs b/Source/Engine/UI/GUI/Panels/DropPanel.cs
index 123e0f034..66e7413eb 100644
--- a/Source/Engine/UI/GUI/Panels/DropPanel.cs
+++ b/Source/Engine/UI/GUI/Panels/DropPanel.cs
@@ -374,7 +374,7 @@ namespace FlaxEngine.GUI
textColor *= 0.6f;
}
- FallbackTextUtils.DrawText(HeaderTextFont.GetFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
+ Render2D.DrawText(HeaderTextFont.GetFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
if (!_isClosed && EnableContainmentLines)
{
diff --git a/Source/Engine/UI/GUI/Style.cs b/Source/Engine/UI/GUI/Style.cs
index f4fca13eb..6092f0f72 100644
--- a/Source/Engine/UI/GUI/Style.cs
+++ b/Source/Engine/UI/GUI/Style.cs
@@ -69,12 +69,6 @@ namespace FlaxEngine.GUI
set => _fontSmall = new FontReference(value);
}
- ///
- /// The fallback fonts to use if the primary font can't render the char.
- ///
- [EditorOrder(50)]
- public FallbackFonts Fallbacks;
-
///
/// The background color.
///
diff --git a/Source/Engine/UI/GUI/Tooltip.cs b/Source/Engine/UI/GUI/Tooltip.cs
index 41d06b017..8d35c21b9 100644
--- a/Source/Engine/UI/GUI/Tooltip.cs
+++ b/Source/Engine/UI/GUI/Tooltip.cs
@@ -234,7 +234,7 @@ namespace FlaxEngine.GUI
Render2D.FillRectangle(new Rectangle(1.1f, 1.1f, Width - 2, Height - 2), style.Background);
// Tooltip text
- FallbackTextUtils.DrawText(
+ Render2D.DrawText(
style.FontMedium,
_currentText,
GetClientArea(),