Skip to content

Comments

Added .codeFont(_:) modifier#11

Open
blsage wants to merge 2 commits intoappstefan:mainfrom
blsage:main
Open

Added .codeFont(_:) modifier#11
blsage wants to merge 2 commits intoappstefan:mainfrom
blsage:main

Conversation

@blsage
Copy link

@blsage blsage commented Oct 29, 2024

Updated modifiers to support a .codeFont(_:) custom attribute. Disabled monospaced design if font is set custom.

@appstefan
Copy link
Owner

These changes are well implemented, however I think they might be redundant.

Standard SwiftUI view modifiers can be applied to CodeText to override the font design back to .default and then set the font to one of the environment-dependent Font options. Notably, the order of these two modifiers does matter. For example:

struct HeadlineCodeText: View {
    let text: String

    var body: some View {
        CodeText(text)
            .fontDesign(.default)
            .font(.headline)
    }
}

Let me know if this is sufficient for your use case. If not, we could still consider merging this.

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

Successfully merging this pull request may close these issues.

2 participants