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

Allow initializing Font with NSFont or UIFont #109

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
Allow initializing Font with NSFont or UIFont
  • Loading branch information
terhechte authored May 28, 2020
commit a2f6803a53de21b0ea3b0f9c915a1c3da2fec8f3
6 changes: 6 additions & 0 deletions Sources/Splash/Theming/Font.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public struct Font {
resource = .system
self.size = size
}

/// Initialize an instance with an existing, custom, font.
public init(font: Loaded) {
Copy link
Owner

Choose a reason for hiding this comment

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

I think here we can drop the external parameter label, so rather than:

Font(font: nativeFont)

It would be:

Font(nativeFont)

Or what do you think @terhechte?

Copy link
Owner

Choose a reason for hiding this comment

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

Or, an alternative design would be to use something inspired by RawRepresentable, and name the external parameter label rawFont, or nativeFont.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I like it. Makes it clearer. If you're fine with this change, I'd check out the repo and create a proper PR, seems CI failed (I did the editing right on Github, so I never tried to compile it ;)

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds great! 👍

resource = .preloaded(font)
self.size = font.pointSize
}
}

public extension Font {
Expand Down