Make font fallbacking the default option

This commit is contained in:
ExMatics HydrogenC
2023-12-03 15:11:47 +08:00
parent 2f019d4264
commit 23b71e7d3e
83 changed files with 598 additions and 619 deletions

View File

@@ -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,

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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);
}
}
}

View File

@@ -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)

View File

@@ -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();
}
}

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);