-
Notifications
You must be signed in to change notification settings - Fork 38
Fonts: fix code which checks if a font is already registered #77
Conversation
I remember trying the registration on macOS when I first wrote it. It seemed to work at the time 😅 Seeing as CI compilation passes, the only thing missing is a changelog entry. If you could please add it crediting yourself, and using the same format as the other entries. See here for more information: |
CHANGELOG.md
Outdated
|
||
### Bug Fixes | ||
|
||
* Fix code which checks is font already registered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "if font"
Also, please add two spaces after that ending period. That's required by MarkDown syntax to render the next line separately properly (see other entries for inspiration)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see @djbe beat me to it and already made the change for you ^^
|
||
fileprivate var url: NSURL? { | ||
let bundle = NSBundle(forClass: BundleToken.self) | ||
guard let url = bundle.URLForResource(path, withExtension: nil) else { return nil } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, given than you guard let url … else return nil
and do nothing afterwards but directly return url
, why not directly return bundle.URLForResource(path, withExtension: nil)
there? That would already directly return nil if URLForResource
return nil, so…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, you right..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now 👌
Thanks for the contribution @chipp 👍
Thanks a lot for contributing to SwiftGen @chipp ! 👍 No pressure to accept nor any obligation in that! It will just give you the ability to help triage issues or push directly branches to the repo (instead of your fork)… in case you want to contribute again in the future 😉 For more information, read the COMMUNITY.md and CONTRIBUTING.md documents, and if you have any questions don't hesitate to reach out! |
@AliSoftware we discussed these changes here 06bcd2a#diff-3fc62affc2b681781b6ef4a2fac1a6e7R37
Also I prepared test project for these changes: https://github.com/chipp/FontTests
I tried to reuse
NSFontManager.shared().availableMembers(ofFontFamily:)
solution for macOS, but with help of test project I found thatNSFontManager
doesn't see freshly added fonts and this check is useless.