From dc1c24a9322f3ad5dd342ed052f796272f3b9cf5 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Wed, 5 Oct 2016 16:05:35 -0500 Subject: [PATCH] fixed text drawing --- Sources/Cacao/NSStringDrawing.swift | 10 +++++----- Sources/CacaoTests/StyleKitTests.swift | 2 +- Sources/CacaoTests/TestStyleKit.swift | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/Cacao/NSStringDrawing.swift b/Sources/Cacao/NSStringDrawing.swift index d690c39..c744d09 100644 --- a/Sources/Cacao/NSStringDrawing.swift +++ b/Sources/Cacao/NSStringDrawing.swift @@ -149,10 +149,10 @@ extension NSLineBreakMode: CacaoConvertible { /// Rendering options for a string when it is drawn. public struct NSStringDrawingOptions: OptionSet, ExpressibleByIntegerLiteral { - public static let UsesLineFragmentOrigin = NSStringDrawingOptions(rawValue: (1 << 0)) - public static let UsesFontLeading = NSStringDrawingOptions(rawValue: (1 << 1)) - public static let UsesDeviceMetrics = NSStringDrawingOptions(rawValue: (1 << 3)) - public static let TruncatesLastVisibleLine = NSStringDrawingOptions(rawValue: (1 << 5)) + public static let usesLineFragmentOrigin = NSStringDrawingOptions(rawValue: (1 << 0)) + public static let usesFontLeading = NSStringDrawingOptions(rawValue: (1 << 1)) + public static let usesDeviceMetrics = NSStringDrawingOptions(rawValue: (1 << 3)) + public static let truncatesLastVisibleLine = NSStringDrawingOptions(rawValue: (1 << 5)) public var rawValue: Int @@ -168,7 +168,7 @@ public struct NSStringDrawingOptions: OptionSet, ExpressibleByIntegerLiteral { public init() { - self = NSStringDrawingOptions.UsesLineFragmentOrigin + self = NSStringDrawingOptions.usesLineFragmentOrigin } } diff --git a/Sources/CacaoTests/StyleKitTests.swift b/Sources/CacaoTests/StyleKitTests.swift index 286d327..8ff3d6d 100644 --- a/Sources/CacaoTests/StyleKitTests.swift +++ b/Sources/CacaoTests/StyleKitTests.swift @@ -85,7 +85,7 @@ final class StyleKitTests: XCTestCase { UIGraphicsPushContext(CGContext(context)) - TestStyleKit.drawMultilineText() + TestStyleKit.drawMultiLineText() UIGraphicsPopContext() diff --git a/Sources/CacaoTests/TestStyleKit.swift b/Sources/CacaoTests/TestStyleKit.swift index 3a0868d..f78fbfd 100644 --- a/Sources/CacaoTests/TestStyleKit.swift +++ b/Sources/CacaoTests/TestStyleKit.swift @@ -461,7 +461,7 @@ public final class TestStyleKit : NSObject { "Upper alignment".draw(in: text5Rect, withAttributes: text5FontAttributes) } - public dynamic class func drawMultiLineText() { + public class func drawMultiLineText() { //// General Declarations let context = UIGraphicsGetCurrentContext()! @@ -479,7 +479,7 @@ public final class TestStyleKit : NSObject { let text5TextContent = "Center - Lorem ipsum dolor sit amet, consectetur adipiscing elit." let text5Style = NSMutableParagraphStyle() text5Style.alignment = .center - let text5FontAttributes = [NSFontAttributeName: UIFont(name: "TimesNewRomanPSMT", size: 17)!, NSForegroundColorAttributeName: white, NSParagraphStyleAttributeName: text5Style] as [String : Any] + let text5FontAttributes = [NSFontAttributeName: UIFont(name: "TimesNewRoman", size: 17)!, NSForegroundColorAttributeName: white, NSParagraphStyleAttributeName: text5Style] as [String : Any] let text5TextHeight: CGFloat = text5TextContent.boundingRect(with: CGSize(width: text5Rect.width, height: CGFloat.infinity), options: .usesLineFragmentOrigin, attributes: text5FontAttributes, context: nil).height context.saveGState() @@ -496,7 +496,7 @@ public final class TestStyleKit : NSObject { let textTextContent = "Left - Lorem ipsum dolor sit amet, consectetur adipiscing elit." let textStyle = NSMutableParagraphStyle() textStyle.alignment = .left - let textFontAttributes = [NSFontAttributeName: UIFont(name: "TimesNewRomanPSMT", size: 17)!, NSForegroundColorAttributeName: white, NSParagraphStyleAttributeName: textStyle] as [String : Any] + let textFontAttributes = [NSFontAttributeName: UIFont(name: "TimesNewRoman", size: 17)!, NSForegroundColorAttributeName: white, NSParagraphStyleAttributeName: textStyle] as [String : Any] let textTextHeight: CGFloat = textTextContent.boundingRect(with: CGSize(width: textRect.width, height: CGFloat.infinity), options: .usesLineFragmentOrigin, attributes: textFontAttributes, context: nil).height context.saveGState() @@ -513,7 +513,7 @@ public final class TestStyleKit : NSObject { let text2TextContent = "Right - Lorem ipsum dolor sit amet, consectetur adipiscing elit." let text2Style = NSMutableParagraphStyle() text2Style.alignment = .right - let text2FontAttributes = [NSFontAttributeName: UIFont(name: "TimesNewRomanPSMT", size: 17)!, NSForegroundColorAttributeName: white, NSParagraphStyleAttributeName: text2Style] as [String : Any] + let text2FontAttributes = [NSFontAttributeName: UIFont(name: "TimesNewRoman", size: 17)!, NSForegroundColorAttributeName: white, NSParagraphStyleAttributeName: text2Style] as [String : Any] let text2TextHeight: CGFloat = text2TextContent.boundingRect(with: CGSize(width: text2Rect.width, height: CGFloat.infinity), options: .usesLineFragmentOrigin, attributes: text2FontAttributes, context: nil).height context.saveGState()