Fix Font
This commit is contained in:
		| @@ -3,12 +3,12 @@ | |||||||
| FORCE_FLAG="$1" | FORCE_FLAG="$1" | ||||||
|  |  | ||||||
| ## Font | ## Font | ||||||
| #swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \ | swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \ | ||||||
| # --extension-output-path "./Fonts/Generated" \ |  --extension-output-path "./Fonts/Generated" \ | ||||||
| # --extension-name "UIFontYolo" \ |  --extension-name "FontYolo" \ | ||||||
| # --extension-name-swift-ui "FontYolo" \ |  --extension-name-ui-kit "UIFontYolo" \ | ||||||
| # --extension-suffix "GenAllScript" \ |  --extension-suffix "GenAllScript" \ | ||||||
| # --info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist" |  --info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist" | ||||||
| # | # | ||||||
| #echo "\n-------------------------\n" | #echo "\n-------------------------\n" | ||||||
| # | # | ||||||
|   | |||||||
| @@ -97,7 +97,7 @@ fonts: | |||||||
| - | - | ||||||
|    inputFile: ./Fonts/sampleFontsAll.txt |    inputFile: ./Fonts/sampleFontsAll.txt | ||||||
|    extensionOutputPath: ./Fonts/Generated |    extensionOutputPath: ./Fonts/Generated | ||||||
|    extensionName: UIFontYolo |    extensionName: FontYolo | ||||||
|    extensionNameSwiftUI: FontYolo |    extensionNameUIKit: UIFontYolo | ||||||
|    extensionSuffix: GenAllScript |    extensionSuffix: GenAllScript | ||||||
|    infoPlistPaths: "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist" |    infoPlistPaths: "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist" | ||||||
|   | |||||||
| @@ -21,11 +21,11 @@ struct FontsOptions: ParsableArguments { | |||||||
|     @Option(help: "Tell if it will generate static properties or methods") |     @Option(help: "Tell if it will generate static properties or methods") | ||||||
|     var staticMembers: Bool = false |     var staticMembers: Bool = false | ||||||
|      |      | ||||||
|     @Option(help: "Extension name. If not specified, it will generate an UIFont extension.") |     @Option(help: "Extension name. If not specified, it will generate an Font extension.") | ||||||
|     var extensionName: String = Fonts.defaultExtensionName |     var extensionName: String = Fonts.defaultExtensionName | ||||||
|      |      | ||||||
|     @Option(help: "Extension name. If not specified, it will generate an Font extension.") |     @Option(help: "Extension name. If not specified, it will generate an UIFont extension.") | ||||||
|     var extensionNameSwiftUI: String = Fonts.defaultExtensionNameSUI |     var extensionNameUIKit: String = Fonts.defaultExtensionNameUIKit | ||||||
|      |      | ||||||
|     @Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+FontsMyApp.swift") |     @Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+FontsMyApp.swift") | ||||||
|     var extensionSuffix: String = "" |     var extensionSuffix: String = "" | ||||||
| @@ -38,7 +38,7 @@ struct FontsOptions: ParsableArguments { | |||||||
|  |  | ||||||
| extension FontsOptions { | extension FontsOptions { | ||||||
|      |      | ||||||
|     // MARK: - UIKit |     // MARK: - SwiftUI | ||||||
|      |      | ||||||
|     var extensionFileName: String { |     var extensionFileName: String { | ||||||
|         if extensionSuffix.isEmpty == false { |         if extensionSuffix.isEmpty == false { | ||||||
| @@ -51,17 +51,17 @@ extension FontsOptions { | |||||||
|         "\(extensionOutputPath)/\(extensionFileName)" |         "\(extensionOutputPath)/\(extensionFileName)" | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     // MARK: - SwiftUI |     // MARK: - UIKit | ||||||
|      |      | ||||||
|     var extensionFileNameSwiftUI: String { |     var extensionFileNameUIKit: String { | ||||||
|         if extensionSuffix.isEmpty == false { |         if extensionSuffix.isEmpty == false { | ||||||
|             return "\(extensionNameSwiftUI)+\(extensionSuffix).swift" |             return "\(extensionNameUIKit)+\(extensionSuffix).swift" | ||||||
|         } |         } | ||||||
|         return "\(extensionNameSwiftUI).swift" |         return "\(extensionNameUIKit).swift" | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     var extensionFilePathSwiftUI: String { |     var extensionFilePathUIKit: String { | ||||||
|         "\(extensionOutputPath)/\(extensionFileNameSwiftUI)" |         "\(extensionOutputPath)/\(extensionFileNameUIKit)" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // MARK: -  |     // MARK: -  | ||||||
|   | |||||||
| @@ -21,8 +21,8 @@ struct Fonts: ParsableCommand { | |||||||
|     // MARK: - Static |     // MARK: - Static | ||||||
|      |      | ||||||
|     static let toolName = "Fonts" |     static let toolName = "Fonts" | ||||||
|     static let defaultExtensionName = "UIFont" |     static let defaultExtensionName = "Font" | ||||||
|     static let defaultExtensionNameSUI = "Font" |     static let defaultExtensionNameUIKit = "UIFont" | ||||||
|      |      | ||||||
|     // MARK: - Command Options |     // MARK: - Command Options | ||||||
|      |      | ||||||
| @@ -52,13 +52,13 @@ struct Fonts: ParsableCommand { | |||||||
|                                                   staticVar: options.staticMembers, |                                                   staticVar: options.staticMembers, | ||||||
|                                                   extensionName: options.extensionName, |                                                   extensionName: options.extensionName, | ||||||
|                                                   extensionFilePath: options.extensionFilePath, |                                                   extensionFilePath: options.extensionFilePath, | ||||||
|                                                   isSwiftUI: false) |                                                   isSwiftUI: true) | ||||||
|          |          | ||||||
|         FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames, |         FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames, | ||||||
|                                                   staticVar: options.staticMembers, |                                                   staticVar: options.staticMembers, | ||||||
|                                                   extensionName: options.extensionNameSwiftUI, |                                                   extensionName: options.extensionNameUIKit, | ||||||
|                                                   extensionFilePath: options.extensionFilePathSwiftUI, |                                                   extensionFilePath: options.extensionFilePathUIKit, | ||||||
|                                                   isSwiftUI: true) |                                                   isSwiftUI: false) | ||||||
|          |          | ||||||
|         print("Info.plist has been updated with:") |         print("Info.plist has been updated with:") | ||||||
|         print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames, infoPlistPaths: options.infoPlistPaths))") |         print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames, infoPlistPaths: options.infoPlistPaths))") | ||||||
| @@ -79,7 +79,7 @@ struct Fonts: ParsableCommand { | |||||||
|         } |         } | ||||||
|          |          | ||||||
|         // Extension for UIKit and SwiftUI should have different name |         // Extension for UIKit and SwiftUI should have different name | ||||||
|         guard options.extensionName != options.extensionNameSwiftUI else { |         guard options.extensionName != options.extensionNameUIKit else { | ||||||
|             let error = FontsToolError.extensionNamesCollision(options.extensionName) |             let error = FontsToolError.extensionNamesCollision(options.extensionName) | ||||||
|             print(error.description) |             print(error.description) | ||||||
|             Fonts.exit(withError: error) |             Fonts.exit(withError: error) | ||||||
|   | |||||||
| @@ -174,7 +174,7 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible { | |||||||
|     let inputFile: String |     let inputFile: String | ||||||
|     let extensionOutputPath: String |     let extensionOutputPath: String | ||||||
|     let extensionName: String? |     let extensionName: String? | ||||||
|     let extensionNameSwiftUI: String? |     let extensionNameUIKit: String? | ||||||
|     let extensionSuffix: String? |     let extensionSuffix: String? | ||||||
|     let infoPlistPaths: String? |     let infoPlistPaths: String? | ||||||
|     private let staticMembers: Bool? |     private let staticMembers: Bool? | ||||||
| @@ -189,14 +189,14 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible { | |||||||
|     internal init(inputFile: String, |     internal init(inputFile: String, | ||||||
|                   extensionOutputPath: String, |                   extensionOutputPath: String, | ||||||
|                   extensionName: String?, |                   extensionName: String?, | ||||||
|                   extensionNameSwiftUI: String?, |                   extensionNameUIKit: String?, | ||||||
|                   extensionSuffix: String?, |                   extensionSuffix: String?, | ||||||
|                   infoPlistPaths: String?, |                   infoPlistPaths: String?, | ||||||
|                   staticMembers: Bool?) { |                   staticMembers: Bool?) { | ||||||
|         self.inputFile = inputFile |         self.inputFile = inputFile | ||||||
|         self.extensionOutputPath = extensionOutputPath |         self.extensionOutputPath = extensionOutputPath | ||||||
|         self.extensionName = extensionName |         self.extensionName = extensionName | ||||||
|         self.extensionNameSwiftUI = extensionNameSwiftUI |         self.extensionNameUIKit = extensionNameUIKit | ||||||
|         self.extensionSuffix = extensionSuffix |         self.extensionSuffix = extensionSuffix | ||||||
|         self.infoPlistPaths = infoPlistPaths |         self.infoPlistPaths = infoPlistPaths | ||||||
|         self.staticMembers = staticMembers |         self.staticMembers = staticMembers | ||||||
| @@ -208,7 +208,7 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible { | |||||||
|             - Input file: \(inputFile) |             - Input file: \(inputFile) | ||||||
|             - Extension output path: \(extensionOutputPath) |             - Extension output path: \(extensionOutputPath) | ||||||
|             - Extension name: \(extensionName ?? "-") |             - Extension name: \(extensionName ?? "-") | ||||||
|             - Extension name SwiftUI: \(extensionNameSwiftUI ?? "-") |             - Extension name UIKit: \(extensionNameUIKit ?? "-") | ||||||
|             - Extension suffix: \(extensionSuffix ?? "-") |             - Extension suffix: \(extensionSuffix ?? "-") | ||||||
|             - InfoPlistPaths: \(infoPlistPaths ?? "-") |             - InfoPlistPaths: \(infoPlistPaths ?? "-") | ||||||
|         """ |         """ | ||||||
|   | |||||||
| @@ -34,10 +34,10 @@ extension FontsConfiguration: Runnable { | |||||||
|                 extensionName |                 extensionName | ||||||
|             ] |             ] | ||||||
|         } |         } | ||||||
|         if let extensionNameSwiftUI = extensionNameSwiftUI { |         if let extensionNameUIKit = extensionNameUIKit { | ||||||
|             args += [ |             args += [ | ||||||
|                 "--extension-name-swift-ui", |                 "--extension-name-ui-kit", | ||||||
|                 extensionNameSwiftUI |                 extensionNameUIKit | ||||||
|             ] |             ] | ||||||
|         } |         } | ||||||
|          |          | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user