Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Attributed text and scalability #158

Open
MahmoudZinji opened this issue Feb 4, 2025 · 0 comments
Open

Issue with Attributed text and scalability #158

MahmoudZinji opened this issue Feb 4, 2025 · 0 comments

Comments

@MahmoudZinji
Copy link

MahmoudZinji commented Feb 4, 2025

  • This is how i use SwiftyMarkdown in my code

subTitleLabel.attributedText = NSAttributedString.from(markupString: viewModel.subTitle ?? "", baseFont: UIFont.NewDesign.textPrimary)

  • And i call this func in the below extension
extension NSAttributedString {
    static func from(markupString: String,
                     baseFont: UIFont = .NewDesign.textPrimary,
                     color: UIColor = UIColor.NewDesign.graphiteBlack) -> NSAttributedString {
        let markdownString = SwiftyMarkdown(string: markupString)
        markdownString.setFontNameForAllStyles(with: baseFont.fontName)
        markdownString.setFontSizeForAllStyles(with: baseFont.pointSize)
        markdownString.setFontColorForAllStyles(with: color)
        markdownString.body.alignment = .center

        return markdownString.attributedString()
    }
}

  • What i expect if something like

abc def ghi **BoldAttributedString** jkl mno pgr

when i change text size from setting and switch back to my screen all the abc letters adjust except the Attributed one

if i start my app with big text size the attributed is big but not as other texts, not as supposed to be

here below is the font thet i use as an example

extension UIFont {
    struct NewDesign {
        
        static var textPrimary: UIFont {
            UIFont(name: "Asap-Regular", size: 16.0)!.scaledFont
        }
}
}

the scaling is not as supposed to be

Any idea why is this happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant