PF.UI.Fonts.SourceHanSerif 1.0.0

dotnet add package PF.UI.Fonts.SourceHanSerif --version 1.0.0
                    
NuGet\Install-Package PF.UI.Fonts.SourceHanSerif -Version 1.0.0
                    
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.SourceHanSerif" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PF.UI.Fonts.SourceHanSerif" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PF.UI.Fonts.SourceHanSerif" />
                    
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.SourceHanSerif --version 1.0.0
                    
#r "nuget: PF.UI.Fonts.SourceHanSerif, 1.0.0"
                    
#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.SourceHanSerif@1.0.0
                    
#: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.SourceHanSerif&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PF.UI.Fonts.SourceHanSerif&version=1.0.0
                    
Install as a Cake Tool

PF.UI.Fonts.SourceHanSerif

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

思源宋体是 Adobe 与 Google 联合开发的开源衬线中文字体(宋体),与同源的 PF.UI.Fonts.SourceHan 思源黑体(无衬线)构成"黑/宋"配对; 加上 PF.UI.Fonts.LXGW 霞鹜文楷(楷体),形成黑 / 宋 / 楷完整谱系。 宋体笔画有衬线起收,适合强调书卷气、正式感的界面。

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

安装

dotnet add package PF.UI.Fonts.SourceHanSerif

在 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.SourceHanSerif;component/Fonts/SourceHanSerif.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

后加入的字典在 WPF 中优先级更高,因此顺序必须晚于主题字典,否则不生效。

与 PF.UI.Fonts.SourceHan / PF.UI.Fonts.LXGW 互斥:三者都覆盖同一个 GlobalFontFamily 键,同一应用内只应引用其一(后合并的字典会覆盖前者,行为不可预期)。

字重对照

思源宋体是单一字体族(Source Han Serif SC),内含 7 个字重,通过 FontWeight 选取, 不要为每个字重建单独的 FontFamily 键:

FontWeight OpenType 数值 对应字重
250 250(ExtraLight,需写数字,无对应命名值) Source Han Serif SC ExtraLight
Light 300 Light
Normal 400 Regular
Medium 500 Medium
SemiBold 600 SemiBold
Bold 700 Bold
Black 900 Heavy
<TextBlock Text="示例文字" FontFamily="{DynamicResource GlobalFontFamily}" FontWeight="Bold" />

与思源黑体字重的差异(同一项目内换字体时尤其要注意):

  • 宋体有 SemiBold(600),黑体没有;
  • 黑体有 Normal(350),宋体没有。

因此把样式从黑体切到宋体(或反之)时,若用了对方的独有字重,WPF 会在当前族内取最接近的可用 字重,不会报错,但视觉粗细会与预期略有出入。

许可

本包内嵌的思源宋体字体文件按 SIL Open Font License 1.1 分发,随包附带 LICENSE-OFL.txt。字体文件未做任何修改(未子集化、未改名),直接取自官方 发布版(v2.003R,09_SourceHanSerifSC.zip)。与思源黑体同源、同许可,Reserved Font Name 均为 Source(Adobe 商标)。

体积

7 个字重原始 otf 文件合计约 169MB(未子集化)。如需更小体积,需要自行裁剪字符集并重新构建, 但请注意 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.0 162 8/3/2026

v1.0.0 - 初始版本:思源宋体 SC 7 字重(Source Han Serif SC:ExtraLight/Light/Regular/Medium/SemiBold/Bold/Heavy,SIL OFL 1.1),随包附带 LICENSE-OFL.txt