|
@@ -79,7 +79,13 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
var alignment : NSTextAlignment = .center
|
|
|
var fontName: String = "Helvetica" {
|
|
|
didSet {
|
|
|
- self.fontNameVC?.stringValue = fontName
|
|
|
+ if self.fontNameVC != nil {
|
|
|
+ if self.fontNameVC!.items.contains(fontName) {
|
|
|
+ self.fontNameVC?.stringValue = fontName
|
|
|
+ } else {
|
|
|
+ self.fontNameVC?.stringValue = "Helvetica"
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -257,10 +263,18 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
let areas = self.listView.editingAreas().first
|
|
|
if areas is CPDFEditTextArea {
|
|
|
let sizeString = "\(abs(self.listView.editingSelectionFontSize()))"
|
|
|
- let fontName: String = self.listView.editingSelectionFontName() ?? "Helvetica"
|
|
|
+ var fontName: String = self.listView.editingSelectionFontName() ?? "Helvetica"
|
|
|
let alignment = self.listView.editingSelectionAlignment()
|
|
|
var color = self.listView.editingSelectionFontColor() ?? NSColor.black
|
|
|
|
|
|
+ if self.fontNameVC != nil {
|
|
|
+ if self.fontNameVC!.items.contains(fontName) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ fontName = "Helvetica"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
self.updateTextPresupposition(fontName: fontName, size: CGFloat(Float(sizeString)!), needChangeListView: false)
|
|
|
|
|
|
self.currentColor = color
|
|
@@ -563,8 +577,11 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
func updateFontNameAndStyle(name: String, style: String, needChangeListView: Bool = true) {
|
|
|
if fontName != name || fontStyle != style {
|
|
|
let styleArray = self.fetchFontStyleWithFontName(fontName: name)
|
|
|
-
|
|
|
- let fontName = "\(name)-\(style)"
|
|
|
+ var styleString = self.checkFontStyle(style: style)
|
|
|
+ var fontName = "\(name)-\(styleString)"
|
|
|
+ if styleString.count == 0 {
|
|
|
+ fontName = name
|
|
|
+ }
|
|
|
|
|
|
if self.listView.editingAreas()?.count ?? 0 > 0 {
|
|
|
if needChangeListView {
|
|
@@ -638,13 +655,9 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
let alignment = self.alignment
|
|
|
let fontSize = Float((self.fontSizeVC?.stringValue.replacingOccurrences(of: "pt", with: ""))!)
|
|
|
let fontName = self.fontNameVC?.stringValue
|
|
|
- var fontStyle = self.fontStyleVC?.stringValue
|
|
|
+ var fontStyle = self.checkFontStyle(style: self.fontStyleVC?.stringValue ?? "")
|
|
|
let fontCurrentColor = self.currentColor
|
|
|
|
|
|
- if fontStyle == "Regular" || fontStyle == "Roman" {
|
|
|
- fontStyle = ""
|
|
|
- }
|
|
|
-
|
|
|
let editringareas = self.listView.editingAreas()
|
|
|
let count = self.listView.editingAreas()?.count
|
|
|
let editingSelectionString = self.listView.editingSelectionString()
|
|
@@ -693,6 +706,14 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
self.preImageView.image = image
|
|
|
}
|
|
|
|
|
|
+ func checkFontStyle(style: String) -> String {
|
|
|
+ var result = style
|
|
|
+ if style == "Regular" || style == "Roman" {
|
|
|
+ result = ""
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ }
|
|
|
+
|
|
|
func supportFontSize() -> [String] {
|
|
|
return ["8pt", "9pt", "10pt", "11pt", "12pt", "14pt", "16pt", "18pt", "20pt", "22pt", "24pt", "26pt", "28pt", "36pt", "48pt", "72pt"]
|
|
|
}
|