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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PF.UI.Fonts.SourceHan" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PF.UI.Fonts.SourceHan" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="PF.UI.Fonts.SourceHan" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PF.UI.Fonts.SourceHan --version 1.0.1
                    
#r "nuget: PF.UI.Fonts.SourceHan, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PF.UI.Fonts.SourceHan@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PF.UI.Fonts.SourceHan&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=PF.UI.Fonts.SourceHan&version=1.0.1
                    
Install as a Cake Tool

PF.UI.Fonts.SourceHan

可选字体包:内嵌思源黑体 SC(Source Han Sans SC)7 个字重,用于覆盖 PF.UI.ResourcesGlobalFontFamily 键,实现 PF.UI 组件库的全局换字体。

不需要思源黑体的项目不需要引用本包——PF.UI.Resources 已内置 GlobalFontFamily 默认值 (Microsoft YaHei UI, Segoe UI),767 处内置样式均已绑定该键,装或不装本包只是"用哪个字体" 的区别,不影响功能。

安装

dotnet add package PF.UI.Fonts.SourceHan

App.xamlApplication.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 Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.0.1 118 7/31/2026
1.0.0 112 7/31/2026

v1.0.0 - 初始版本:思源黑体 SC 7 字重(Source Han Sans SC, SIL OFL 1.1),随包附带 LICENSE-OFL.txt