|
@@ -280,11 +280,12 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
|
|
|
let fontNameArray = KMEditPDFTextManager.manager.fetchTextFontNames()
|
|
|
|
|
|
+ let familyNames = CPDFFont.familyNames
|
|
|
fontNameVC = KMDesignSelect.init(withType: .PopButton)
|
|
|
// fontNameVC?.isScrollPop = true
|
|
|
fontNameBox.contentView = fontNameVC?.view
|
|
|
fontNameBox.fillColor = NSColor.clear
|
|
|
- fontNameVC?.addItems(withObjectValues: fontNameArray)
|
|
|
+ fontNameVC?.addItems(withObjectValues: familyNames)
|
|
|
fontNameVC?.selectItem(at: 0)
|
|
|
fontNameVC?.delete = self
|
|
|
fontNameVC?.borderColor = KMAppearance.Interactive.s0Color()
|
|
@@ -298,12 +299,15 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
fontNameVC?.popViewControllerTextColor = KMAppearance.Layout.h0Color()
|
|
|
fontNameVC?.popViewControllerEnterFillColor = KMAppearance.Interactive.s0Color()
|
|
|
fontNameVC?.updateUI()
|
|
|
+ self.fontNameVC?.isScrollPop = true
|
|
|
|
|
|
let styleArray = defaultFontStyles //KMEditPDFTextManager.manager.fetchFontStyleWithFontName(fontName: fontName)
|
|
|
+
|
|
|
+ let fontStyleNames = CPDFFont.fontNames(forFamilyName: "Helvetica")
|
|
|
fontStyleVC = KMDesignSelect.init(withType: .PopButton)
|
|
|
fontStyleBox.contentView = fontStyleVC?.view
|
|
|
fontStyleBox.fillColor = NSColor.clear
|
|
|
- fontStyleVC?.addItems(withObjectValues: styleArray)
|
|
|
+ fontStyleVC?.addItems(withObjectValues: fontStyleNames)
|
|
|
fontStyleVC?.selectItem(at: 0)
|
|
|
fontStyleVC?.delete = self
|
|
|
fontStyleVC?.borderColor = KMAppearance.Interactive.s0Color()
|
|
@@ -500,7 +504,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
if self.selectAreas.count > 0 {
|
|
|
textsAreas = []
|
|
|
|
|
|
- fontNameVC?.addItems(withObjectValues: KMEditPDFTextManager.manager.fetchTextFontNames())
|
|
|
+// fontNameVC?.addItems(withObjectValues: KMEditPDFTextManager.manager.fetchTextFontNames())
|
|
|
|
|
|
let areas = self.selectAreas
|
|
|
self.alignmentView.editingAreas = areas
|
|
@@ -642,6 +646,10 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
|
|
|
@objc func fontBoldAction(_ sender: AnyObject) {
|
|
|
let state = self.fontBoldVC?.state ?? .None
|
|
|
+ if state == .Disabled {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if state == .Act {
|
|
|
self.fontBoldVC?.state = .Norm
|
|
|
} else {
|
|
@@ -663,6 +671,9 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
|
|
|
@objc func fontItalicAction(_ sender: AnyObject) {
|
|
|
let state = self.fontItalicVC?.state ?? .None
|
|
|
+ if state == .Disabled {
|
|
|
+ return
|
|
|
+ }
|
|
|
if state == .Act {
|
|
|
self.fontItalicVC?.state = .Norm
|
|
|
} else {
|
|
@@ -958,14 +969,15 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
extension KMEditPDFTextPropertyViewController {
|
|
|
func updateFontNameAndStyle(name: String, style: String, needChangeListView: Bool = true, needSave: Bool = true) {
|
|
|
// if fontName != name || fontStyle != style {
|
|
|
- let styleArray = defaultFontStyles //KMEditPDFTextManager.manager.fetchFontStyleWithFontName(fontName: name)
|
|
|
+// let styleArray = defaultFontStyles //KMEditPDFTextManager.manager.fetchFontStyleWithFontName(fontName: name)
|
|
|
var styleString = KMEditPDFTextManager.manager.checkFontStyle(style: style)
|
|
|
- if !styleArray.contains(style) {
|
|
|
- self.fontStyleVC?.addItems(withObjectValues: styleArray)
|
|
|
+ let fontStyleNames = CPDFFont.fontNames(forFamilyName: name)
|
|
|
+ if !fontStyleNames.contains(style) {
|
|
|
+ self.fontStyleVC?.addItems(withObjectValues: fontStyleNames)
|
|
|
self.fontStyleVC?.selectItem(at: 0)
|
|
|
styleString = KMEditPDFTextManager.manager.checkFontStyle(style: self.fontStyleVC!.stringValue)
|
|
|
} else {
|
|
|
- self.fontStyleVC?.selectItem(at: styleArray.firstIndex(of: styleString) ?? 0)
|
|
|
+ self.fontStyleVC?.selectItem(at: fontStyleNames.firstIndex(of: style) ?? 0)
|
|
|
}
|
|
|
|
|
|
var fontName = "\(name)-\(styleString)"
|
|
@@ -1047,11 +1059,36 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
// Bold
|
|
|
|
|
|
private func _boldButtonStateUpdate(fontStyle fStyle: String) {
|
|
|
+ let fontStyleNames = self.fontStyleVC?.items ?? []
|
|
|
+ var hasBold = false
|
|
|
+ for name in fontStyleNames {
|
|
|
+ if name.contains("Bold") {
|
|
|
+ hasBold = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !hasBold {
|
|
|
+ self.fontBoldVC?.state = .Disabled
|
|
|
+ return
|
|
|
+ }
|
|
|
let bold = fStyle.contains("Bold")
|
|
|
self.fontBoldVC?.state = bold ? .Act : .Norm
|
|
|
}
|
|
|
|
|
|
private func _italicButtonStateUpdate(fontStyle fStyle: String) {
|
|
|
+ let fontStyleNames = self.fontStyleVC?.items ?? []
|
|
|
+ var hasItalic = false
|
|
|
+ for name in fontStyleNames {
|
|
|
+ if name.contains("Italic") || name.contains("Oblique") {
|
|
|
+ hasItalic = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !hasItalic {
|
|
|
+ self.fontItalicVC?.state = .Disabled
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
let italic = fStyle.contains("Italic") || fStyle.contains("Oblique")
|
|
|
self.fontItalicVC?.state = italic ? .Act : .Norm
|
|
|
}
|