diff --git a/.gitignore b/.gitignore index 7fa6c8a..9bf61d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +# macOS .DS_Store -/SwiftRichString/SwiftRichString.xcodeproj/xcuserdata/danielemargutti.xcuserdatad -/SwiftRichString/SwiftRichString.xcodeproj/project.xcworkspace/xcuserdata/danielemargutti.xcuserdatad -/SwiftRichString.xcworkspace/xcuserdata/danielemargutti.xcuserdatad + +# Xcode +xcuserdata *.xcuserstate +*.xctimeline diff --git a/Configs/SwiftRichString.plist b/Configs/SwiftRichString.plist index 7d91fd9..f490ded 100644 --- a/Configs/SwiftRichString.plist +++ b/Configs/SwiftRichString.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 2.0.2 CFBundleSignature ???? CFBundleVersion diff --git a/ExampleiOS/AppDelegate.swift b/ExampleiOS/AppDelegate.swift index 092f25f..83ea536 100644 --- a/ExampleiOS/AppDelegate.swift +++ b/ExampleiOS/AppDelegate.swift @@ -16,20 +16,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. - - let bold = Style { - $0.font = SystemFonts.Helvetica_Bold.font(size: 20) - } - let normal = Style { - $0.font = SystemFonts.Helvetica_Light.font(size: 15) - } - let red = normal.byAdding { - $0.color = UIColor.red - $0.traitVariants = [TraitVariant.bold,TraitVariant.tightLineSpacing] - } - - Styles.register("MyStyle", style: StyleGroup(base: normal, ["bold" : bold, "red" : red])) - return true } diff --git a/ExampleiOS/ViewController.swift b/ExampleiOS/ViewController.swift index 87ee7df..1484b94 100644 --- a/ExampleiOS/ViewController.swift +++ b/ExampleiOS/ViewController.swift @@ -14,8 +14,6 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - - self.label?.styledText = "Hello MERDA" } override func didReceiveMemoryWarning() { diff --git a/README.md b/README.md index 8898770..8fbe082 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ Other info: ### Versions -- **SwiftRichString 2.x branch (current)**. The latest version is [2.0.1](https://github.com/malcommac/SwiftRichString/releases/tag/2.0.1). +- **SwiftRichString 2.x branch (current)**. The latest version is [2.0.2](https://github.com/malcommac/SwiftRichString/releases/tag/2.0.2). - **SwiftRichString 1.x branch (supported)**. Use [1.1.0 tag](https://github.com/malcommac/SwiftRichString/releases/tag/1.1.0). Its compatible with Swift 4.x. - **Swift 3.x (no longer mantained)**. Use [0.9.1 release](https://github.com/malcommac/SwiftRichString/releases/tag/0.9.10). @@ -487,6 +487,7 @@ The following properties are available: | font | `FontConvertible` | font used in text | | color | `ColorConvertible` | foreground color of the text | | backColor | `ColorConvertible` | background color of the text | +| shadow | `NSShadow` | shadow effect of the text | | underline | `(NSUnderlineStyle?,ColorConvertible?)` | underline style and color (if color is nil foreground is used) | | strikethrough | `(NSUnderlineStyle?,ColorConvertible?)` | strikethrough style and color (if color is nil foreground is used) | | baselineOffset | `Float` | character’s offset from the baseline, in point | diff --git a/Sources/SwiftRichString/Attributes/FontInfo.swift b/Sources/SwiftRichString/Attributes/FontData.swift similarity index 69% rename from Sources/SwiftRichString/Attributes/FontInfo.swift rename to Sources/SwiftRichString/Attributes/FontData.swift index f73bfce..e196f77 100644 --- a/Sources/SwiftRichString/Attributes/FontInfo.swift +++ b/Sources/SwiftRichString/Attributes/FontData.swift @@ -21,13 +21,15 @@ internal let WATCHOS_SYSTEMFONT_SIZE: CGFloat = 12.0 /// User don't interact with this object directly but via `Style`'s properties. /// Using the `attributes` property this object return a valid instance of the attributes to describe /// required behaviour. -internal struct FontInfo { +public class FontData { + + private static var DefaultFont = Font.systemFont(ofSize: 12.0) /// Font object - var font: FontConvertible { didSet { self.style?.invalidateCache() } } + var font: FontConvertible? { didSet { self.style?.invalidateCache() } } /// Size of the font - var size: CGFloat { didSet { self.style?.invalidateCache() } } + var size: CGFloat? { didSet { self.style?.invalidateCache() } } #if os(OSX) || os(iOS) || os(tvOS) @@ -75,7 +77,9 @@ internal struct FontInfo { /// Initialize a new `FontInfo` instance with system font with system font size. init() { - #if os(tvOS) + self.font = nil + self.size = nil + /*#if os(tvOS) self.font = Font.systemFont(ofSize: TVOS_SYSTEMFONT_SIZE) self.size = TVOS_SYSTEMFONT_SIZE #elseif os(watchOS) @@ -84,7 +88,12 @@ internal struct FontInfo { #else self.font = Font.systemFont(ofSize: Font.systemFontSize) self.size = Font.systemFontSize - #endif + #endif*/ + } + + /// Has font explicit value for font name or size + var explicitFont: Bool { + return (self.font != nil || self.size != nil) } /// Return a font with all attributes set. @@ -92,10 +101,50 @@ internal struct FontInfo { /// - Parameter size: ignored. It will be overriden by `fontSize` property. /// - Returns: instance of the font var attributes: [NSAttributedStringKey:Any] { - var finalAttributes: [NSAttributedStringKey:Any] = [:] + guard !self.explicitFont else { + return [:] + } + return attributes(currentFont: self.font, size: self.size) + } + + /// Apply font attributes to the selected range. + /// It's used to support ineriths from current font of an attributed string. + /// Note: this method does nothing if a fixed font is set because the entire font attributes are replaced + /// by default's `.attributes` of the Style. + /// + /// - Parameters: + /// - source: source of the attributed string. + /// - range: range of application, `nil` means the entire string. + internal func addAttributes(to source: AttributedString, range: NSRange?) { + // This method does nothing if a fixed value for font attributes is set. + // This becuause font attributes will be set along with the remaining attributes from `.attributes` dictionary. + guard self.explicitFont else { + return + } + /// Enumerate fonts in string and attach the attributes + let scanRange = (range ?? NSMakeRange(0, source.length)) + source.enumerateAttribute(.font, in: scanRange, options: []) { (fontValue, fontRange, shouldStop) in + let currentFont = ((fontValue ?? FontData.DefaultFont) as? FontConvertible) + let currentSize = (fontValue as? Font)?.pointSize + let fontAttributes = self.attributes(currentFont: currentFont, size: currentSize) + source.addAttributes(fontAttributes, range: fontRange) + } + } + + /// Return the attributes by sending an already set font/size. + /// If no fixed font/size is already set on self the current font/size is used instead, along with the additional font attributes. + /// + /// - Parameters: + /// - currentFont: current font. + /// - currentSize: current font size. + /// - Returns: attributes + public func attributes(currentFont: FontConvertible?, size currentSize: CGFloat?) -> [NSAttributedStringKey:Any] { + var finalAttributes: [NSAttributedStringKey:Any] = [:] + // generate an initial font from passed FontConvertible instance - var finalFont = self.font.font(size: self.size) + guard let size = (self.size ?? currentSize) else { return [:] } + guard var finalFont = (self.font ?? currentFont)?.font(size: size) else { return [:] } // compose the attributes #if os(iOS) || os(tvOS) || os(OSX) @@ -113,7 +162,6 @@ internal struct FontInfo { finalFont = finalFont.withAttributes(attributes) - if let traitVariants = self.traitVariants { // manage emphasis let descriptor = finalFont.fontDescriptor let existingTraits = descriptor.symbolicTraits diff --git a/Sources/SwiftRichString/Extensions/UIKit+Extras.swift b/Sources/SwiftRichString/Extensions/UIKit+Extras.swift index 3a2735c..4548b23 100644 --- a/Sources/SwiftRichString/Extensions/UIKit+Extras.swift +++ b/Sources/SwiftRichString/Extensions/UIKit+Extras.swift @@ -163,3 +163,14 @@ extension UITextView { } #endif + +//MARK: - compactMap for Swift 4.0 (not necessary > 4.0) + +#if swift(>=4.1) +#else +extension Collection { + func compactMap(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] { + return try flatMap(transform) + } +} +#endif diff --git a/Sources/SwiftRichString/Style/Style.swift b/Sources/SwiftRichString/Style/Style.swift index 14869c7..c35c2ed 100644 --- a/Sources/SwiftRichString/Style/Style.swift +++ b/Sources/SwiftRichString/Style/Style.swift @@ -46,7 +46,7 @@ public class Style: StyleProtocol { /// Contains font description and size along with all other additional /// attributes to render the text. You should not need to modify this object; /// configurable attributes are exposed at `Style` level. - private var fontInfo: FontInfo = FontInfo() + public var fontData: FontData? = FontData() /// Attributes defined by the style. This is the dictionary modified when you /// set a style attributed. @@ -59,27 +59,32 @@ public class Style: StyleProtocol { //MARK: - PROPERTIES /// Alter the size of the currently set font to the specified value (expressed in point) - public var size: CGFloat { + /// **Note**: in order to be used you must also set the `.font` attribute of the style. + public var size: CGFloat? { set { - self.fontInfo.size = newValue + self.fontData?.size = newValue self.invalidateCache() } - get { return self.fontInfo.size } + get { + return self.fontData?.size + } } /// Set the font of the style. /// You can pass any `FontConvertible` conform object, it will be transformed to a valid `UIFont`/`NSFont`` /// and used by the style itself. Both `String`, `SystemFonts` and `UIFont`/`NSFont` are conform to this protocol yet /// so you are able to pass a valid font as a string, from predefined list or directly as an instance. - public var font: FontConvertible { + public var font: FontConvertible? { set { - self.fontInfo.font = newValue + self.fontData?.font = newValue if let f = newValue as? Font { - self.fontInfo.size = f.pointSize + self.fontData?.size = f.pointSize } self.invalidateCache() } - get { return self.fontInfo.font } + get { + return self.fontData?.font + } } /// Set the text color of the style. @@ -113,6 +118,29 @@ public class Style: StyleProtocol { } } + /// Define stroke attributes + /// Value must be a tuple which defines the color of the line and the width. + /// + /// If `color` it is not defined it is assumed to be the same as the value of color; + /// otherwise, it describes the outline color. + /// + /// The `width` value represents the amount to change the stroke width and is specified as a percentage + /// of the font point size. Specify 0 (the default) for no additional changes. + /// Specify positive values to change the stroke width alone. + /// Specify negative values to stroke and fill the text. For example, a typical value for + /// outlined text would be -3.0. + public var stroke: (color: ColorConvertible?, width: Float?)? { + set { + self.set(attribute: newValue?.color?.color, forKey: .strokeColor) + self.set(attribute: NSNumber.from(float: newValue?.width), forKey: .strokeWidth) + } + get { + let color: Color? = self.get(attributeForKey: .strokeColor) + let width: NSNumber? = self.get(attributeForKey: .strokeWidth) + return (color,width?.floatValue) + } + } + /// This value indicates whether the text has a line through it. /// Value must be a tuple which define the style of the line (as `NSUnderlineStyle`) /// and the optional color of the line (if `nil`, foreground color is used instead). @@ -301,6 +329,20 @@ public class Style: StyleProtocol { } } + #if os(iOS) || os(tvOS) || os(macOS) + + /// The value of this attribute is an `NSShadow` object. The default value of this property is nil. + public var shadow: NSShadow? { + set { + self.set(attribute: newValue, forKey: .shadow) + } + get { + return self.get(attributeForKey: .shadow) + } + } + + #endif + #if os(iOS) || os(tvOS) || os(watchOS) /// Enable spoken of all punctuation in the text. @@ -380,55 +422,70 @@ public class Style: StyleProtocol { #endif + /// The value of this attribute is an NSURL object (preferred) or an NSString object. + /// The default value of this property is nil, indicating no link. + public var linkURL: URL? { + set { self.set(attribute: newValue, forKey: .link) } + get { return self.get(attributeForKey: .link) } + } + #if os(OSX) || os(iOS) || os(tvOS) /// Configuration for the number case, also known as "figure style". + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var numberCase: NumberCase? { - set { self.fontInfo.numberCase = newValue } - get { return self.fontInfo.numberCase } + set { self.fontData?.numberCase = newValue } + get { return self.fontData?.numberCase } } /// Configuration for number spacing, also known as "figure spacing". + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var numberSpacing: NumberSpacing? { - set { self.fontInfo.numberSpacing = newValue } - get { return self.fontInfo.numberSpacing } + set { self.fontData?.numberSpacing = newValue } + get { return self.fontData?.numberSpacing } } /// Configuration for displyaing a fraction. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var fractions: Fractions? { - set { self.fontInfo.fractions = newValue } - get { return self.fontInfo.fractions } + set { self.fontData?.fractions = newValue } + get { return self.fontData?.fractions } } /// Superscript (superior) glpyh variants are used, as in footnotes¹. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var superscript: Bool? { - set { self.fontInfo.superscript = newValue } - get { return self.fontInfo.superscript } + set { self.fontData?.superscript = newValue } + get { return self.fontData?.superscript } } /// Subscript (inferior) glyph variants are used: vₑ. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var `subscript`: Bool? { - set { self.fontInfo.subscript = newValue } - get { return self.fontInfo.subscript } + set { self.fontData?.subscript = newValue } + get { return self.fontData?.subscript } } /// Ordinal glyph variants are used, as in the common typesetting of 4th. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var ordinals: Bool? { - set { self.fontInfo.ordinals = newValue } - get { return self.fontInfo.ordinals } + set { self.fontData?.ordinals = newValue } + get { return self.fontData?.ordinals } } /// Scientific inferior glyph variants are used: H₂O + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var scientificInferiors: Bool? { - set { self.fontInfo.scientificInferiors = newValue } - get { return self.fontInfo.scientificInferiors } + set { self.fontData?.scientificInferiors = newValue } + get { return self.fontData?.scientificInferiors } } /// Configure small caps behavior. /// `fromUppercase` and `fromLowercase` can be combined: they are not mutually exclusive. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var smallCaps: Set { - set { self.fontInfo.smallCaps = newValue } - get { return self.fontInfo.smallCaps } + set { self.fontData?.smallCaps = newValue } + get { return self.fontData?.smallCaps ?? Set() } } /// Different stylistic alternates available for customizing a font. @@ -438,28 +495,32 @@ public class Style: StyleProtocol { /// /// For example, in Apple's San Francisco font, turn on alternate set "six" to /// enable high-legibility alternates for ambiguous characters like: 0lI164. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var stylisticAlternates: StylisticAlternates { - set { self.fontInfo.stylisticAlternates = newValue } - get { return self.fontInfo.stylisticAlternates } + set { self.fontData?.stylisticAlternates = newValue } + get { return self.fontData?.stylisticAlternates ?? StylisticAlternates() } } /// Different contextual alternates available for customizing a font. /// Note: Not all fonts support all (or any) of these options. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var contextualAlternates: ContextualAlternates { - set { self.fontInfo.contextualAlternates = newValue } - get { return self.fontInfo.contextualAlternates } + set { self.fontData?.contextualAlternates = newValue } + get { return self.fontData?.contextualAlternates ?? ContextualAlternates() } } /// Tracking to apply. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var kerning: Kerning? { - set { self.fontInfo.kerning = newValue } - get { return self.fontInfo.kerning } + set { self.fontData?.kerning = newValue } + get { return self.fontData?.kerning } } /// Describe trait variants to apply to the font. + /// **Note**: in order to be used you must also set the `.font`/`.size` attribute of the style. public var traitVariants: TraitVariant? { - set { self.fontInfo.traitVariants = newValue } - get { return self.fontInfo.traitVariants } + set { self.fontData?.traitVariants = newValue } + get { return self.fontData?.traitVariants } } #endif @@ -470,14 +531,14 @@ public class Style: StyleProtocol { /// /// - Parameter handler: configuration handler callback. public init(_ handler: StyleInitHandler? = nil) { - self.fontInfo.style = self - #if os(tvOS) + self.fontData?.style = self + /*#if os(tvOS) self.set(attribute: Font.systemFont(ofSize: TVOS_SYSTEMFONT_SIZE), forKey: .font) #elseif os(watchOS) self.set(attribute: Font.systemFont(ofSize: WATCHOS_SYSTEMFONT_SIZE), forKey: .font) #else self.set(attribute: Font.systemFont(ofSize: Font.systemFontSize), forKey: .font) - #endif + #endif*/ handler?(self) } @@ -486,10 +547,10 @@ public class Style: StyleProtocol { /// /// - Parameter dictionary: dictionary to set public init(dictionary: [NSAttributedStringKey: Any]?) { - self.fontInfo.style = self + self.fontData?.style = self if let font = dictionary?[.font] as? Font { - self.fontInfo.font = font - self.fontInfo.size = font.pointSize + self.fontData?.font = font + self.fontData?.size = font.pointSize } self.innerAttributes = (dictionary ?? [:]) } @@ -498,9 +559,9 @@ public class Style: StyleProtocol { /// /// - Parameter style: style to clone public init(style: Style) { - self.fontInfo.style = self + self.fontData?.style = self self.innerAttributes = style.innerAttributes - self.fontInfo = style.fontInfo + self.fontData = style.fontData } //MARK: - INTERNAL METHODS @@ -541,7 +602,8 @@ public class Style: StyleProtocol { } // generate font from `fontInfo` attributes collection, then merge it with the inner attributes of the // string to generate a single attributes dictionary for `NSAttributedString`. - self.cachedAttributes = self.innerAttributes.merging(self.fontInfo.attributes) { (_, new) in return new } + let fontAttributes = self.fontData?.attributes ?? [:] + self.cachedAttributes = self.innerAttributes.merging(fontAttributes) { (_, new) in return new } return self.cachedAttributes! } diff --git a/Sources/SwiftRichString/Style/StyleGroup.swift b/Sources/SwiftRichString/Style/StyleGroup.swift index 8926d44..fb7e008 100644 --- a/Sources/SwiftRichString/Style/StyleGroup.swift +++ b/Sources/SwiftRichString/Style/StyleGroup.swift @@ -38,6 +38,9 @@ import UIKit /// `StyleGroup` is a container for named `Style` instances. /// You need of it to render a text using html-style tags. public class StyleGroup: StyleProtocol { + + /// Does not return anything for groups. + public var fontData: FontData? = nil /// TagAttribute represent a single tag in a source string after the text is parsed. private class TagAttribute { @@ -210,9 +213,9 @@ public class StyleGroup: StyleProtocol { } } - func removeTag(index: Int) { + func removeTag(index: Int, with str: String = "") { let tag = tagQueue[index] - attrStr.replaceCharacters(in: tag.range, with: NSAttributedString()) + attrStr.replaceCharacters(in: tag.range, with: NSAttributedString(string: str)) let nextIndex = index+1 if nextIndex < tagQueue.count { for tIndex in nextIndex.. AttributedString func add(to source: AttributedString, range: NSRange?) -> AttributedString func set(to source: AttributedString, range: NSRange?) -> AttributedString @@ -46,21 +49,21 @@ public protocol StyleProtocol: class { public extension StyleProtocol { func set(to source: String, range: NSRange?) -> AttributedString { - guard let range = range else { // apply to entire string - return NSMutableAttributedString(string: source, attributes: self.attributes) - } let attributedText = NSMutableAttributedString(string: source) - attributedText.setAttributes(self.attributes, range: range) + self.fontData?.addAttributes(to: attributedText, range: nil) + attributedText.addAttributes(self.attributes, range: (range ?? NSMakeRange(0, source.count))) return attributedText } func add(to source: AttributedString, range: NSRange?) -> AttributedString { + self.fontData?.addAttributes(to: source, range: range) source.addAttributes(self.attributes, range: (range ?? NSMakeRange(0, source.length))) return source } func set(to source: AttributedString, range: NSRange?) -> AttributedString { - source.setAttributes(self.attributes, range: (range ?? NSMakeRange(0, source.length))) + self.fontData?.addAttributes(to: source, range: range) + source.addAttributes(self.attributes, range: (range ?? NSMakeRange(0, source.length))) return source } diff --git a/Sources/SwiftRichString/Style/StyleRegEx.swift b/Sources/SwiftRichString/Style/StyleRegEx.swift index 39dc59b..a82bc54 100644 --- a/Sources/SwiftRichString/Style/StyleRegEx.swift +++ b/Sources/SwiftRichString/Style/StyleRegEx.swift @@ -55,6 +55,11 @@ public class StyleRegEx: StyleProtocol { return self.style.attributes } + /// Font attributes + public var fontData: FontData? { + return self.style.fontData + } + //MARK: - INIT /// Initialize a new regular expression style matcher. diff --git a/SwiftRichString.playground/Contents.swift b/SwiftRichString.playground/Contents.swift new file mode 100644 index 0000000..d4f4295 --- /dev/null +++ b/SwiftRichString.playground/Contents.swift @@ -0,0 +1,33 @@ + +import UIKit +import SwiftRichString +import PlaygroundSupport + +// Create your own styles + +let normal = Style { + $0.font = SystemFonts.Helvetica_Light.font(size: 15) +} + +let bold = Style { + $0.font = SystemFonts.Helvetica_Bold.font(size: 20) + $0.color = UIColor.red + $0.backColor = UIColor.yellow +} + +let italic = normal.byAdding { + $0.traitVariants = .italic +} + +// Create a group which contains your style, each identified by a tag. +let myGroup = StyleGroup(base: normal, ["bold": bold, "italic": italic]) + +// Use tags in your plain string +let str = "Hello Daniele!. You're ready to play with us!" + +let attributedStringController = AttributedStringController() +PlaygroundPage.current.liveView = attributedStringController + +attributedStringController.attributedString = str.set(style: myGroup) + + diff --git a/SwiftRichString.playground/Sources/AttributedStringController.swift b/SwiftRichString.playground/Sources/AttributedStringController.swift new file mode 100644 index 0000000..80915e9 --- /dev/null +++ b/SwiftRichString.playground/Sources/AttributedStringController.swift @@ -0,0 +1,29 @@ + +import UIKit + +public class AttributedStringController: UIViewController { + + public var attributedString: NSAttributedString? { + get { + return textView?.attributedText + } + set { + textView?.attributedText = newValue + } + } + + private var textView: UITextView? + + public override func loadView() { + let view = UIView() + view.backgroundColor = .white + + let textView = UITextView() + textView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + textView.attributedText = attributedString + view.addSubview(textView) + self.textView = textView + + self.view = view + } +} diff --git a/SwiftRichString.playground/contents.xcplayground b/SwiftRichString.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/SwiftRichString.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SwiftRichString.podspec b/SwiftRichString.podspec index 12a50cc..ca7e8fc 100644 --- a/SwiftRichString.podspec +++ b/SwiftRichString.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SwiftRichString" - s.version = "2.0.1" + s.version = "2.0.2" s.summary = "Elegant Strings & Attributed Strings Toolkit for Swift" s.description = <<-DESC SwiftRichString is the best toolkit to work easily with Strings and Attributed Strings. diff --git a/SwiftRichString.xcodeproj/project.pbxproj b/SwiftRichString.xcodeproj/project.pbxproj index 62336ff..bf05955 100644 --- a/SwiftRichString.xcodeproj/project.pbxproj +++ b/SwiftRichString.xcodeproj/project.pbxproj @@ -55,12 +55,12 @@ 64507EA720B05015009455BD /* AttributedString+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EA320B05015009455BD /* AttributedString+Ext.swift */; }; 64507EA820B05015009455BD /* AttributedString+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EA320B05015009455BD /* AttributedString+Ext.swift */; }; 64507EA920B05015009455BD /* AttributedString+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EA320B05015009455BD /* AttributedString+Ext.swift */; }; - 64507EAC20B056FB009455BD /* FontInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontInfo.swift */; }; - 64507EAD20B056FB009455BD /* FontInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontInfo.swift */; }; - 64507EAE20B056FB009455BD /* FontInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontInfo.swift */; }; - 64507EAF20B056FB009455BD /* FontInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontInfo.swift */; }; - 64507EB020B056FB009455BD /* FontInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontInfo.swift */; }; - 64507EB120B056FB009455BD /* FontInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontInfo.swift */; }; + 64507EAC20B056FB009455BD /* FontData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontData.swift */; }; + 64507EAD20B056FB009455BD /* FontData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontData.swift */; }; + 64507EAE20B056FB009455BD /* FontData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontData.swift */; }; + 64507EAF20B056FB009455BD /* FontData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontData.swift */; }; + 64507EB020B056FB009455BD /* FontData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontData.swift */; }; + 64507EB120B056FB009455BD /* FontData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontData.swift */; }; 64507EB320B05E5A009455BD /* UIKit+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507E6120AEEE8D009455BD /* UIKit+Extras.swift */; }; 64507EB720B1766D009455BD /* StyleRegEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EB620B1766D009455BD /* StyleRegEx.swift */; }; 64507EB820B1766D009455BD /* StyleRegEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EB620B1766D009455BD /* StyleRegEx.swift */; }; @@ -88,7 +88,7 @@ 64507EF120B18F20009455BD /* AttributedString+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EA320B05015009455BD /* AttributedString+Ext.swift */; }; 64507EF220B18F20009455BD /* SystemFonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6489330F209DE87D000E691A /* SystemFonts.swift */; }; 64507EF320B18F20009455BD /* UIKit+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507E6120AEEE8D009455BD /* UIKit+Extras.swift */; }; - 64507EF420B18F20009455BD /* FontInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontInfo.swift */; }; + 64507EF420B18F20009455BD /* FontData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontData.swift */; }; 64507EF520B18F20009455BD /* CommonsAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648932C9209DE194000E691A /* CommonsAttributes.swift */; }; 64507EF620B18F20009455BD /* FontConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648932D3209DE44E000E691A /* FontConvertible.swift */; }; 64507EF720B18F20009455BD /* ColorConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64893308209DE7C5000E691A /* ColorConvertible.swift */; }; @@ -114,7 +114,7 @@ 64507F2B20B1912B009455BD /* AttributedString+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EA320B05015009455BD /* AttributedString+Ext.swift */; }; 64507F2C20B1912B009455BD /* SystemFonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6489330F209DE87D000E691A /* SystemFonts.swift */; }; 64507F2D20B1912B009455BD /* UIKit+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507E6120AEEE8D009455BD /* UIKit+Extras.swift */; }; - 64507F2E20B1912B009455BD /* FontInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontInfo.swift */; }; + 64507F2E20B1912B009455BD /* FontData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64507EAB20B056FB009455BD /* FontData.swift */; }; 64507F2F20B1912B009455BD /* CommonsAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648932C9209DE194000E691A /* CommonsAttributes.swift */; }; 64507F3020B1912B009455BD /* FontConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648932D3209DE44E000E691A /* FontConvertible.swift */; }; 64507F3120B1912B009455BD /* ColorConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64893308209DE7C5000E691A /* ColorConvertible.swift */; }; @@ -257,7 +257,7 @@ 64507E8C20AF3A9C009455BD /* StyleProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyleProtocol.swift; sourceTree = ""; }; 64507E9A20AF4681009455BD /* String+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Ext.swift"; sourceTree = ""; }; 64507EA320B05015009455BD /* AttributedString+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttributedString+Ext.swift"; sourceTree = ""; }; - 64507EAB20B056FB009455BD /* FontInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontInfo.swift; sourceTree = ""; }; + 64507EAB20B056FB009455BD /* FontData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontData.swift; sourceTree = ""; }; 64507EB620B1766D009455BD /* StyleRegEx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyleRegEx.swift; sourceTree = ""; }; 64507EBD20B18489009455BD /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; 64507EDB20B18F0F009455BD /* ExampleTvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleTvOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -460,7 +460,7 @@ 64507EAA20B05501009455BD /* Attributes */ = { isa = PBXGroup; children = ( - 64507EAB20B056FB009455BD /* FontInfo.swift */, + 64507EAB20B056FB009455BD /* FontData.swift */, 648932C9209DE194000E691A /* CommonsAttributes.swift */, 648932D3209DE44E000E691A /* FontConvertible.swift */, 64893308209DE7C5000E691A /* ColorConvertible.swift */, @@ -1040,7 +1040,7 @@ 64507EA420B05015009455BD /* AttributedString+Ext.swift in Sources */, 64893309209DE7C5000E691A /* ColorConvertible.swift in Sources */, 64507E8620AF3609009455BD /* String+Subscript.swift in Sources */, - 64507EAC20B056FB009455BD /* FontInfo.swift in Sources */, + 64507EAC20B056FB009455BD /* FontData.swift in Sources */, 648932D4209DE44E000E691A /* FontConvertible.swift in Sources */, 64507E7120AEF12C009455BD /* AssociatedValues.swift in Sources */, 64893310209DE87D000E691A /* SystemFonts.swift in Sources */, @@ -1073,7 +1073,7 @@ 64507EA620B05015009455BD /* AttributedString+Ext.swift in Sources */, 6489330B209DE7C5000E691A /* ColorConvertible.swift in Sources */, 64507E8820AF3609009455BD /* String+Subscript.swift in Sources */, - 64507EAE20B056FB009455BD /* FontInfo.swift in Sources */, + 64507EAE20B056FB009455BD /* FontData.swift in Sources */, 648932D6209DE44E000E691A /* FontConvertible.swift in Sources */, 64507E7320AEF12C009455BD /* AssociatedValues.swift in Sources */, 64893312209DE87D000E691A /* SystemFonts.swift in Sources */, @@ -1098,7 +1098,7 @@ 64507EA720B05015009455BD /* AttributedString+Ext.swift in Sources */, 6489330C209DE7C5000E691A /* ColorConvertible.swift in Sources */, 64507E8920AF3609009455BD /* String+Subscript.swift in Sources */, - 64507EAF20B056FB009455BD /* FontInfo.swift in Sources */, + 64507EAF20B056FB009455BD /* FontData.swift in Sources */, 648932D7209DE44E000E691A /* FontConvertible.swift in Sources */, 64507E7420AEF12C009455BD /* AssociatedValues.swift in Sources */, 64893313209DE87D000E691A /* SystemFonts.swift in Sources */, @@ -1123,7 +1123,7 @@ 64507EA520B05015009455BD /* AttributedString+Ext.swift in Sources */, 6489330A209DE7C5000E691A /* ColorConvertible.swift in Sources */, 64507E8720AF3609009455BD /* String+Subscript.swift in Sources */, - 64507EAD20B056FB009455BD /* FontInfo.swift in Sources */, + 64507EAD20B056FB009455BD /* FontData.swift in Sources */, 648932D5209DE44E000E691A /* FontConvertible.swift in Sources */, 64507E7220AEF12C009455BD /* AssociatedValues.swift in Sources */, 64893311209DE87D000E691A /* SystemFonts.swift in Sources */, @@ -1161,7 +1161,7 @@ 64507EF520B18F20009455BD /* CommonsAttributes.swift in Sources */, 64507EF720B18F20009455BD /* ColorConvertible.swift in Sources */, 64507EEE20B18F20009455BD /* StylesManager.swift in Sources */, - 64507EF420B18F20009455BD /* FontInfo.swift in Sources */, + 64507EF420B18F20009455BD /* FontData.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1176,7 +1176,7 @@ 64507F3220B1912B009455BD /* FontInfoAttribute.swift in Sources */, 64507F2D20B1912B009455BD /* UIKit+Extras.swift in Sources */, 64507F3020B1912B009455BD /* FontConvertible.swift in Sources */, - 64507F2E20B1912B009455BD /* FontInfo.swift in Sources */, + 64507F2E20B1912B009455BD /* FontData.swift in Sources */, 64507F2F20B1912B009455BD /* CommonsAttributes.swift in Sources */, 64507F2C20B1912B009455BD /* SystemFonts.swift in Sources */, 64507F1220B1911B009455BD /* ExtensionDelegate.swift in Sources */, @@ -1216,7 +1216,7 @@ 6489331B209DEAFF000E691A /* Style.swift in Sources */, 648932F0209DE47C000E691A /* FontConvertible.swift in Sources */, 64507E9F20AF4681009455BD /* String+Ext.swift in Sources */, - 64507EB020B056FB009455BD /* FontInfo.swift in Sources */, + 64507EB020B056FB009455BD /* FontData.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1240,7 +1240,7 @@ 64507EA920B05015009455BD /* AttributedString+Ext.swift in Sources */, 64507E7D20AEF611009455BD /* OrderedDictionary.swift in Sources */, 64507EC320B18489009455BD /* Extensions.swift in Sources */, - 64507EB120B056FB009455BD /* FontInfo.swift in Sources */, + 64507EB120B056FB009455BD /* FontData.swift in Sources */, 6489331C209DEAFF000E691A /* Style.swift in Sources */, 64507E8B20AF3609009455BD /* String+Subscript.swift in Sources */, 64893307209DE6CD000E691A /* FontConvertible.swift in Sources */, @@ -1851,6 +1851,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; + URLSERVIZI = ""; }; name = Debug; }; @@ -1878,6 +1879,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; + URLSERVIZI = ""; }; name = Release; }; diff --git a/SwiftRichString.xcodeproj/project.xcworkspace/xcuserdata/daniele.xcuserdatad/UserInterfaceState.xcuserstate b/SwiftRichString.xcodeproj/project.xcworkspace/xcuserdata/daniele.xcuserdatad/UserInterfaceState.xcuserstate index 2560158..7dd92b8 100644 Binary files a/SwiftRichString.xcodeproj/project.xcworkspace/xcuserdata/daniele.xcuserdatad/UserInterfaceState.xcuserstate and b/SwiftRichString.xcodeproj/project.xcworkspace/xcuserdata/daniele.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SwiftRichString.xcworkspace/contents.xcworkspacedata b/SwiftRichString.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ffd9a45 --- /dev/null +++ b/SwiftRichString.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/SwiftRichString.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftRichString.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwiftRichString.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + +