Skip to content

Commit

Permalink
Merge pull request #36 from Nirma/baseline_offset
Browse files Browse the repository at this point in the history
Add support for NSBaselineOffsetAttributeName
  • Loading branch information
Nicholas Maccharoli authored Jul 20, 2017
2 parents b40e99f + 2a35053 commit d2a66af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Attributed/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public struct Attributes {
public func link(_ link: String) -> Attributes {
return self + Attributes(dictionary: [NSLinkAttributeName: link])
}

public func baselineOffset(_ offset: NSNumber) -> Attributes {
return self + Attributes(dictionary: [NSBaselineOffsetAttributeName: offset])
}
}

// MARK: NSParagraphStyle related
Expand Down
8 changes: 8 additions & 0 deletions AttributedTests/AttributesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ class AttributesTests: XCTestCase {
let attributed = Attributes().font(.systemFont(ofSize: 12.0))
XCTAssert(attributed.dictionary.keys.first! == expected.keys.first!, "Font is broken")
}

// NSBaselineOffsetAttributeName

func testBaselineOffset() {
let expected: [String: Any] = [NSBaselineOffsetAttributeName: NSNumber(value: 1)]
let attributed = Attributes().baselineOffset(1)
XCTAssert(attributed.dictionary.keys.first! == expected.keys.first!, "NSBaselineOffsetAttributeName functionality is broken")
}
}

0 comments on commit d2a66af

Please sign in to comment.