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

Conversation

terhechte
Copy link

This would allow using a custom monospace font for highlighting. Which is especially useful if, say, the code is embedded into some sort of presentation 😊. An assert could be added to make sure the font is monospace, but I feel like that's not required. If somebody wants to display their code in Comic Sans, all the more power to them

@@ -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! 👍

@terhechte
Copy link
Author

Closed in favor of #111

@terhechte terhechte closed this Jun 7, 2020
@terhechte terhechte deleted the patch-1 branch June 7, 2020 07:47
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