PF.UI.Fonts.SourceHan
1.0.1
dotnet add package PF.UI.Fonts.SourceHan --version 1.0.1
NuGet\Install-Package PF.UI.Fonts.SourceHan -Version 1.0.1
<PackageReference Include="PF.UI.Fonts.SourceHan" Version="1.0.1" />
<PackageVersion Include="PF.UI.Fonts.SourceHan" Version="1.0.1" />
<PackageReference Include="PF.UI.Fonts.SourceHan" />
paket add PF.UI.Fonts.SourceHan --version 1.0.1
#r "nuget: PF.UI.Fonts.SourceHan, 1.0.1"
#:package PF.UI.Fonts.SourceHan@1.0.1
#addin nuget:?package=PF.UI.Fonts.SourceHan&version=1.0.1
#tool nuget:?package=PF.UI.Fonts.SourceHan&version=1.0.1
PF.UI.Fonts.SourceHan
可选字体包:内嵌思源黑体 SC(Source Han Sans SC)7 个字重,用于覆盖 PF.UI.Resources 的
GlobalFontFamily 键,实现 PF.UI 组件库的全局换字体。
不需要思源黑体的项目不需要引用本包——PF.UI.Resources 已内置 GlobalFontFamily 默认值
(Microsoft YaHei UI, Segoe UI),767 处内置样式均已绑定该键,装或不装本包只是"用哪个字体"
的区别,不影响功能。
安装
dotnet add package PF.UI.Fonts.SourceHan
在 App.xaml 的 Application.Resources.MergedDictionaries 中,于 PF.UI.Resources 主题字典
之后追加一条:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/PF.UI.Resources;component/Themes/Default.xaml" />
<ResourceDictionary Source="pack://application:,,,/PF.UI.Fonts.SourceHan;component/Fonts/SourceHan.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
后加入的字典在 WPF 中优先级更高,因此顺序必须晚于主题字典,否则不生效。
字重对照
思源黑体是单一字体族(Source Han Sans SC),内含 7 个字重,通过 FontWeight 选取,
不要为每个字重建单独的 FontFamily 键:
| FontWeight | OpenType 数值 |
|---|---|
250 |
250(ExtraLight,需写数字,无对应命名值) |
Light |
300 |
350 |
350(需写数字,思源自己的 "Normal" 字重) |
Normal |
400(对应思源的 Regular,注意不是 350) |
Medium |
500 |
Bold |
700 |
Black |
900 |
<TextBlock Text="示例文字" FontFamily="{DynamicResource GlobalFontFamily}" FontWeight="Bold" />
许可
本包内嵌的思源黑体字体文件按 SIL Open Font License 1.1 分发,随包附带
LICENSE-OFL.txt。字体文件未做任何修改(未子集化、未改名)。
正式对外分发前请核实 LICENSE-OFL.txt 中的官方许可原文链接是否需要替换为完整文本。
体积
7 个字重原始 otf 文件合计约 111MB(未子集化)。如需更小体积,需要自行裁剪字符集并重新构建,
但请注意 OFL 对 "Reserved Font Name"(本字体族名含 "Source")的限制——字体一旦被修改
(含子集化),需要更改分发的字体族名称,详见 LICENSE-OFL.txt。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net8.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.0.0 - 初始版本:思源黑体 SC 7 字重(Source Han Sans SC, SIL OFL 1.1),随包附带 LICENSE-OFL.txt