問題タブ [nsfont]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
swift - Adding a custom font to macOS app using Swift
I followed a bunch of tutorials but it doesn’t work: I simply want to add a custom font to a macOS app.
What I tried essentially:
- Added the
.ttffont-files to my project: Target Membership is set and I also made sure that the files are copied usingCopy FileswithinBundle Phases. After compiling I can see that all files are within the Bundle. So that seems to work perfectly fine.
Info.plist: I addedFonts provided by applicationand created an item for every font-file I want to add (values likemyFont.tff).I made sure that I use the correct font name. I installed the fonts on my system and configured a Label with Interface Builder so that it uses the desired font. I printed it’s value
print(myLabel.font.fontName).Confusing: If the exactly same font-file I want to add to the app is installed in the systems Fontbook and activated, everything works well. When I deactivate it, it doesn’t work. For me that indicates that I am using the correct font name.
I found
ATSApplicationFontsPathand tried to add it to theInfo.plist, but neither using a path (recommended by the docs) or values like.(which seemed to work for some people out there) worked out.
Appreciate any help!

