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

New ignoreDynamicFontSize property for iOS #132

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/SwiftyMarkdown/SwiftyMarkdown+iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ extension SwiftyMarkdown {
} else {
font = UIFont.preferredFont(forTextStyle: textStyle)
}

if ignoreDynamicFontSize, let fontSize = fontSize {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be a good idea to fix indentation before merging?

font = font.withSize(fontSize)
}

if globalItalic, let italicDescriptor = font.fontDescriptor.withSymbolicTraits(.traitItalic) {
font = UIFont(descriptor: italicDescriptor, size: fontSize ?? 0)
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftyMarkdown/SwiftyMarkdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ If that is not set, then the system default will be used.
public var bullet : String = "・"

public var underlineLinks : Bool = false

/// **iOS only** : Setting this boolean to true will force using the exact size set for each style if available.
public var ignoreDynamicFontSize : Bool = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works and covers an genuine use case, but a better solution might be to use scaledFont(for:, maximumPointSize:) from UIFontMetrics on SwiftyMarkdown+iOS.swift instead?


public var frontMatterAttributes : [String : String] {
get {
Expand Down