SimonFairbairn / SwiftyMarkdown

Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.
MIT License
1.64k stars 275 forks source link

Changes to the .bold property has no effect #57

Closed Wiingaard closed 4 years ago

Wiingaard commented 5 years ago

Hello there. Thanks for a great open source project :)

I'm using SwiftyMarkdown version 0.6.0 I haven't used SwiftyMarkdown for very long, so maybe this is on me, but it seems to me that there is a problem with formatting bold tags.

See the following example code:

let message = "this is **bold** text"
let swiftyMarkdown = SwiftyMarkdown.init(string: message)
swiftyMarkdown.body.fontName = UIFont.systemFont(ofSize: 13, weight: UIFont.Weight.semibold).fontName
swiftyMarkdown.body.fontSize = 13
swiftyMarkdown.bold.fontName = UIFont.systemFont(ofSize: 13, weight: UIFont.Weight.heavy).fontName
swiftyMarkdown.bold.fontSize = 13
let markdown = swiftyMarkdown.attributedString()
print("___")
print(markdown)
print("___")

In this example all the body text is changed correctly to the .semibold weight, but the bold text isn't changed to .heavy weight. See the following debug print:


this is { NSColor = "UIExtendedGrayColorSpace 0 1"; NSFont = "<UICTFont: 0x7f89e37b9ce0> font-family: \".SFUIText-Semibold\"; font-weight: bold; font-style: normal; font-size: 13.00pt"; }bold{ NSColor = "UIExtendedGrayColorSpace 0 1"; NSFont = "<UICTFont: 0x7f89d6600000> font-family: \".SFUIText\"; font-weight: normal; font-style: normal; font-size: 13.00pt"; } text{ NSColor = "UIExtendedGrayColorSpace 0 1"; NSFont = "<UICTFont: 0x7f89e37b9ce0> font-family: \".SFUIText-Semibold\"; font-weight: bold; font-style: normal; font-size: 13.00pt"; }


Here it appear that the "bold"-text is reset to .normal weight. I've also tried changing other properties og the bold style, but none of them take effect.

Is this a bug, or is it intended behaviour? it so, how can I set both the weight of the body text and bold text?