提交 8e34b273 编写于 作者: N Nicholas Maccharoli

Initial Implementation

上级 d7798692
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
.DS_Store
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
.build/
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
language: objective-c
osx_image: xcode8.2
xcode_project: UIFontComplete.xcodeproj # path to your xcodeproj folder
xcode_scheme: UIFontComplete
script:
# - xcodebuild -scheme UIFontComplete -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.2' test
- xcodebuild -scheme UIFontComplete -sdk iphonesimulator -destination 'id=E40727B3-41FB-4D6E-B4CB-BFA87109EB12' test
after_success:
- bash <(curl -s https://codecov.io/bash)
MIT License
Copyright (c) 2016 Nicholas Maccharoli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# UIFontComplete
[![Build Status](https://travis-ci.org/Nirma/UIFontComplete.svg?branch=master)](https://travis-ci.org/Nirma/UIFontComplete)
![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.1-orange.svg)
![CodeCov](https://img.shields.io/codecov/c/github/Nirma/UIFontComplete.svg)
[![CocoaPods compatible](https://img.shields.io/cocoapods/v/UIFontComplete.svg)](#cocoapods)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)
Make working with `UIFont` faster and less error-prone
## Usage
This library is simply one extension to `UIFont` and one `Font` `enum` with a case for each standard installed font on iOS.
No more muddling around searching for names of `UIFont` types and no more surprises at runtime if a font name was mistyped.
Instead of the `String` base constructor for `UIFont`:
```swift
let font = UIFont(name: "Arial-BoldItalicMT", size: 12.0)
```
You can now simply start typing the name of the font enum and let code completion help you:
![](http://i.imgur.com/yBYRQVB.gif)
```swift
let font = UIFont(font: .arialBoldItalicMT, size: 12.0)
```
## Installation
#### Carthage
If you use Carthage to manage your dependencies, simply add
UIFontComplete to your `Cartfile`:
```
github "Nirma/UIFontComplete"
```
If you use Carthage to build your dependencies, make sure you have added `UIFontComplete.framework` to the "_Linked Frameworks and Libraries_" section of your target, and have included `UIFontComplete.framework` in your Carthage framework copying build phase.
#### CocoaPods
If you use CocoaPods to manage your dependencies, simply add
UIFontComplete to your `Podfile`:
```
pod 'UIFontComplete'
```
## Requirements
* Xcode 8.0
* Swift 3.0+
## Contribution and Maintenance
Fonts available on iOS are surely subject to possible change,
and when they do the `Font` enum in this library will need to be updated as well.
If you would like to help maintain or improve this library please feel free to do so.
## License
UIFontComplete is free software, and may be redistributed under the terms specified in the [LICENSE] file.
[LICENSE]: /LICENSE
Pod::Spec.new do |s|
s.name = 'UIFontComplete'
s.version = '0.1.0'
s.summary = 'Make working with UIFont faster and less error-prone'
s.description = <<-DESC
Make working with UIFont faster and less error-prone
This mico library is simply just one giant `Font` enum
that can be used in place of raw Strings when choosing a font
type to use.
Use code completion of the enum case to see available fonts,
make runtime crashes due to font name typos near impossible!
DESC
s.homepage = 'https://github.com/Nirma/UIFontComplete'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Nicholas Maccharoli' => 'nmaccharoli@gmail.com' }
s.source = { :git => 'https://github.com/Nirma/UIFontComplete.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.source_files = 'UIFontComplete/*.swift'
end
......@@ -10,6 +10,9 @@
AAE1A29D1E02618D00610C40 /* UIFontComplete.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AAE1A2931E02618D00610C40 /* UIFontComplete.framework */; };
AAE1A2A21E02618D00610C40 /* UIFontCompleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE1A2A11E02618D00610C40 /* UIFontCompleteTests.swift */; };
AAE1A2A41E02618D00610C40 /* UIFontComplete.h in Headers */ = {isa = PBXBuildFile; fileRef = AAE1A2961E02618D00610C40 /* UIFontComplete.h */; settings = {ATTRIBUTES = (Public, ); }; };
AAE1A2AE1E0261B200610C40 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE1A2AD1E0261B200610C40 /* Font.swift */; };
AAE1A2B01E0261F600610C40 /* UIFont+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE1A2AF1E0261F600610C40 /* UIFont+Extension.swift */; };
AAE1A2B31E027E8100610C40 /* CodeGeneration.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE1A2B21E027E8100610C40 /* CodeGeneration.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -29,6 +32,9 @@
AAE1A29C1E02618D00610C40 /* UIFontCompleteTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIFontCompleteTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
AAE1A2A11E02618D00610C40 /* UIFontCompleteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFontCompleteTests.swift; sourceTree = "<group>"; };
AAE1A2A31E02618D00610C40 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AAE1A2AD1E0261B200610C40 /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
AAE1A2AF1E0261F600610C40 /* UIFont+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIFont+Extension.swift"; sourceTree = "<group>"; };
AAE1A2B21E027E8100610C40 /* CodeGeneration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CodeGeneration.swift; path = Util/CodeGeneration.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -71,8 +77,10 @@
AAE1A2951E02618D00610C40 /* UIFontComplete */ = {
isa = PBXGroup;
children = (
AAE1A2961E02618D00610C40 /* UIFontComplete.h */,
AAE1A2971E02618D00610C40 /* Info.plist */,
AAE1A2B61E027F4B00610C40 /* Supporting */,
AAE1A2B51E027F3A00610C40 /* Enums */,
AAE1A2B41E027F1A00610C40 /* Extensions */,
AAE1A2B11E027E5600610C40 /* Util */,
);
path = UIFontComplete;
sourceTree = "<group>";
......@@ -86,6 +94,39 @@
path = UIFontCompleteTests;
sourceTree = "<group>";
};
AAE1A2B11E027E5600610C40 /* Util */ = {
isa = PBXGroup;
children = (
AAE1A2B21E027E8100610C40 /* CodeGeneration.swift */,
);
name = Util;
sourceTree = "<group>";
};
AAE1A2B41E027F1A00610C40 /* Extensions */ = {
isa = PBXGroup;
children = (
AAE1A2AF1E0261F600610C40 /* UIFont+Extension.swift */,
);
name = Extensions;
sourceTree = "<group>";
};
AAE1A2B51E027F3A00610C40 /* Enums */ = {
isa = PBXGroup;
children = (
AAE1A2AD1E0261B200610C40 /* Font.swift */,
);
name = Enums;
sourceTree = "<group>";
};
AAE1A2B61E027F4B00610C40 /* Supporting */ = {
isa = PBXGroup;
children = (
AAE1A2961E02618D00610C40 /* UIFontComplete.h */,
AAE1A2971E02618D00610C40 /* Info.plist */,
);
name = Supporting;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
......@@ -147,11 +188,12 @@
TargetAttributes = {
AAE1A2921E02618D00610C40 = {
CreatedOnToolsVersion = 8.2;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
AAE1A29B1E02618D00610C40 = {
CreatedOnToolsVersion = 8.2;
ProvisioningStyle = Automatic;
ProvisioningStyle = Manual;
};
};
};
......@@ -195,6 +237,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AAE1A2B01E0261F600610C40 /* UIFont+Extension.swift in Sources */,
AAE1A2AE1E0261B200610C40 /* Font.swift in Sources */,
AAE1A2B31E027E8100610C40 /* CodeGeneration.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -258,12 +303,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
......@@ -305,10 +351,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
......@@ -319,6 +366,7 @@
AAE1A2A81E02618D00610C40 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
......@@ -330,6 +378,7 @@
PRODUCT_BUNDLE_IDENTIFIER = fontComplete.UIFontComplete;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
......@@ -337,6 +386,7 @@
AAE1A2A91E02618D00610C40 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
......@@ -355,6 +405,8 @@
AAE1A2AB1E02618D00610C40 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = UIFontCompleteTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = fontComplete.UIFontCompleteTests;
......@@ -366,6 +418,8 @@
AAE1A2AC1E02618D00610C40 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = UIFontCompleteTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = fontComplete.UIFontCompleteTests;
......@@ -393,6 +447,7 @@
AAE1A2A91E02618D00610C40 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AAE1A2AA1E02618D00610C40 /* Build configuration list for PBXNativeTarget "UIFontCompleteTests" */ = {
isa = XCConfigurationList;
......@@ -401,6 +456,7 @@
AAE1A2AC1E02618D00610C40 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
......
......@@ -5,14 +5,50 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAE1A2921E02618D00610C40"
BuildableName = "UIFontComplete.framework"
BlueprintName = "UIFontComplete"
ReferencedContainer = "container:UIFontComplete.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAE1A29B1E02618D00610C40"
BuildableName = "UIFontCompleteTests.xctest"
BlueprintName = "UIFontCompleteTests"
ReferencedContainer = "container:UIFontComplete.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAE1A2921E02618D00610C40"
BuildableName = "UIFontComplete.framework"
BlueprintName = "UIFontComplete"
ReferencedContainer = "container:UIFontComplete.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
......@@ -26,6 +62,15 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAE1A2921E02618D00610C40"
BuildableName = "UIFontComplete.framework"
BlueprintName = "UIFontComplete"
ReferencedContainer = "container:UIFontComplete.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
......@@ -35,6 +80,15 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAE1A2921E02618D00610C40"
BuildableName = "UIFontComplete.framework"
BlueprintName = "UIFontComplete"
ReferencedContainer = "container:UIFontComplete.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
......
......@@ -4,7 +4,7 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>UIFontComplete.xcscheme</key>
<key>UIFontComplete.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
......
//
// Font.swift
// UIFontComplete
//
// Created by Nicholas Maccharoli on 2016/12/15.
//
//
public enum Font: String {
// Font Family: Copperplate
case copperplateLight = "Copperplate-Light"
case copperplate = "Copperplate"
case copperplateBold = "Copperplate-Bold"
// Font Family: Kohinoor Telugu
case kohinoorTeluguRegular = "KohinoorTelugu-Regular"
case kohinoorTeluguMedium = "KohinoorTelugu-Medium"
case kohinoorTeluguLight = "KohinoorTelugu-Light"
// Font Family: Thonburi
case thonburi = "Thonburi"
case thonburiBold = "Thonburi-Bold"
case thonburiLight = "Thonburi-Light"
// Font Family: Courier New
case courierNewPSBoldMT = "CourierNewPS-BoldMT"
case courierNewPSItalicMT = "CourierNewPS-ItalicMT"
case courierNewPSMT = "CourierNewPSMT"
case courierNewPSBoldItalicMT = "CourierNewPS-BoldItalicMT"
// Font Family: Gill Sans
case gillSansItalic = "GillSans-Italic"
case gillSansBold = "GillSans-Bold"
case gillSansBoldItalic = "GillSans-BoldItalic"
case gillSansLightItalic = "GillSans-LightItalic"
case gillSans = "GillSans"
case gillSansLight = "GillSans-Light"
case gillSansSemiBold = "GillSans-SemiBold"
case gillSansSemiBoldItalic = "GillSans-SemiBoldItalic"
case gillSansUltraBold = "GillSans-UltraBold"
// Font Family: Apple SD Gothic Neo
case appleSDGothicNeoBold = "AppleSDGothicNeo-Bold"
case appleSDGothicNeoUltraLight = "AppleSDGothicNeo-UltraLight"
case appleSDGothicNeoThin = "AppleSDGothicNeo-Thin"
case appleSDGothicNeoRegular = "AppleSDGothicNeo-Regular"
case appleSDGothicNeoLight = "AppleSDGothicNeo-Light"
case appleSDGothicNeoMedium = "AppleSDGothicNeo-Medium"
case appleSDGothicNeoSemiBold = "AppleSDGothicNeo-SemiBold"
// Font Family: Marker Felt
case markerFeltThin = "MarkerFelt-Thin"
case markerFeltWide = "MarkerFelt-Wide"
// Font Family: Avenir Next Condensed
case avenirNextCondensedBoldItalic = "AvenirNextCondensed-BoldItalic"
case avenirNextCondensedHeavy = "AvenirNextCondensed-Heavy"
case avenirNextCondensedMedium = "AvenirNextCondensed-Medium"
case avenirNextCondensedRegular = "AvenirNextCondensed-Regular"
case avenirNextCondensedHeavyItalic = "AvenirNextCondensed-HeavyItalic"
case avenirNextCondensedMediumItalic = "AvenirNextCondensed-MediumItalic"
case avenirNextCondensedItalic = "AvenirNextCondensed-Italic"
case avenirNextCondensedUltraLightItalic = "AvenirNextCondensed-UltraLightItalic"
case avenirNextCondensedUltraLight = "AvenirNextCondensed-UltraLight"
case avenirNextCondensedDemiBold = "AvenirNextCondensed-DemiBold"
case avenirNextCondensedBold = "AvenirNextCondensed-Bold"
case avenirNextCondensedDemiBoldItalic = "AvenirNextCondensed-DemiBoldItalic"
// Font Family: Tamil Sangam MN
case tamilSangamMN = "TamilSangamMN"
case tamilSangamMNBold = "TamilSangamMN-Bold"
// Font Family: Helvetica Neue
case helveticaNeueItalic = "HelveticaNeue-Italic"
case helveticaNeueBold = "HelveticaNeue-Bold"
case helveticaNeueUltraLight = "HelveticaNeue-UltraLight"
case helveticaNeueCondensedBlack = "HelveticaNeue-CondensedBlack"
case helveticaNeueBoldItalic = "HelveticaNeue-BoldItalic"
case helveticaNeueCondensedBold = "HelveticaNeue-CondensedBold"
case helveticaNeueMedium = "HelveticaNeue-Medium"
case helveticaNeueLight = "HelveticaNeue-Light"
case helveticaNeueThin = "HelveticaNeue-Thin"
case helveticaNeueThinItalic = "HelveticaNeue-ThinItalic"
case helveticaNeueLightItalic = "HelveticaNeue-LightItalic"
case helveticaNeueUltraLightItalic = "HelveticaNeue-UltraLightItalic"
case helveticaNeueMediumItalic = "HelveticaNeue-MediumItalic"
case helveticaNeue = "HelveticaNeue"
// Font Family: Gurmukhi MN
case gurmukhiMNBold = "GurmukhiMN-Bold"
case gurmukhiMN = "GurmukhiMN"
// Font Family: Times New Roman
case timesNewRomanPSMT = "TimesNewRomanPSMT"
case timesNewRomanPSBoldItalicMT = "TimesNewRomanPS-BoldItalicMT"
case timesNewRomanPSItalicMT = "TimesNewRomanPS-ItalicMT"
case timesNewRomanPSBoldMT = "TimesNewRomanPS-BoldMT"
// Font Family: Georgia
case georgiaBoldItalic = "Georgia-BoldItalic"
case georgia = "Georgia"
case georgiaItalic = "Georgia-Italic"
case georgiaBold = "Georgia-Bold"
// Font Family: Apple Color Emoji
case appleColorEmoji = "AppleColorEmoji"
// Font Family: Arial Rounded MT Bold
case arialRoundedMTBold = "ArialRoundedMTBold"
// Font Family: Kailasa
case kailasaBold = "Kailasa-Bold"
case kailasa = "Kailasa"
// Font Family: Kohinoor Devanagari
case kohinoorDevanagariLight = "KohinoorDevanagari-Light"
case kohinoorDevanagariRegular = "KohinoorDevanagari-Regular"
case kohinoorDevanagariSemibold = "KohinoorDevanagari-Semibold"
// Font Family: Kohinoor Bangla
case kohinoorBanglaSemibold = "KohinoorBangla-Semibold"
case kohinoorBanglaRegular = "KohinoorBangla-Regular"
case kohinoorBanglaLight = "KohinoorBangla-Light"
// Font Family: Chalkboard SE
case chalkboardSEBold = "ChalkboardSE-Bold"
case chalkboardSELight = "ChalkboardSE-Light"
case chalkboardSERegular = "ChalkboardSE-Regular"
// Font Family: Sinhala Sangam MN
case sinhalaSangamMNBold = "SinhalaSangamMN-Bold"
case sinhalaSangamMN = "SinhalaSangamMN"
// Font Family: PingFang TC
case pingFangTCMedium = "PingFangTC-Medium"
case pingFangTCRegular = "PingFangTC-Regular"
case pingFangTCLight = "PingFangTC-Light"
case pingFangTCUltralight = "PingFangTC-Ultralight"
case pingFangTCSemibold = "PingFangTC-Semibold"
case pingFangTCThin = "PingFangTC-Thin"
// Font Family: Gujarati Sangam MN
case gujaratiSangamMNBold = "GujaratiSangamMN-Bold"
case gujaratiSangamMN = "GujaratiSangamMN"
// Font Family: Damascus
case damascusLight = "DamascusLight"
case damascusBold = "DamascusBold"
case damascusSemiBold = "DamascusSemiBold"
case damascusMedium = "DamascusMedium"
case damascus = "Damascus"
// Font Family: Noteworthy
case noteworthyLight = "Noteworthy-Light"
case noteworthyBold = "Noteworthy-Bold"
// Font Family: Geeza Pro
case geezaPro = "GeezaPro"
case geezaProBold = "GeezaPro-Bold"
// Font Family: Avenir
case avenirMedium = "Avenir-Medium"
case avenirHeavyOblique = "Avenir-HeavyOblique"
case avenirBook = "Avenir-Book"
case avenirLight = "Avenir-Light"
case avenirRoman = "Avenir-Roman"
case avenirBookOblique = "Avenir-BookOblique"
case avenirMediumOblique = "Avenir-MediumOblique"
case avenirBlack = "Avenir-Black"
case avenirBlackOblique = "Avenir-BlackOblique"
case avenirHeavy = "Avenir-Heavy"
case avenirLightOblique = "Avenir-LightOblique"
case avenirOblique = "Avenir-Oblique"
// Font Family: Academy Engraved LET
case academyEngravedLetPlain = "AcademyEngravedLetPlain"
// Font Family: Mishafi
case diwanMishafi = "DiwanMishafi"
// Font Family: Futura
case futuraCondensedMedium = "Futura-CondensedMedium"
case futuraCondensedExtraBold = "Futura-CondensedExtraBold"
case futuraMedium = "Futura-Medium"
case futuraMediumItalic = "Futura-MediumItalic"
case futuraBold = "Futura-Bold"
// Font Family: Farah
case farah = "Farah"
// Font Family: Kannada Sangam MN
case kannadaSangamMN = "KannadaSangamMN"
case kannadaSangamMNBold = "KannadaSangamMN-Bold"
// Font Family: Arial Hebrew
case arialHebrewBold = "ArialHebrew-Bold"
case arialHebrewLight = "ArialHebrew-Light"
case arialHebrew = "ArialHebrew"
// Font Family: Arial
case arialMT = "ArialMT"
case arialBoldItalicMT = "Arial-BoldItalicMT"
case arialBoldMT = "Arial-BoldMT"
case arialItalicMT = "Arial-ItalicMT"
// Font Family: Party LET
case partyLetPlain = "PartyLetPlain"
// Font Family: Chalkduster
case chalkduster = "Chalkduster"
// Font Family: Hoefler Text
case hoeflerTextItalic = "HoeflerText-Italic"
case hoeflerTextRegular = "HoeflerText-Regular"
case hoeflerTextBlack = "HoeflerText-Black"
case hoeflerTextBlackItalic = "HoeflerText-BlackItalic"
// Font Family: Optima
case optimaRegular = "Optima-Regular"
case optimaExtraBlack = "Optima-ExtraBlack"
case optimaBoldItalic = "Optima-BoldItalic"
case optimaItalic = "Optima-Italic"
case optimaBold = "Optima-Bold"
// Font Family: Palatino
case palatinoBold = "Palatino-Bold"
case palatinoRoman = "Palatino-Roman"
case palatinoBoldItalic = "Palatino-BoldItalic"
case palatinoItalic = "Palatino-Italic"
// Font Family: Lao Sangam MN
case laoSangamMN = "LaoSangamMN"
// Font Family: Malayalam Sangam MN
case malayalamSangamMNBold = "MalayalamSangamMN-Bold"
case malayalamSangamMN = "MalayalamSangamMN"
// Font Family: Al Nile
case alNileBold = "AlNile-Bold"
case alNile = "AlNile"
// Font Family: Bradley Hand
case bradleyHandITCTTBold = "BradleyHandITCTT-Bold"
// Font Family: PingFang HK
case pingFangHKUltralight = "PingFangHK-Ultralight"
case pingFangHKSemibold = "PingFangHK-Semibold"
case pingFangHKThin = "PingFangHK-Thin"
case pingFangHKLight = "PingFangHK-Light"
case pingFangHKRegular = "PingFangHK-Regular"
case pingFangHKMedium = "PingFangHK-Medium"
// Font Family: Trebuchet MS
case trebuchetBoldItalic = "Trebuchet-BoldItalic"
case trebuchetMS = "TrebuchetMS"
case trebuchetMSBold = "TrebuchetMS-Bold"
case trebuchetMSItalic = "TrebuchetMS-Italic"
// Font Family: Helvetica
case helveticaBold = "Helvetica-Bold"
case helvetica = "Helvetica"
case helveticaLightOblique = "Helvetica-LightOblique"
case helveticaOblique = "Helvetica-Oblique"
case helveticaBoldOblique = "Helvetica-BoldOblique"
case helveticaLight = "Helvetica-Light"
// Font Family: Courier
case courierBoldOblique = "Courier-BoldOblique"
case courier = "Courier"
case courierBold = "Courier-Bold"
case courierOblique = "Courier-Oblique"
// Font Family: Cochin
case cochinBold = "Cochin-Bold"
case cochin = "Cochin"
case cochinItalic = "Cochin-Italic"
case cochinBoldItalic = "Cochin-BoldItalic"
// Font Family: Hiragino Mincho ProN
case hiraMinProNW6 = "HiraMinProN-W6"
case hiraMinProNW3 = "HiraMinProN-W3"
// Font Family: Devanagari Sangam MN
case devanagariSangamMN = "DevanagariSangamMN"
case devanagariSangamMNBold = "DevanagariSangamMN-Bold"
// Font Family: Oriya Sangam MN
case oriyaSangamMN = "OriyaSangamMN"
case oriyaSangamMNBold = "OriyaSangamMN-Bold"
// Font Family: Snell Roundhand
case snellRoundhandBold = "SnellRoundhand-Bold"
case snellRoundhand = "SnellRoundhand"
case snellRoundhandBlack = "SnellRoundhand-Black"
// Font Family: Zapf Dingbats
case zapfDingbatsITC = "ZapfDingbatsITC"
// Font Family: Bodoni 72
case bodoniSvtyTwoITCTTBold = "BodoniSvtyTwoITCTT-Bold"
case bodoniSvtyTwoITCTTBook = "BodoniSvtyTwoITCTT-Book"
case bodoniSvtyTwoITCTTBookIta = "BodoniSvtyTwoITCTT-BookIta"
// Font Family: Verdana
case verdanaItalic = "Verdana-Italic"
case verdanaBoldItalic = "Verdana-BoldItalic"
case verdana = "Verdana"
case verdanaBold = "Verdana-Bold"
// Font Family: American Typewriter
case americanTypewriterCondensedLight = "AmericanTypewriter-CondensedLight"
case americanTypewriter = "AmericanTypewriter"
case americanTypewriterCondensedBold = "AmericanTypewriter-CondensedBold"
case americanTypewriterLight = "AmericanTypewriter-Light"
case americanTypewriterSemibold = "AmericanTypewriter-Semibold"
case americanTypewriterBold = "AmericanTypewriter-Bold"
case americanTypewriterCondensed = "AmericanTypewriter-Condensed"
// Font Family: Avenir Next
case avenirNextUltraLight = "AvenirNext-UltraLight"
case avenirNextUltraLightItalic = "AvenirNext-UltraLightItalic"
case avenirNextBold = "AvenirNext-Bold"
case avenirNextBoldItalic = "AvenirNext-BoldItalic"
case avenirNextDemiBold = "AvenirNext-DemiBold"
case avenirNextDemiBoldItalic = "AvenirNext-DemiBoldItalic"
case avenirNextMedium = "AvenirNext-Medium"
case avenirNextHeavyItalic = "AvenirNext-HeavyItalic"
case avenirNextHeavy = "AvenirNext-Heavy"
case avenirNextItalic = "AvenirNext-Italic"
case avenirNextRegular = "AvenirNext-Regular"
case avenirNextMediumItalic = "AvenirNext-MediumItalic"
// Font Family: Baskerville
case baskervilleItalic = "Baskerville-Italic"
case baskervilleSemiBold = "Baskerville-SemiBold"
case baskervilleBoldItalic = "Baskerville-BoldItalic"
case baskervilleSemiBoldItalic = "Baskerville-SemiBoldItalic"
case baskervilleBold = "Baskerville-Bold"
case baskerville = "Baskerville"
// Font Family: Khmer Sangam MN
case khmerSangamMN = "KhmerSangamMN"
// Font Family: Didot
case didotItalic = "Didot-Italic"
case didotBold = "Didot-Bold"
case didot = "Didot"
// Font Family: Savoye LET
case savoyeLetPlain = "SavoyeLetPlain"
// Font Family: Bodoni Ornaments
case bodoniOrnamentsITCTT = "BodoniOrnamentsITCTT"
// Font Family: Symbol
case symbol = "Symbol"
// Font Family: Menlo
case menloItalic = "Menlo-Italic"
case menloBold = "Menlo-Bold"
case menloRegular = "Menlo-Regular"
case menloBoldItalic = "Menlo-BoldItalic"
// Font Family: Bodoni 72 Smallcaps
case bodoniSvtyTwoSCITCTTBook = "BodoniSvtyTwoSCITCTT-Book"
// Font Family: Papyrus
case papyrus = "Papyrus"
case papyrusCondensed = "Papyrus-Condensed"
// Font Family: Hiragino Sans
case hiraginoSansW3 = "HiraginoSans-W3"
case hiraginoSansW6 = "HiraginoSans-W6"
// Font Family: PingFang SC
case pingFangSCUltralight = "PingFangSC-Ultralight"
case pingFangSCRegular = "PingFangSC-Regular"
case pingFangSCSemibold = "PingFangSC-Semibold"
case pingFangSCThin = "PingFangSC-Thin"
case pingFangSCLight = "PingFangSC-Light"
case pingFangSCMedium = "PingFangSC-Medium"
// Font Family: Myanmar Sangam MN
case myanmarSangamMNBold = "MyanmarSangamMN-Bold"
case myanmarSangamMN = "MyanmarSangamMN"
// Font Family: Euphemia UCAS
case euphemiaUCASItalic = "EuphemiaUCAS-Italic"
case euphemiaUCAS = "EuphemiaUCAS"
case euphemiaUCASBold = "EuphemiaUCAS-Bold"
// Font Family: Zapfino
case zapfino = "Zapfino"
// Font Family: Bodoni 72 Oldstyle
case bodoniSvtyTwoOSITCTTBook = "BodoniSvtyTwoOSITCTT-Book"
case bodoniSvtyTwoOSITCTTBold = "BodoniSvtyTwoOSITCTT-Bold"
case bodoniSvtyTwoOSITCTTBookIt = "BodoniSvtyTwoOSITCTT-BookIt"
}
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
......
//
// UIFont+Extension.swift
// UIFontComplete
//
// Created by Nicholas Maccharoli on 2016/12/15.
//
//
import Foundation
import UIKit
extension UIFont {
/// Create a UIFont object with a `Font` enum
public convenience init?(font: Font, size: CGFloat) {
let fontIdentifier: String = font.rawValue
self.init(name: fontIdentifier, size: size)
}
}
//
// CodeGeneration.swift
// UIFontComplete
//
// Created by Nicholas Maccharoli on 2016/12/15.
//
//
import Foundation
import UIKit
extension String {
fileprivate var enumified: String {
let hyphenless = self.replacingOccurrences(of: "-", with: "")
return String(hyphenless.characters.first!).lowercased() + String(hyphenless.characters.dropFirst())
}
}
enum FontCase {
case family(String)
case name(String, String)
}
func createEnumNamesAndCases() -> [FontCase] {
var fontData = [FontCase]()
for family in UIFont.familyNames where UIFont.fontNames(forFamilyName: family).count > 0 {
fontData += [FontCase.family(family)]
for font in UIFont.fontNames(forFamilyName: family) {
fontData += [FontCase.name(font.enumified, font)]
}
}
return fontData
}
func createEnum(with fonts: [FontCase], spacing: Int = 4, familyComment: Bool = true) -> String {
var outputString = ""
let indent = (0..<spacing).map({ _ in " "}).joined()
for fontItem in fonts {
switch fontItem {
case .family(let familyName) where familyComment:
outputString += "\n\n" + indent + "// Font Family: " + familyName
case .name(let enumCaseName, let fontString):
outputString += "\n" + indent + "case " + enumCaseName + " = \"\(fontString)\""
default:
break
}
}
return "public enum Font: String {" + outputString + "\n}"
}
func makeTestCases(with fonts: [FontCase]) -> String {
func makeTestCase(fontInfo: FontCase) -> String? {
switch fontInfo {
case .name(let enumName, let fontString):
return "func testFont" + enumName.capitalized + "() {\n" +
" XCTAssert(UIFont(font: ." + enumName + ", size: 12.0) != nil," +
" \"Font \\\"\(fontString)\\\" can not be found.\")" +
"\n}"
default:
return nil
}
}
let results = fonts.flatMap { makeTestCase(fontInfo: $0) }
return results.joined(separator: "\n\n")
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册