Skip to content

Commit

Permalink
fixed text drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Oct 5, 2016
1 parent e74b1f1 commit dc1c24a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Sources/Cacao/NSStringDrawing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -168,7 +168,7 @@ public struct NSStringDrawingOptions: OptionSet, ExpressibleByIntegerLiteral {

public init() {

self = NSStringDrawingOptions.UsesLineFragmentOrigin
self = NSStringDrawingOptions.usesLineFragmentOrigin
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/CacaoTests/StyleKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ final class StyleKitTests: XCTestCase {

UIGraphicsPushContext(CGContext(context))

TestStyleKit.drawMultilineText()
TestStyleKit.drawMultiLineText()

UIGraphicsPopContext()

Expand Down
8 changes: 4 additions & 4 deletions Sources/CacaoTests/TestStyleKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()!

Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit dc1c24a

Please sign in to comment.