From efca533aef5c8dc9e5401c31b4f4ed0c686e1930 Mon Sep 17 00:00:00 2001 From: YexuanXiao Date: Mon, 17 Jun 2024 10:31:54 +0800 Subject: [PATCH] Fixed the issue where ScottPlot could not display CJK (and possibly other) characters by default --- .../ViewModels/Pages/BatteryHistoryPageViewModel.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GalaxyBudsClient/Interface/ViewModels/Pages/BatteryHistoryPageViewModel.cs b/GalaxyBudsClient/Interface/ViewModels/Pages/BatteryHistoryPageViewModel.cs index 5540f84b..e7cf5e8c 100644 --- a/GalaxyBudsClient/Interface/ViewModels/Pages/BatteryHistoryPageViewModel.cs +++ b/GalaxyBudsClient/Interface/ViewModels/Pages/BatteryHistoryPageViewModel.cs @@ -16,6 +16,7 @@ using ScottPlot.AxisRules; using ScottPlot.Plottables; using ScottPlot.TickGenerators; +using SkiaSharp; namespace GalaxyBudsClient.Interface.ViewModels.Pages; @@ -157,7 +158,9 @@ private async Task UpdatePlotAsync() } overlay?.AddNullFrame(DateTimeOffset.Now.DateTime.ToOADate()); - + var font = SKFontManager.Default.MatchCharacter(Strings.Left[0]).FamilyName; + Plot.Legend.FontName = font; + var plotBatteryL = Plot.Add.Scatter(timestamp, batteryL); plotBatteryL.MarkerShape = MarkerShape.None; plotBatteryL.LineWidth = 2; @@ -181,7 +184,8 @@ private async Task UpdatePlotAsync() { LabelFormatter = value => value is < 0 or > 100 ? string.Empty : NumericAutomatic.DefaultLabelFormatter(value) }; - + + Plot.Font.Set(font); Plot.YLabel(Strings.BattHistYAxis); UpdateLegendVisibility();