- PdfSharpCore 1.3.64 引入(纯托管,Unity IL2CPP 兼容,+9 DLL) - ReportData 结构化模型 + MarkdownRenderer + StandardPdfTemplate - IReportService.ExportReport(id, format) 按需导出 PDF/MD - 仿真后自动生成 MD 到 reports 目录,PDF 按需调用 - CJK 字体嵌入(SimHei),IPathProvider + GetFontPath - ReportGenerator 重构为构建 ReportData,去掉 emoji - check_unity_build.ps1 修复 -quit 参数缺失导致超时 - 对接文档 V2.0:坐标系/3D 可视化/完整枚举/Manager 签名/模型字段 - 262 测试全部通过
41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using System;
|
|
using System.IO;
|
|
using PdfSharpCore.Fonts;
|
|
|
|
namespace CounterDrone.Core.Reporting
|
|
{
|
|
/// <summary>CJK 字体解析器 — 从文件路径加载 TrueType 字体供 PdfSharpCore 使用</summary>
|
|
public sealed class CjkFontResolver : IFontResolver
|
|
{
|
|
private readonly byte[] _fontData;
|
|
private readonly string _familyName;
|
|
|
|
/// <summary>注册 CJK 字体解析器到全局设置(进程内只能注册一次)</summary>
|
|
/// <param name="fontPath">CJK TrueType/OpenType 字体文件路径</param>
|
|
/// <param name="familyName">字体族名(用于 XFont 构造)</param>
|
|
public static void Register(string fontPath, string familyName)
|
|
{
|
|
if (string.IsNullOrEmpty(fontPath))
|
|
throw new ArgumentException("字体路径不能为空", nameof(fontPath));
|
|
if (!File.Exists(fontPath))
|
|
throw new FileNotFoundException($"字体文件不存在: {fontPath}", fontPath);
|
|
|
|
if (GlobalFontSettings.FontResolver == null)
|
|
GlobalFontSettings.FontResolver = new CjkFontResolver(fontPath, familyName);
|
|
}
|
|
|
|
private CjkFontResolver(string fontPath, string familyName)
|
|
{
|
|
_fontData = File.ReadAllBytes(fontPath);
|
|
_familyName = familyName;
|
|
}
|
|
|
|
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic)
|
|
=> new FontResolverInfo(_familyName);
|
|
|
|
public byte[] GetFont(string faceName) => _fontData;
|
|
|
|
public string DefaultFontName => _familyName;
|
|
}
|
|
}
|