gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.24k stars 266 forks source link

Fixing dynamic type for custom fonts #314

Closed mikelikespie closed 1 week ago

mikelikespie commented 1 month ago

Right now it seems the library accounts for dynamic type twice when using custom fonts.

This is because it is using the @ScaledMetric for dynamic size, as well as custom(_ name: String, size: CGFloat) constructor for Font. The docs for that one say

    /// Create a custom font with the given `name` and `size` that scales with
    /// the body text style.

Which means its scales it again.

It seems like the easiest fix is just calling the other constructor for custom fonts which has a fixedSize parameter. It appears that all the versions required in Package.swift support that constructor.

erator commented 1 month ago

@mikelikespie have you tried looking into the failing test testFontWithProperties()?

gonzalezreal commented 1 week ago

@mikelikespie I cherry-picked your change and fixed the failing test #330. Thanks for the contribution!

mikelikespie commented 1 week ago

Thanks so much! APologies for not fixin the test, it got lost in my todos

On Sun, Jun 16, 2024 at 1:38 AM Guille Gonzalez @.***> wrote:

@mikelikespie https://github.com/mikelikespie I cherry-picked your change and fixed the failing test #330 https://github.com/gonzalezreal/swift-markdown-ui/pull/330. Thanks for the contribution!

— Reply to this email directly, view it on GitHub https://github.com/gonzalezreal/swift-markdown-ui/pull/314#issuecomment-2171253031, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAFHOY6UDU6D23KI3RJE7LZHVFHBAVCNFSM6AAAAABHMCODT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZRGI2TGMBTGE . You are receiving this because you were mentioned.Message ID: @.***>