Font
public enum Font
extension Font: CustomStringConvertible
extension Font: RawRepresentable
extension Font: MediaSubtype
extension Font: Hashable
Represents the font
media type. See the
official documentation for details.
You typically use Font
as a MediaType
.
let font = Font.ttf(nil, ["layout": "oat,aat"])
let mediaType = MediaType.font(font) // Creates: font/ttf;layout=oat,aat
You can use standard switch
statement to access font values.
func isSupported(font: Font) -> Bool {
switch font {
case .woff, .woff2: return true
case .ttf(_, let parameters?): return !parameters.isEmpty
default: return false
}
}
isSupported(font: .woff()) // Returns: true
isSupported(font: .ttf(nil, ["layout": "oat,aat"])) // Returns: true
isSupported(font: .ttf()) // Returns: false
See also
MediaType
-
Represents the
collection
subtype.Declaration
Swift
case collection(_: Suffix? = nil, _: Parameters? = nil)
-
Represents the
otf
subtype.Declaration
Swift
case otf(_: Suffix? = nil, _: Parameters? = nil)
-
Represents the
sfnt
subtype.Declaration
Swift
case sfnt(_: Suffix? = nil, _: Parameters? = nil)
-
Represents the
ttf
subtype.Declaration
Swift
case ttf(_: Suffix? = nil, _: Parameters? = nil)
-
Represents the
woff
subtype.Declaration
Swift
case woff(_: Suffix? = nil, _: Parameters? = nil)
-
Represents the
woff2
subtype.Declaration
Swift
case woff2(_: Suffix? = nil, _: Parameters? = nil)
-
Represents a subtype that does not fit in the other cases or is currently not officially defined.
You can use this case to define an arbitrary, unregistered subtype with the given name or to represent a subtype in the non standard tree, e.g. vendor tree or personal tree.
Optionally, you can specify a
Suffix
andParameters
.Declaration
Swift
case other(String, _: Suffix? = nil, _: Parameters? = nil)
-
Declaration
Swift
case anything(_: Suffix? = nil, _: Parameters? = nil)
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public init(rawValue: String)
-
Declaration
Swift
public var rawValue: String { get }
-
Declaration
Swift
public var type: MediaType { get }
-
Declaration
Swift
public static func == (lhs: `Self`, rhs: `Self`) -> Bool
-
Declaration
Swift
public func hash(into hasher: inout Hasher)