-修复 #257(系统字体名称为0长度时导致程序出错)

This commit is contained in:
WMJ
2025-05-19 16:19:51 +08:00
parent f026bbecab
commit ac282180da
2 changed files with 10 additions and 10 deletions
+9 -10
View File
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using iTextSharp.text.pdf;
using Microsoft.Win32;
using CharSet = System.Runtime.InteropServices.CharSet;
using DllImport = System.Runtime.InteropServices.DllImportAttribute;
using Microsoft.Win32;
namespace PDFPatcher.Common
{
@@ -49,7 +49,6 @@ namespace PDFPatcher.Common
}
else if (fp.HasExtension(Constants.FileExtensions.Ttc)) {
var nl = BaseFont.EnumerateTTCNames(p).Length;
//Tracker.DebugMessage (p);
for (int i = 0; i < nl; i++) {
AddFontNames(d, p + "," + i.ToText(), includeFamilyName);
}
@@ -68,9 +67,8 @@ namespace PDFPatcher.Common
static void AddFontNames(Dictionary<string, string> fontNames, string fontPath, bool includeFamilyName) {
var nl = BaseFont.GetAllFontNames(fontPath, "Cp936", null);
//Tracker.DebugMessage (fontPath);
if (includeFamilyName) {
fontNames[nl[0] as string] = fontPath;
AddFontName(fontNames, nl[0] as string, fontPath);
}
var ffn = nl[2] as string[][];
string n = null;
@@ -90,13 +88,14 @@ namespace PDFPatcher.Common
}
}
if (n != null) {
//Tracker.DebugMessage (cn ?? nn ?? n);
fontNames[cn ?? nn ?? n] = fontPath;
AddFontName(fontNames, cn ?? nn ?? n, fontPath);
}
}
static void AddFontName(Dictionary<string, string> fontNames, string name, string path) {
if (!String.IsNullOrEmpty(name)) {
fontNames[name] = path;
}
//foreach (string[] item in nl[1] as string[][]) {
// fontNames[item] = fontPath;
// Tracker.DebugMessage (item);
//}
}
static class NativeMethods
+1
View File
@@ -22,6 +22,7 @@
在“关于程序”页面无法打开文档。
自动生成书签功能可能生成空白的书签。
自动生成书签列表框导入之前保存的条件后,插入新书签将清空规则列表。
列出系统安装字体时,对于异常的字体不要抛出异常。
1.0.4.4512 2024年9月30日
新增功能: