fix: handle potential font error
This commit is contained in:
+10
-1
@@ -1,4 +1,5 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using SharpDX;
|
||||||
using SharpDX.DirectWrite;
|
using SharpDX.DirectWrite;
|
||||||
using FontStyle = SharpDX.DirectWrite.FontStyle;
|
using FontStyle = SharpDX.DirectWrite.FontStyle;
|
||||||
|
|
||||||
@@ -44,13 +45,17 @@ internal static class Fonts {
|
|||||||
using var family = collection.GetFontFamily(i);
|
using var family = collection.GetFontFamily(i);
|
||||||
var anyItalic = false;
|
var anyItalic = false;
|
||||||
for (var j = 0; j < family.FontCount; j++) {
|
for (var j = 0; j < family.FontCount; j++) {
|
||||||
using var font = family.GetFont(j);
|
try {
|
||||||
|
var font = family.GetFont(j);
|
||||||
if (font.IsSymbolFont || font.Style is not (FontStyle.Italic or FontStyle.Oblique)) {
|
if (font.IsSymbolFont || font.Style is not (FontStyle.Italic or FontStyle.Oblique)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
anyItalic = true;
|
anyItalic = true;
|
||||||
break;
|
break;
|
||||||
|
} catch (SharpDXException) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!anyItalic) {
|
if (!anyItalic) {
|
||||||
@@ -74,6 +79,7 @@ internal static class Fonts {
|
|||||||
using var family = collection.GetFontFamily(i);
|
using var family = collection.GetFontFamily(i);
|
||||||
var probablyJp = false;
|
var probablyJp = false;
|
||||||
for (var j = 0; j < family.FontCount; j++) {
|
for (var j = 0; j < family.FontCount; j++) {
|
||||||
|
try {
|
||||||
using var font = family.GetFont(j);
|
using var font = family.GetFont(j);
|
||||||
if (!font.HasCharacter('気') || font.IsSymbolFont) {
|
if (!font.HasCharacter('気') || font.IsSymbolFont) {
|
||||||
continue;
|
continue;
|
||||||
@@ -81,6 +87,9 @@ internal static class Fonts {
|
|||||||
|
|
||||||
probablyJp = true;
|
probablyJp = true;
|
||||||
break;
|
break;
|
||||||
|
} catch (SharpDXException) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!probablyJp) {
|
if (!probablyJp) {
|
||||||
|
|||||||
Reference in New Issue
Block a user