Search paths for fonts on Apple platforms
Closed this issue · 1 comments
Currently, the CoreText source is searching in "/System/Library/Fonts/"
for fonts, but it should probably be searching in more than that.
Fonts can be found in:
- The user's home directory library, but this one is tricky.
"/Library/Fonts"
"/System/Library/Fonts"
"/Network/Library/Fonts"
The user's home directory might be tricky due to sandboxing and so we shouldn't just put together the paths ourselves, but use the system APIs for this instead. (In sandboxed applications, one doesn't have direct access to ~/Library/
but has access to something in ~/Library/Containers/<application id>/data/Library
which contains a symlink to the Fonts
directory.)
I think the right thing to do would be to use NSSearchPathForDirectoriesInDomains
(https://developer.apple.com/documentation/foundation/1414224-nssearchpathfordirectoriesindoma?language=objc) with NSLibraryDirectory
or (NSAllLibrariesDirectory
, I don't know which) and a mask of NSAllDomainsMask
. We should be able to get this from objc2_foundation
(https://docs.rs/objc2-foundation/latest/objc2_foundation/fn.NSSearchPathForDirectoriesInDomains.html)
And finally ... there are ALSO fonts in /System/Library/Fonts/Supplemental
which should be scanned.
Ends up: /System/Library/Fonts/Supplemental
is already scanned while scanning /System/Library/Fonts
... but the rest remains true!