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