|
@@ -2346,33 +2346,32 @@ let KMColorPickerViewHeight: CGFloat = 64
|
|
|
|
|
|
for (index, fontName) in fonts.enumerated() {
|
|
|
if let font = NSFont(name: fontName, size: 12.0) {
|
|
|
- let attributedString = NSAttributedString(string: fontName, attributes: [NSAttributedString.Key.font: font])
|
|
|
+ let attributedString = NSAttributedString(string: fontName, attributes: [.font: font])
|
|
|
let item = NSMenuItem()
|
|
|
item.attributedTitle = attributedString
|
|
|
menu.addItem(item)
|
|
|
-
|
|
|
- if self.annotationType == .freeText || self.annotationType == .signText || self.annotationType == .signDate {
|
|
|
- if self.annotationModel?.fontName() == font.fontName {
|
|
|
- selectedIndex = index
|
|
|
- }
|
|
|
+ if [.freeText, .signText, .signDate].contains(self.annotationType),
|
|
|
+ let modelFontName = self.annotationModel?.fontName(),
|
|
|
+ modelFontName == font.fontName {
|
|
|
+ selectedIndex = index
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if self.annotationType == .freeText || self.annotationType == .signText || self.annotationType == .signDate {
|
|
|
- if let data = self.annotationModel?.fontName() {
|
|
|
- let freetextFont = NSFont(name: data, size: 16) ?? NSFont.systemFont(ofSize: 16)
|
|
|
- if let family = freetextFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String,
|
|
|
- let style = freetextFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String {
|
|
|
+ if [.freeText, .signText, .signDate].contains(self.annotationType),
|
|
|
+ let data = self.annotationModel?.fontName() {
|
|
|
+ let freetextFont = NSFont(name: data, size: 16) ?? NSFont.systemFont(ofSize: 16)
|
|
|
+ if let family = freetextFont.fontDescriptor.object(forKey: .family) as? String,
|
|
|
+ let style = freetextFont.fontDescriptor.object(forKey: .face) as? String {
|
|
|
+
|
|
|
+ DispatchQueue.main.async { [weak self] in
|
|
|
+ guard let self = self else { return }
|
|
|
|
|
|
- DispatchQueue.main.async { [weak self] in
|
|
|
- guard let self = self else { return }
|
|
|
- self.fontPopUpButton.menu = menu
|
|
|
- self.fontPopUpButton.selectItem(at: selectedIndex)
|
|
|
-
|
|
|
- let selectedStyleIndex = self.setFontStyle(fontName: family, currentStyle: style)
|
|
|
- self.fontStylePopUpButton.selectItem(at: Int(selectedStyleIndex))
|
|
|
- }
|
|
|
+ self.fontPopUpButton.menu = menu
|
|
|
+ self.fontPopUpButton.selectItem(at: selectedIndex)
|
|
|
+
|
|
|
+ let selectedStyleIndex = self.setFontStyle(fontName: family, currentStyle: style)
|
|
|
+ self.fontStylePopUpButton.selectItem(at: Int(selectedStyleIndex))
|
|
|
}
|
|
|
}
|
|
|
}
|