|
@@ -94,16 +94,7 @@ class KMSliderItemView: NSView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-enum CPDFActiveAreasAlignType : Int {
|
|
|
- case Left
|
|
|
- case Vertical
|
|
|
- case Right
|
|
|
- case Top
|
|
|
- case Horizontally
|
|
|
- case Bottom
|
|
|
- case DisHorizontally
|
|
|
- case DisVertical
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
@IBOutlet weak var contentView: NSClipView!
|
|
@@ -164,7 +155,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
@IBOutlet weak var fontReduceBox: NSBox!
|
|
|
var fontAddVC: KMDesignButton?
|
|
|
var fontReduceVC: KMDesignButton?
|
|
|
-
|
|
|
+
|
|
|
@IBOutlet weak var opacityBox: NSBox!
|
|
|
var opacitVC: KMDesignSelect?
|
|
|
var sliderItemView: KMSliderItemView?
|
|
@@ -188,7 +179,6 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
self.fontNameVC?.stringValue = fontName
|
|
|
}
|
|
|
} else {
|
|
|
-// self.fontNameVC?.stringValue = "Helvetica"
|
|
|
let areas = self.handdler?.editingTextAreas ?? []
|
|
|
if areas.count == 1 {
|
|
|
let cfont = self.listView.editingSelectionCFont(byRangeEdit: areas.first)
|
|
@@ -244,9 +234,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
self.addNotification()
|
|
|
self.setup()
|
|
|
self.initData()
|
|
|
-// self.reloadData()
|
|
|
self.updateLanguage()
|
|
|
-// self.updatePreviewImage()
|
|
|
self.updateUI()
|
|
|
|
|
|
self.headerBox.isHidden = true
|
|
@@ -256,23 +244,21 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
}
|
|
|
|
|
|
func setup() {
|
|
|
-// self.backgroundView.backgroundColor(KMAppearance.Layout.bgDrakColor())
|
|
|
self.propertyTitle.font = NSFont.SFProTextSemiboldFont(14.0)
|
|
|
self.propertyTitle.textColor = KMAppearance.Layout.h0Color()
|
|
|
-
|
|
|
+
|
|
|
self.fontTitleLabel.font = NSFont.SFProTextRegularFont(12.0)
|
|
|
self.fontTitleLabel.textColor = KMAppearance.Layout.h0Color()
|
|
|
-
|
|
|
+
|
|
|
self.headerBox.borderWidth = 1
|
|
|
self.headerBox.borderColor = KMAppearance.Interactive.s0Color()
|
|
|
self.headerBox.cornerRadius = 4
|
|
|
self.headerBox.fillColor = KMAppearance.Layout.l1Color()
|
|
|
|
|
|
- //
|
|
|
self.fontColorButton.border(NSColor.clear, 0, 10)
|
|
|
self.fontColorButton.target = self
|
|
|
self.fontColorButton.action = #selector(fontColorAction)
|
|
|
- //alignment
|
|
|
+
|
|
|
leftAlignmentVC = KMDesignPropertySelector.init(withType: .Icon_Btn)
|
|
|
leftAlignmentBox.contentView = leftAlignmentVC?.view
|
|
|
leftAlignmentBox.fillColor = NSColor.clear
|
|
@@ -310,7 +296,6 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
|
|
|
let familyNames = CPDFFont.familyNames
|
|
|
fontNameVC = KMDesignSelect.init(withType: .PopButton)
|
|
|
-// fontNameVC?.isScrollPop = true
|
|
|
fontNameBox.contentView = fontNameVC?.view
|
|
|
fontNameBox.fillColor = NSColor.clear
|
|
|
fontNameVC?.addItems(withObjectValues: familyNames)
|
|
@@ -444,7 +429,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
textPresuppositionResetVC?.borderWidth_disabled = 1
|
|
|
textPresuppositionResetVC?.borderColor_disabled = KMAppearance.view_border_dis_color()
|
|
|
textPresuppositionResetVC?.updateUI()
|
|
|
-
|
|
|
+
|
|
|
self.colorBox.borderColor = KMAppearance.Interactive.s0Color()
|
|
|
|
|
|
let sliderItemView = KMSliderItemView()
|
|
@@ -457,7 +442,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
sliderItemView.maxValue = 1
|
|
|
sliderItemView.valueChange = { [weak self] value in
|
|
|
self?.opacitVC?.stringValue = String(format: "%0.f%%", value*100)
|
|
|
-
|
|
|
+
|
|
|
if let data = self?.opacitVC {
|
|
|
self?.km_comboBoxSelectionDidChange(data)
|
|
|
}
|
|
@@ -482,13 +467,6 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
|
|
|
self.alignmentView.didChange = { [unowned self] view, areasArray, boundsArray in
|
|
|
self.changeAreasAlign(areas: areasArray, newBounds: boundsArray)
|
|
|
-
|
|
|
- self._trackEvent()
|
|
|
- let textAreas = self.handdler?.editingTextAreas ?? []
|
|
|
- let imageAreas = self.handdler?.editingImageAreas ?? []
|
|
|
- if textAreas.count > 0 && imageAreas.count > 0 {
|
|
|
- self._trackAlignEvent()
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
self.changeEffectiveAppearance()
|
|
@@ -576,24 +554,19 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
self.fontReduceVC?.background_act = KMAppearance.Interactive.m1Color()
|
|
|
self.fontReduceVC?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
|
|
|
self.fontReduceVC?.borderColor_hov = KMAppearance.Interactive.a0Color()
|
|
|
-// self.fontAddVC?.background_act = KMAppearance.Interactive.m1Color()
|
|
|
-// self.fontAddVC?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
|
|
|
-// self.fontAddVC?.borderColor_hov = KMAppearance.Interactive.a0Color()
|
|
|
self.fontReduceVC?.image_disabled = NSImage(named: "KMImageNameEditPDFFontReduceDisabled")!
|
|
|
self.fontReduceVC?.background_disabled = NSColor(white: 96/255.0, alpha: 1.0)
|
|
|
|
|
|
self.leftAlignmentVC?.background_sel = KMAppearance.Interactive.m1Color()
|
|
|
self.centerAlignmentVC?.background_sel = KMAppearance.Interactive.m1Color()
|
|
|
self.rightAlignmentVC?.background_sel = KMAppearance.Interactive.m1Color()
|
|
|
-
|
|
|
+
|
|
|
let color = NSColor(hex: "#0E1114")
|
|
|
-// fontNameVC?.popViewControllerBackground = KMAppearance.Layout.bgColor()
|
|
|
fontNameVC?.popViewControllerBackground = color
|
|
|
} else {
|
|
|
self.backgroundView.backgroundColor(NSColor.km_init(hex: "#FAFAFA"))
|
|
|
-
|
|
|
+
|
|
|
self.propertyTitle.textColor = KMAppearance.Layout.h0Color()
|
|
|
-// self.fontTitleLabel.textColor = KMAppearance.Layout.h0Color()
|
|
|
self.fontTitleLabel.textColor = NSColor(hex: "#616469")
|
|
|
self.sliderItemView?.titleLabel.textColor = NSColor(hex: "#616469")
|
|
|
self.alignmentView.alignmentLabel.textColor = NSColor(hex: "#616469")
|
|
@@ -684,19 +657,14 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
|
|
|
self.fontItalicVC?.initDefaultValue()
|
|
|
|
|
|
-// self.fontAddVC?.pagination()
|
|
|
self.fontAddVC?.ignoreDisabledImage = true
|
|
|
self.fontAddVC?.initDefaultValue()
|
|
|
self.fontAddVC?.image = NSImage(named: "KMImageNameEditPDFFontAdd")!
|
|
|
-// self.fontAddVC?.image_disabled = NSImage(named: "KMImageNameEditPDFFontAddDisabled")!
|
|
|
-// self.fontAddVC?.background_disabled = NSColor.red
|
|
|
self.fontAddVC?.background_disabled = KMAppearance.buttonDisabledColor()
|
|
|
|
|
|
self.fontReduceVC?.ignoreDisabledImage = true
|
|
|
self.fontReduceVC?.initDefaultValue()
|
|
|
self.fontReduceVC?.image = NSImage(named: "KMImageNameEditPDFFontReduce")!
|
|
|
-// self.fontAddVC?.image_disabled = NSImage(named: "KMImageNameEditPDFFontAddDisabled")!
|
|
|
-// self.fontAddVC?.background_disabled = NSColor.red
|
|
|
self.fontReduceVC?.background_disabled = KMAppearance.buttonDisabledColor()
|
|
|
}
|
|
|
}
|
|
@@ -754,7 +722,6 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
if areas is CPDFEditTextArea {
|
|
|
let area = areas as! CPDFEditTextArea
|
|
|
let cFont = self.listView.editingSelectionCFont(byRangeEdit: area)
|
|
|
-// let cFont = self.listView.editingSelectionCFont(with: area)
|
|
|
var sizeString = "\(self.listView.editingSelectionFontSize(byRangeEdit: area))"
|
|
|
var fontName: String = cFont?.familyName ?? "Helvetica"
|
|
|
if fontName.count == 0 {
|
|
@@ -766,15 +733,9 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
}
|
|
|
let alignment = self.listView.currentSelectionAlignment(byRangeEdit: area)
|
|
|
let color = self.listView.editingSelectionFontColor(byRangeEdit: area) ?? NSColor.black
|
|
|
-// fontName = KMEditPDFTextManager.manager.transformAreaTextFontName(fontName: fontName, fontNames: self.fontNameVC?.items ?? [])
|
|
|
|
|
|
self.fontNameVC?.stringValue = cFont?.familyName == nil ? "--" : fontName
|
|
|
-// if let data = self.listView?.isBoldCurrentSelection(byRangeEdit: area), data {
|
|
|
-// fontName += "-Bold"
|
|
|
-// }
|
|
|
-// if let data = self.listView?.isItalicCurrentSelection(byRangeEdit: area), data {
|
|
|
-// fontName += "-Italic"
|
|
|
-// }
|
|
|
+
|
|
|
//获取默认数据
|
|
|
if needDefaultData {
|
|
|
let model = KMEditPDFTextManager.manager.fetchUserDefaultData(type: .commonly)
|
|
@@ -784,21 +745,12 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
}
|
|
|
|
|
|
self.updateTextTextPresuppositionState()
|
|
|
-// var fontN = fontName
|
|
|
-// if let data = cFont {
|
|
|
-// fontN = CPDFFont.convertAppleFont(data) ?? fontName
|
|
|
-// }
|
|
|
self.updateTextPresupposition(fontName: fontName, style: fontStyle, size: CGFloat(Float(sizeString)!), needChangeListView: false)
|
|
|
self.currentColor = color
|
|
|
-// DispatchQueue.main.async {
|
|
|
-// NSColorPanel.shared.color = color
|
|
|
-// }
|
|
|
self.fontColorButton.image = self.swatchWithColor(color: color, size: NSSize(width: 20, height: 20))
|
|
|
self.alignment = alignment
|
|
|
self.selectAlignment(alignment: alignment)
|
|
|
|
|
|
-// self.updatePreviewImage()
|
|
|
-
|
|
|
let opacity = self.listView.opacity(for: areas as? CPDFEditArea)
|
|
|
let sliderView = self.opacityBox.contentView as? KMSliderItemView
|
|
|
sliderView?.doubleValue = Double(opacity)
|
|
@@ -816,7 +768,6 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
if let data = self.handdler?.editAreasFontNameIsEqual(), data {
|
|
|
if let area = self.handdler?.editingTextAreas.first {
|
|
|
let font = self.listView.editingSelectionCFont(byRangeEdit: area)
|
|
|
-// let font = self.listView.editingSelectionCFont(with: area)
|
|
|
self.fontNameVC?.stringValue = font?.familyName ?? ""
|
|
|
}
|
|
|
} else {
|
|
@@ -825,7 +776,6 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
|
|
|
if let data = self.handdler?.editAreasFontStyleIsEqual(), data {
|
|
|
if let area = self.handdler?.editingTextAreas.first {
|
|
|
-// if let styleName = self.listView.editingSelectionCFont(with: area)?.styleName, styleName.isEmpty == false {
|
|
|
if let styleName = self.listView.editingSelectionCFont(byRangeEdit: area)?.styleName, styleName.isEmpty == false {
|
|
|
self.fontStyleVC?.stringValue = styleName
|
|
|
} else {
|
|
@@ -930,8 +880,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
//MARK: - Action
|
|
|
extension KMEditPDFTextPropertyViewController {
|
|
|
@IBAction func fontColorAction(_ sender: Any) {
|
|
|
- self._trackEvent()
|
|
|
-
|
|
|
+
|
|
|
let color = self.listView.editingSelectionFontColor(with: self.selectAreas.first as? CPDFEditTextArea)
|
|
|
let panel = NSColorPanel.shared
|
|
|
panel.setTarget(self)
|
|
@@ -944,7 +893,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@objc func fontColorChangeAction() {
|
|
|
let color = NSColorPanel.shared.color
|
|
|
self.currentColor = color
|
|
@@ -959,7 +908,6 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
} else {
|
|
|
KMEditPDFTextManager.manager.setCommonlyFontColor(color: self.currentColor)
|
|
|
}
|
|
|
-// self.updatePreviewImage()
|
|
|
}
|
|
|
|
|
|
@objc func fontBoldAction(_ sender: AnyObject) {
|
|
@@ -976,7 +924,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
self.fontBoldVC?.state = .Act
|
|
|
boldV = true
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
let index = self.textPresuppositionVC?.indexOfSelectedItem ?? 0
|
|
|
let type = KMEditPDFTextFontType.typeOfRawValue(value: KMEditPDFTextFontType.allValues()[index])
|
|
|
let model = KMEditPDFTextManager.manager.fetchUserDefaultData(type: type)
|
|
@@ -986,8 +934,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
KMEditPDFTextManager.manager.changeTextPresupposition(fontName: model_com.fontName, fontStyle: model_com.fontStyle, fontSize: model_com.fontSize, type: .commonly, bold: boldV, italic: nil)
|
|
|
|
|
|
self.handdler?.fontBoldAction()
|
|
|
-
|
|
|
- self._trackEvent()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@objc func fontItalicAction(_ sender: AnyObject) {
|
|
@@ -1013,8 +960,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
KMEditPDFTextManager.manager.changeTextPresupposition(fontName: model_com.fontName, fontStyle: model_com.fontStyle, fontSize: model_com.fontSize, type: .commonly, bold: nil, italic: italicV)
|
|
|
|
|
|
self.handdler?.fontItalicAction()
|
|
|
-
|
|
|
- self._trackEvent()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@objc func fontAddAction(_ sender: AnyObject) {
|
|
@@ -1026,8 +972,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
let size = Float(self.fontSizeVC?.stringValue.replacingOccurrences(of: "pt", with: "") ?? "12") ?? 1
|
|
|
self.fontSizeVC?.stringValue = String(format: "%.0fpt", size+1)
|
|
|
self.km_comboBoxSelectionDidChange(self.fontSizeVC!)
|
|
|
-
|
|
|
- self._trackEvent()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@objc func fontReduceAction(_ sender: AnyObject) {
|
|
@@ -1042,8 +987,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
}
|
|
|
self.fontSizeVC?.stringValue = String(format: "%.0fpt", size-1)
|
|
|
self.km_comboBoxSelectionDidChange(self.fontSizeVC!)
|
|
|
-
|
|
|
- self._trackEvent()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@objc func leftAlignmentAction(sender: NSButton?) {
|
|
@@ -1053,7 +997,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
self.updateAlignment(alignment: .left)
|
|
|
if let _ = sender {
|
|
|
KMEditPDFPopToolBarWindow.shared.updateTextAlign(align: .left)
|
|
|
- self._trackEvent()
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1066,8 +1010,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
if let _ = sender {
|
|
|
KMEditPDFPopToolBarWindow.shared.updateTextAlign(align: .center)
|
|
|
}
|
|
|
-
|
|
|
- self._trackEvent()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@objc func rightAlignmentAction(sender: NSButton?) {
|
|
@@ -1079,8 +1022,6 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
if let _ = sender {
|
|
|
KMEditPDFPopToolBarWindow.shared.updateTextAlign(align: .right)
|
|
|
}
|
|
|
-
|
|
|
- self._trackEvent()
|
|
|
}
|
|
|
|
|
|
func selectAlignment(alignment: NSTextAlignment) {
|
|
@@ -1134,8 +1075,7 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
createFilePopover.behavior = .semitransient
|
|
|
createFilePopover.setValue(true, forKey: "shouldHideAnchor")
|
|
|
createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: -10, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
|
|
|
-
|
|
|
-// vc.customBoxWidthLayoutConstraint.constant = self.popWidth ?? sender.frame.width
|
|
|
+
|
|
|
vc.downCallback = { [unowned self](downEntered: Bool, count: String) -> Void in
|
|
|
if downEntered {
|
|
|
if count == NSLocalizedString("Reset", comment: "") {
|
|
@@ -1153,29 +1093,20 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
if areas is CPDFEditTextArea {
|
|
|
var size: CGFloat = (abs(self.listView.editingSelectionFontSize(byRangeEdit: areas as? CPDFEditTextArea)))
|
|
|
let cfont = self.listView.editingSelectionCFont(byRangeEdit: areas as? CPDFEditTextArea)
|
|
|
-// let cfont = self.listView.editingSelectionCFont(with: areas as? CPDFEditTextArea)
|
|
|
var fontName = cfont?.familyName ?? "Helvetica"
|
|
|
-// fontName = KMEditPDFTextManager.manager.transformAreaTextFontName(fontName: fontName, fontNames: self.fontNameVC?.items ?? [])
|
|
|
|
|
|
var isBold = false
|
|
|
if let data = self.listView?.isBoldCurrentSelection(byRangeEdit: areas as? CPDFEditTextArea) {
|
|
|
-// fontName += "-Bold"
|
|
|
isBold = data
|
|
|
}
|
|
|
var isItalic = false
|
|
|
if let data = self.listView?.isItalicCurrentSelection(byRangeEdit: areas as? CPDFEditTextArea) {
|
|
|
-// fontName += "-Italic"
|
|
|
isItalic = data
|
|
|
}
|
|
|
-// var fontN = fontName
|
|
|
-// if let data = cfont {
|
|
|
-// fontN = CPDFFont.convertAppleFont(data) ?? fontName
|
|
|
-// }
|
|
|
|
|
|
let models = KMEditPDFTextManager.manager.fetchAllUserDefaultData()
|
|
|
var index = 0
|
|
|
- // && model.bold == isBold && model.italic == isItalic
|
|
|
- for i in 0...models.count - 1 {
|
|
|
+ for i in 0...models.count - 1 {
|
|
|
let model = models[i]
|
|
|
if model.fontName == fontName && model.fontStyle == cfont?.styleName && size == model.fontSize {
|
|
|
index = i
|
|
@@ -1203,7 +1134,6 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
KMEditPDFTextManager.manager.setFontAlignment(alignment: alignment)
|
|
|
}
|
|
|
self.alignment = alignment
|
|
|
-// self.updatePreviewImage()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1244,7 +1174,6 @@ extension KMEditPDFTextPropertyViewController: KMSelectPopButtonDelegate {
|
|
|
self.updateTextPresupposition(type: type)
|
|
|
} else if obj == fontNameVC {
|
|
|
self.updateFontNameAndStyle(name: obj.stringValue, style: fontStyle)
|
|
|
-// self.updatePreviewImage()
|
|
|
let win = KMEditPDFPopToolBarWindow.shared
|
|
|
if win.isVisible {
|
|
|
(win.contentViewController as? KMEditPDFPopToolBarController)?.toolbarView?.reloadData()
|
|
@@ -1252,12 +1181,10 @@ extension KMEditPDFTextPropertyViewController: KMSelectPopButtonDelegate {
|
|
|
} else if obj == fontSizeVC {
|
|
|
let size = CGFloat(Float((obj.stringValue.replacingOccurrences(of: "pt", with: "")))!)
|
|
|
self.updateFontSize(size: size)
|
|
|
-// self.updatePreviewImage()
|
|
|
|
|
|
KMEditPDFPopToolBarWindow.shared.updateFontSizeButtons(enable: true)
|
|
|
} else if obj == fontStyleVC {
|
|
|
self.updateFontNameAndStyle(name: fontName, style: obj.stringValue)
|
|
|
-// self.updatePreviewImage()
|
|
|
} else if obj == self.opacitVC {
|
|
|
let stringValue = self.opacitVC?.stringValue ?? ""
|
|
|
let value = (stringValue.components(separatedBy: "%").first?.stringToCGFloat() ?? 0) / 100
|
|
@@ -1298,7 +1225,6 @@ extension KMEditPDFTextPropertyViewController: KMSelectPopButtonDelegate {
|
|
|
return
|
|
|
}
|
|
|
if let label = cellView.contentView?.subviews.first as? NSTextField {
|
|
|
- /* 14.0 "SFProText-Regular" */
|
|
|
|
|
|
let allValues = KMEditPDFTextFontType.allValues()
|
|
|
let idx = allValues.count-index-1
|
|
@@ -1326,10 +1252,9 @@ extension KMEditPDFTextPropertyViewController: KMSelectPopButtonDelegate {
|
|
|
}
|
|
|
let model = KMEditPDFTextManager.manager.fetchUserDefaultData(type: type)
|
|
|
let fontName: String = model.fontName
|
|
|
-// let size: CGFloat = model.fontSize
|
|
|
var fontN: String = fontName
|
|
|
if let cfont = CPDFFont.mappingFont(withFontString: fontName) {
|
|
|
- fontN = CPDFFont.convertAppleFont(cfont) ?? fontName
|
|
|
+ fontN = CPDFFont.convertAppleFont(cfont) ?? fontName
|
|
|
}
|
|
|
var bold = fontName.contains("Bold")
|
|
|
var italic = fontName.contains("Oblique") || fontName.contains("Italic")
|
|
@@ -1340,33 +1265,22 @@ extension KMEditPDFTextPropertyViewController: KMSelectPopButtonDelegate {
|
|
|
italic = model.italic
|
|
|
}
|
|
|
|
|
|
-// if let data = NSFont(name: fontN, size: fontSidze) {
|
|
|
-// let attri = NSMutableAttributedString(attributedString: label.attributedStringValue)
|
|
|
-// attri.addAttribute(.font, value: data, range: NSMakeRange(0, attri.string.count))
|
|
|
-// label.attributedStringValue = attri
|
|
|
-// } else {
|
|
|
- let attri = NSMutableAttributedString(attributedString: label.attributedStringValue)
|
|
|
- if bold {
|
|
|
- attri.addAttribute(.font, value: NSFont.boldSystemFont(ofSize: fontSize), range: NSMakeRange(0, attri.string.count))
|
|
|
- } else {
|
|
|
- attri.addAttribute(.font, value: NSFont.systemFont(ofSize: fontSize), range: NSMakeRange(0, attri.string.count))
|
|
|
- }
|
|
|
- if italic {
|
|
|
- attri.addAttribute(.obliqueness, value: 0.3, range: NSMakeRange(0, attri.string.count))
|
|
|
- }
|
|
|
- label.attributedStringValue = attri
|
|
|
-// }
|
|
|
+ let attri = NSMutableAttributedString(attributedString: label.attributedStringValue)
|
|
|
+ if bold {
|
|
|
+ attri.addAttribute(.font, value: NSFont.boldSystemFont(ofSize: fontSize), range: NSMakeRange(0, attri.string.count))
|
|
|
+ } else {
|
|
|
+ attri.addAttribute(.font, value: NSFont.systemFont(ofSize: fontSize), range: NSMakeRange(0, attri.string.count))
|
|
|
+ }
|
|
|
+ if italic {
|
|
|
+ attri.addAttribute(.obliqueness, value: 0.3, range: NSMakeRange(0, attri.string.count))
|
|
|
+ }
|
|
|
+ label.attributedStringValue = attri
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func km_SelectPopoverWillShow(_ obj: KMDesignSelect) {
|
|
|
- if obj.isEqual(to: self.fontNameVC) {
|
|
|
- self._trackEvent()
|
|
|
- } else if obj.isEqual(to: self.fontStyleVC) {
|
|
|
- self._trackEvent()
|
|
|
- } else if obj.isEqual(to: self.fontSizeVC) {
|
|
|
- self._trackEvent()
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1374,28 +1288,10 @@ extension KMEditPDFTextPropertyViewController: KMSelectPopButtonDelegate {
|
|
|
extension KMEditPDFTextPropertyViewController {
|
|
|
//MARK: 基本属性调整
|
|
|
func updateTextPresupposition(fontName: String, style: String, size: CGFloat, needChangeListView: Bool = true) {
|
|
|
-// let fontNameArray = fontName.components(separatedBy: "-")
|
|
|
-// var name = ""
|
|
|
-// var style = ""
|
|
|
-// if fontNameArray.count > 0 {
|
|
|
-// name = fontNameArray.first!
|
|
|
-// } else {
|
|
|
-// name = "Helvetica"
|
|
|
-// }
|
|
|
-//
|
|
|
-// if fontNameArray.count == 4 {
|
|
|
-// style = "\(fontNameArray[2]) \(fontNameArray[3])"
|
|
|
-// } else if fontNameArray.count == 3 {
|
|
|
-// style = "\(fontNameArray[1]) \(fontNameArray[2])"
|
|
|
-// } else if fontNameArray.count == 2 {
|
|
|
-// style = fontNameArray.last!
|
|
|
-// } else {
|
|
|
-// style = "Regular"
|
|
|
-// }
|
|
|
+
|
|
|
|
|
|
self.updateFontNameAndStyle(name: fontName, style: style, needChangeListView: needChangeListView, needSave: false)
|
|
|
self.updateFontSize(size: size, needChangeListView: needChangeListView, needSave: false)
|
|
|
-// self.updatePreviewImage()
|
|
|
}
|
|
|
|
|
|
func resetTextPresuppositionData() {
|
|
@@ -1422,27 +1318,21 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
}
|
|
|
|
|
|
//MARK: - Private
|
|
|
-// 更新字体名称+字重
|
|
|
|
|
|
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)
|
|
|
-// var styleString = KMEditPDFTextManager.manager.checkFontStyle(style: style)
|
|
|
+
|
|
|
var styleString = style
|
|
|
let fontStyleNames = CPDFFont.fontNames(forFamilyName: name)
|
|
|
if !fontStyleNames.contains(style) {
|
|
|
if fontStyleNames.isEmpty {
|
|
|
self.fontStyleVC?.addItems(withObjectValues: [style])
|
|
|
self.fontStyleVC?.selectItem(at: 0)
|
|
|
- // styleString = KMEditPDFTextManager.manager.checkFontStyle(style: self.fontStyleVC!.stringValue)
|
|
|
styleString = style
|
|
|
} else {
|
|
|
self.fontStyleVC?.addItems(withObjectValues: fontStyleNames)
|
|
|
self.fontStyleVC?.selectItem(at: 0)
|
|
|
- // styleString = KMEditPDFTextManager.manager.checkFontStyle(style: self.fontStyleVC!.stringValue)
|
|
|
styleString = fontStyleNames.first ?? ""
|
|
|
}
|
|
|
} else {
|
|
@@ -1450,30 +1340,14 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
self.fontStyleVC?.selectItem(at: fontStyleNames.firstIndex(of: style) ?? 0)
|
|
|
}
|
|
|
|
|
|
-// var fontName = "\(name)-\(styleString)"
|
|
|
-// if styleString.count == 0 {
|
|
|
-// fontName = name
|
|
|
-// }
|
|
|
-
|
|
|
//数据保存返回
|
|
|
if self.selectAreas.count > 0 {
|
|
|
if needChangeListView {
|
|
|
let areas = self.handdler?.editingTextAreas ?? []
|
|
|
for area in areas {
|
|
|
-// self.listView.setEditingSelectionFontName(name, with: area)
|
|
|
let font = CPDFFont(familyName: name, fontStyle: styleString)
|
|
|
self.listView.setEditSelectionCFont(font, with: area)
|
|
|
-// if styleString.contains("Bold") {
|
|
|
-// self.listView.setCurrentSelectionIsBold(true, with: area)
|
|
|
-// } else {
|
|
|
-// self.listView.setCurrentSelectionIsBold(false, with: area)
|
|
|
-// }
|
|
|
-//
|
|
|
-// if styleString.contains("Oblique") || styleString.contains("Italic") {
|
|
|
-// self.listView.setCurrentSelectionIsItalic(true, with: area)
|
|
|
-// } else {
|
|
|
-// self.listView.setCurrentSelectionIsItalic(false, with: area)
|
|
|
-// }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -1484,7 +1358,6 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
}
|
|
|
|
|
|
self.fontName = name
|
|
|
-// self.fontStyle = self.fontStyleVC?.stringValue ?? "Regular"
|
|
|
self.fontStyle = styleString
|
|
|
|
|
|
if needSave {
|
|
@@ -1498,13 +1371,11 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
//刷新样式
|
|
|
textPresuppositionVC?.addItems(withObjectValues: KMEditPDFTextManager.manager.updateTextPresuppositionFontNameArray())
|
|
|
textPresuppositionVC?.selectItem(at: textPresuppositionVC!.indexOfSelectedItem)
|
|
|
- // }
|
|
|
|
|
|
self._boldButtonStateUpdate(fontStyle: styleString)
|
|
|
}
|
|
|
|
|
|
func updateFontSize(size: CGFloat, needChangeListView: Bool = true, needSave: Bool = true) {
|
|
|
- // var fontSize = Float((self.fontSizeVC?.stringValue.replacingOccurrences(of: "pt", with: ""))!) ?? 8.0
|
|
|
if fontSize != size {
|
|
|
let areas = self.handdler?.editingTextAreas ?? []
|
|
|
if areas.count > 0 {
|
|
@@ -1590,13 +1461,11 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
|
|
|
let editringareas = self.selectAreas
|
|
|
let count = editringareas.count
|
|
|
-// let editingSelectionString = self.listView.editingSelectionString()
|
|
|
let editingSelectionAlignment = self.listView.editingSelectionAlignment(with: editringareas.first as? CPDFEditTextArea)
|
|
|
|
|
|
if count == 1 {
|
|
|
let areas = editringareas.first
|
|
|
if areas is CPDFEditTextArea {
|
|
|
-// string = editingSelectionString ?? NSLocalizedString("Sample", comment: "")
|
|
|
alignment = editingSelectionAlignment
|
|
|
}
|
|
|
}
|
|
@@ -1612,13 +1481,6 @@ extension KMEditPDFTextPropertyViewController {
|
|
|
func supportFontSize() -> [String] {
|
|
|
return ["8pt", "9pt", "10pt", "11pt", "12pt", "14pt", "16pt", "18pt", "20pt", "22pt", "24pt", "26pt", "28pt", "36pt", "48pt", "72pt"]
|
|
|
}
|
|
|
-
|
|
|
- private func _trackEvent() {
|
|
|
- kTrackEventManager.trackEvent(event: "SubTbr_EditPDF", withProperties: ["SubTbr_EditText":"SubTbr_EditText_PropertiesPanel_All"])
|
|
|
- }
|
|
|
-
|
|
|
- private func _trackAlignEvent() {
|
|
|
- kTrackEventManager.trackEvent(event: "SubTbr_EditPDF", withProperties: ["SubTbr_EditText":"SubTbr_EditContent_AlignContent"])
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|