Browse Source

【fix】【内容编辑】文字块属性面板,文字大小自定义,不应该可以输入0

tangchao 7 months ago
parent
commit
4e4ad63906

+ 10 - 4
PDF Office/PDF Master/Class/Home/ViewController/KMHomePopViewController.swift

@@ -451,10 +451,16 @@ class KMScrollPopViewController: KMHomePopViewController {
         } else {
             debugPrint("不支持字体" + stringValue)
         }
-        boxLabel.font = NSFont(name: fontFamily, size: textTypography.fontSize.stringToCGFloat()) ?? NSFont.systemFont(ofSize: textTypography.fontSize.stringToCGFloat())
-        let paragraphStyle = NSMutableParagraphStyle()
-        paragraphStyle.lineSpacing = textTypography.lineHeight.stringToCGFloat()
-        boxLabel.attributedStringValue = NSAttributedString(string: stringValue, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
+        
+        if stringValue == "Al Tarikh" {
+            boxLabel.font = NSFont.systemFont(ofSize: 14)
+            boxLabel.stringValue = stringValue
+        } else {
+            boxLabel.font = NSFont(name: fontFamily, size: textTypography.fontSize.stringToCGFloat()) ?? NSFont.systemFont(ofSize: textTypography.fontSize.stringToCGFloat())
+            let paragraphStyle = NSMutableParagraphStyle()
+            paragraphStyle.lineSpacing = textTypography.lineHeight.stringToCGFloat()
+            boxLabel.attributedStringValue = NSAttributedString(string: stringValue, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
+        }
         
         if (isDisabled) {
             box.fillColor = KMDesignToken.shared.fill(withToken: "dropdown.m.bg.dis")

+ 7 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditPDFTextPropertyViewController.swift

@@ -779,7 +779,7 @@ extension KMEditPDFTextPropertyViewController {
     }
     
     @objc func fontAddAction(_ sender: AnyObject) {
-        let size = Float(self.fontSizeVC?.stringValue.replacingOccurrences(of: "pt", with: "") ?? "12") ?? 12
+        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!)
         
@@ -787,7 +787,7 @@ extension KMEditPDFTextPropertyViewController {
     }
     
     @objc func fontReduceAction(_ sender: AnyObject) {
-        let size = Float(self.fontSizeVC?.stringValue.replacingOccurrences(of: "pt", with: "") ?? "12") ?? 12
+        let size = Float(self.fontSizeVC?.stringValue.replacingOccurrences(of: "pt", with: "") ?? "12") ?? 1
         if size < 1 {
             return
         }
@@ -992,14 +992,17 @@ extension KMEditPDFTextPropertyViewController: KMSelectPopButtonDelegate {
         if obj == self.fontSizeVC {
             let format = NumberFormatter()
             format.numberStyle = .decimal
-            let size = Float((obj.stringValue.replacingOccurrences(of: "pt", with: ""))) ?? 0
+            var string = obj.stringValue.replacingOccurrences(of: "pt", with: "")
+            string = string.replacingOccurrences(of: "p", with: "")
+            let size = max(Float(string) ?? 1, 1)
             self.fontSizeVC?.stringValue = format.string(from: NSNumber(value: size)) ?? ""
         }
     }
     
     func km_controlTextDidEndEditing(_ obj: KMDesignSelect) {
         if obj == self.fontSizeVC {
-            let size = CGFloat(Float((obj.stringValue.replacingOccurrences(of: "pt", with: ""))) ?? 12)
+            let size = CGFloat(Float((obj.stringValue.replacingOccurrences(of: "pt", with: ""))) ?? 1)
+            let sizeValue = max(size, 1)
             self.fontSizeVC?.stringValue = String(format: "%.0fpt", size)
             self.updateFontSize(size: size)
         }