|
@@ -402,16 +402,16 @@ extension KMEditPDFTextManager {
|
|
|
|
|
|
func fetchFont(fontName: String, style: String, size: CGFloat) -> NSFont {
|
|
|
var fontStyle = style
|
|
|
+
|
|
|
var attributeFontDescriptor = NSFontDescriptor.init(fontAttributes: [NSFontDescriptor.AttributeName.family: fontName])
|
|
|
if fontStyle.count > 0 {
|
|
|
- attributeFontDescriptor = NSFontDescriptor.init(fontAttributes: [NSFontDescriptor.AttributeName.family: fontName, NSFontDescriptor.AttributeName.face : fontStyle])
|
|
|
+ if fontStyle == "Regular" || fontStyle == "Roman" {
|
|
|
+ attributeFontDescriptor = NSFontDescriptor.init(fontAttributes: [NSFontDescriptor.AttributeName.family : fontName])
|
|
|
+ } else {
|
|
|
+ attributeFontDescriptor = NSFontDescriptor.init(fontAttributes: [NSFontDescriptor.AttributeName.family : fontName,NSFontDescriptor.AttributeName.face : fontStyle])
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
var font = NSFont.init(descriptor: attributeFontDescriptor, size: size)
|
|
|
- if font == nil {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
if font == nil {
|
|
|
attributeFontDescriptor = NSFontDescriptor.init(fontAttributes: [NSFontDescriptor.AttributeName.family: FONTNAME_DEFAULT])
|
|
|
font = NSFont.init(descriptor: attributeFontDescriptor, size: size)
|
|
@@ -525,10 +525,18 @@ extension KMEditPDFTextManager {
|
|
|
var name = KMEditPDFTextManager.manager.fetchFontName(fontName: resultString)
|
|
|
var style = KMEditPDFTextManager.manager.fetchFontStyle(fontName: resultString)
|
|
|
|
|
|
- if !fontNames.contains(name) {
|
|
|
+ if !fontNames.contains(name) || fontName == "SimSun" {
|
|
|
name = "Helvetica"
|
|
|
}
|
|
|
|
|
|
+ if name.contains("SimSun") {
|
|
|
+ name = name.replacingOccurrences(of: "SimSun", with: "Helvetica")
|
|
|
+ }
|
|
|
+
|
|
|
+ if name.contains("Arial") {
|
|
|
+ name = name.replacingOccurrences(of: "Arial", with: "Helvetica")
|
|
|
+ }
|
|
|
+
|
|
|
if style.count == 0 {
|
|
|
resultString = name
|
|
|
} else {
|