malcommac / SwiftRichString

👩‍🎨 Elegant Attributed String composition in Swift sauce
MIT License
3.1k stars 211 forks source link

When using a StyleGroup, the ParagraphStyles are not inherited from the base style. #126

Open CraigSiemens opened 3 years ago

CraigSiemens commented 3 years ago

Normally a style from the base style is inherited if a nested style doesn't override it. It seems like every field in NSParagraphStyle is overridden if one field is set on the paragraph style.

let baseStyle = Style {
    $0.lineHeightMultiple = 0.9
})

let headerStyle = Style {
    $0.paragraphSpacingAfter = 16
})

let style = StyleGroup(base: baseStyle, ["header": headerStyle])

This will cause the header text to no longer have the custom lineHeightMultiple applied to it.