Enumerate available fonts through the native API on macOS - #263
Conversation
macOS provides the CTFontManagerCopyAvailableFontURLs() method to get a list of all available fonts. Use it to iterate available fonts on macOS instead of scanning a list of hardcoded directories. Use the `Switch.SixLabors.Fonts.DoNotUseNativeSystemFontsEnumeration` AppContext switch to opt-out of the native system fonts enumeration.
Codecov Report
@@ Coverage Diff @@
## main #263 +/- ##
===================================
- Coverage 83% 83% -1%
===================================
Files 186 187 +1
Lines 9474 9517 +43
Branches 1493 1499 +6
===================================
+ Hits 7936 7939 +3
- Misses 1193 1231 +38
- Partials 345 347 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
Well this is cool! Thanks! I'm not super well versed with dll Importing so I'm gonna see if I can get a second opinion for reviewing. |
JimBobSquarePants
left a comment
There was a problem hiding this comment.
This all looks like it's working well to me an is very well documented to approving.
Thanks @0xced for your help! 👍
|
Awesome, thanks for merging. Once the Also, I'll make sure not to use file scoped namespaces in my future pull requests. |
|
No worries! Working hard on CFF but it's a huge task. Could take me a while.
Once I finally shift a V1 I'll be moving everything to the latest and greatest so we can use things like that without issue. |
Prerequisites
Description
macOS provides the CTFontManagerCopyAvailableFontURLs() method to get a list of all available fonts. Use it to iterate available fonts on macOS instead of scanning a list of hardcoded directories.
Use the
Switch.SixLabors.Fonts.DoNotUseNativeSystemFontsEnumerationAppContext switch to opt-out of the native system fonts enumeration.Running the
ListFontssample code before this change on my Mac would yield 628 fonts and 726 after this change becauseCTFontManagerCopyAvailableFontURLsknows about downloadable fonts.