Skip to content

Commit bbe9abd

Browse files
committed
Fix HeaderFormatter remove of style.
1 parent 78d52ec commit bbe9abd

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

Aztec/Classes/Formatters/Implementations/HeaderFormatter.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ open class HeaderFormatter: ParagraphAttributeFormatter {
6868
resultingAttributes[.paragraphStyle] = newParagraphStyle
6969

7070
if let font = attributes[.font] as? UIFont {
71-
let newFont = font.withSize(CGFloat(header.defaultFontSize))
71+
var newFont = font.withSize(CGFloat(header.defaultFontSize))
7272
if Configuration.headersWithBoldTrait {
73-
resultingAttributes[.font] = newFont.modifyTraits(.traitBold, enable: false)
73+
newFont = newFont.modifyTraits(.traitBold, enable: false)
7474
}
75+
resultingAttributes[.font] = newFont
7576
}
7677
resultingAttributes[.headingRepresentation] = nil
7778
return resultingAttributes

AztecTests/Formatters/HeaderFormatterTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class HeaderFormatterTests: XCTestCase {
2828

2929
let removedAttrs = formatter.remove(from: updatedAttrs)
3030
let removedFont = removedAttrs[.font] as! UIFont
31-
XCTAssert(removedFont.pointSize == defaultFontSize)
31+
XCTAssertEqual(removedFont.pointSize, defaultFontSize)
3232
}
3333

3434
/// Verifies that the Default Font is preserved whenever a Header Style is applied on top of an existant Header.
@@ -46,6 +46,6 @@ class HeaderFormatterTests: XCTestCase {
4646

4747
let removedAttrs = formatterH2.remove(from: updatedH2Attrs)
4848
let removedFont = removedAttrs[.font] as! UIFont
49-
XCTAssert(removedFont.pointSize == defaultFontSize)
49+
XCTAssertEqual(removedFont.pointSize, defaultFontSize)
5050
}
5151
}

0 commit comments

Comments
 (0)