Make font fallbacking the default option
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user