From 36428f7af7503591a16146013baac78b074cfa35 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Thu, 2 May 2024 20:24:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E5=BC=B9?= =?UTF-8?q?=E5=B9=95=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Controls/PlayerControl.xaml | 6 +++++- src/BiliLite.UWP/Controls/PlayerControl.xaml.cs | 11 +++++++++++ src/BiliLite.UWP/Models/Common/SettingConstants.cs | 6 ++++++ .../Services/FrostMasterDanmakuController.cs | 5 +++++ .../Services/Interfaces/IDanmakuController.cs | 6 ++++++ src/BiliLite.UWP/Services/NsDanmakuController.cs | 6 ++++++ 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml b/src/BiliLite.UWP/Controls/PlayerControl.xaml index 13918e7a..651b1865 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml @@ -386,7 +386,11 @@ 弹幕同屏密度(0为不限制) - + + 弹幕字体 + + + diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 3b77c24a..f1db0b30 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -626,6 +626,17 @@ private void LoadDanmuSetting() SettingService.SetValue(SettingConstants.VideoDanmaku.BORDER_STYLE, DanmuSettingStyle.SelectedIndex); } }); + + //弹幕字体 + var fontFamily = + SettingService.GetValue(SettingConstants.VideoDanmaku.DANMAKU_FONT_FAMILY, string.Empty); + m_danmakuController.SetFont(fontFamily); + DanmuSettingFont.Text = fontFamily; + DanmuSettingFont.QuerySubmitted += (e, args) => + { + m_danmakuController.SetFont(DanmuSettingFont.Text); + SettingService.SetValue(SettingConstants.VideoDanmaku.DANMAKU_FONT_FAMILY, DanmuSettingFont.Text); + }; //合并弹幕 DanmuSettingMerge.IsOn = SettingService.GetValue(SettingConstants.VideoDanmaku.MERGE, false); DanmuSettingMerge.Toggled += async (e, args) => diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs index 8770c526..e9477535 100644 --- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs +++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs @@ -338,6 +338,12 @@ public class VideoDanmaku /// [SettingKey(typeof(int))] public const string SHIELD_LEVEL = "VideoDanmuShieldLevel"; + + /// + /// 弹幕字体 + /// + [SettingKey(typeof(string))] + public const string DANMAKU_FONT_FAMILY = "VideoDanmuFontFamily"; } public class Live diff --git a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs index dc8f0c30..b5185225 100644 --- a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs +++ b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs @@ -90,6 +90,11 @@ public override void ShowScroll() m_danmakuMaster.SetLayerRenderState(DanmakuDefaultLayerDef.RollingLayerId, true); } + public override void SetFont(string fontName) + { + m_danmakuMaster.SetFontFamilyName(fontName); + } + public override void SetFontZoom(double fontZoom) { base.SetFontZoom(fontZoom); diff --git a/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs b/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs index d9d3e788..bff549b1 100644 --- a/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs +++ b/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs @@ -72,6 +72,12 @@ public virtual void Show() /// public abstract void ShowScroll(); + /// + /// 设置字体 + /// + /// + public abstract void SetFont(string fontName); + /// /// 设置弹幕字体缩放 /// diff --git a/src/BiliLite.UWP/Services/NsDanmakuController.cs b/src/BiliLite.UWP/Services/NsDanmakuController.cs index b711aa30..25656d02 100644 --- a/src/BiliLite.UWP/Services/NsDanmakuController.cs +++ b/src/BiliLite.UWP/Services/NsDanmakuController.cs @@ -83,6 +83,12 @@ public override void ShowScroll() m_danmakuControl.ShowDanmaku(DanmakuLocation.Scroll); } + public override void SetFont(string fontName) + { + if (string.IsNullOrEmpty(fontName)) return; + m_danmakuControl.FontFamily = new FontFamily(fontName); + } + public override void SetFontZoom(double fontZoom) { base.SetFontZoom(fontZoom);