How to use custom fonts in a mac application?
I try to use custom fonts in my swift app, but they don't load.
I copy the fonts.ttf in my resources folder, and I added the names in Info.plist under "Fonts provided by application " key.
I've try with "Application fonts resource path" key from .plist , but no results.
Here is the code I used to apply my font. I've try with : "MyFont.ttf" , and "MyFont"
@IBOutlet weak var label:NSTextField!
override func awakeFromNib() {
label.font = NSFont(name: "MyFont.ttf", size: 15)
}
xcode macos swift custom-font
add a comment |
I try to use custom fonts in my swift app, but they don't load.
I copy the fonts.ttf in my resources folder, and I added the names in Info.plist under "Fonts provided by application " key.
I've try with "Application fonts resource path" key from .plist , but no results.
Here is the code I used to apply my font. I've try with : "MyFont.ttf" , and "MyFont"
@IBOutlet weak var label:NSTextField!
override func awakeFromNib() {
label.font = NSFont(name: "MyFont.ttf", size: 15)
}
xcode macos swift custom-font
From another SO answer (sorry can't find it now): the name string can be found by opening the font in Font Book and using the string next toPostScript name
that's shown in the inspector pane.
– Todd
Nov 21 at 17:04
add a comment |
I try to use custom fonts in my swift app, but they don't load.
I copy the fonts.ttf in my resources folder, and I added the names in Info.plist under "Fonts provided by application " key.
I've try with "Application fonts resource path" key from .plist , but no results.
Here is the code I used to apply my font. I've try with : "MyFont.ttf" , and "MyFont"
@IBOutlet weak var label:NSTextField!
override func awakeFromNib() {
label.font = NSFont(name: "MyFont.ttf", size: 15)
}
xcode macos swift custom-font
I try to use custom fonts in my swift app, but they don't load.
I copy the fonts.ttf in my resources folder, and I added the names in Info.plist under "Fonts provided by application " key.
I've try with "Application fonts resource path" key from .plist , but no results.
Here is the code I used to apply my font. I've try with : "MyFont.ttf" , and "MyFont"
@IBOutlet weak var label:NSTextField!
override func awakeFromNib() {
label.font = NSFont(name: "MyFont.ttf", size: 15)
}
xcode macos swift custom-font
xcode macos swift custom-font
edited Aug 19 '16 at 14:23
dckuehn
1,84631932
1,84631932
asked Dec 28 '14 at 21:46
C-Viorel
4541027
4541027
From another SO answer (sorry can't find it now): the name string can be found by opening the font in Font Book and using the string next toPostScript name
that's shown in the inspector pane.
– Todd
Nov 21 at 17:04
add a comment |
From another SO answer (sorry can't find it now): the name string can be found by opening the font in Font Book and using the string next toPostScript name
that's shown in the inspector pane.
– Todd
Nov 21 at 17:04
From another SO answer (sorry can't find it now): the name string can be found by opening the font in Font Book and using the string next to
PostScript name
that's shown in the inspector pane.– Todd
Nov 21 at 17:04
From another SO answer (sorry can't find it now): the name string can be found by opening the font in Font Book and using the string next to
PostScript name
that's shown in the inspector pane.– Todd
Nov 21 at 17:04
add a comment |
6 Answers
6
active
oldest
votes
First add the desired font you want to embed to your OSX app to your project:
Then click project > Info, then click the plus sign and add a new key "Application fonts resource path" and type the name of your fonts there creating an array of strings:
Now you can select custom font and the name of the font will show there, you still need to use the Font Book to make it available inside Xcode.
I think i get crazy! I done this, exactly like you said , but , nothing . Added font is not present in font list.
– C-Viorel
Dec 29 '14 at 7:06
Can you send me the font link? The problem might be with the Font selected. Have you tried with another font ?
– Leo Dabus
Dec 29 '14 at 7:07
2
Application fonts resource path is a string type and I can't add array of strings
– myatmins
Jun 11 '16 at 20:28
2
hi, what if Application fonts resource path is a string not a array, I couldn't add font like you did with that image
– stan liu
Sep 8 '16 at 4:38
3
For me this was the issue, the font MUST be installed in the system (ie. Font Book) before it can be embedded in the application. This seems ridiculous, but I'm assuming the explanation is so you can use it in Interface Builder, but even if you only create the font in code, it needs to be installed in Font Book initially, then you can remove it if you want to. And Apple does not mention any of that on the page for how to embed fonts in your app so it is very confusing. Also, for macOS, I'm using the plist key "Fonts Provided By Application" and not "Application fonts resource path".
– Ben Stahl
Mar 1 at 19:41
|
show 11 more comments
As "Application fonts resource path" is now a string type in XCode 7.3.1 and I couldn't seem to find a way to use an Array for multiple fonts, I used "." in the Info.plist:
Application fonts resource path String .
and this seemed to work to pick up all my custom fonts in a Resources folder dynamically e.g. using Swift
labelText.font = NSFont(name: "DS-Digital", size: 48)
However, to see it in XCode design mode (to choose a font from drop-down menu), I needed to first add the font to Font Book.
However, Font Book was not required for the dynamic method to work :)
This solution saved me!! Thanks
– Silviu St
Oct 23 '16 at 15:16
this is not working for me any other solution ??
– Devang
Jan 11 '17 at 10:01
"." is working for me.
– R0CKSTAR
Feb 15 '17 at 3:37
Also found if you place the fonts into a folder, say "Fonts", you can use "Fonts" for the string value.
– R0CKSTAR
Feb 15 '17 at 3:48
add a comment |
ATSApplicationFontsPath
is for macOS:
ATSApplicationFontsPath (
String
- macOS) identifies the location of a
font file or directory of fonts in the bundle’s Resources directory.
If present, macOS activates the fonts at the specified path for use by
the bundled app. The fonts are activated only for the bundled app and
not for the system as a whole. The path itself should be specified as
a relative directory of the bundle’s Resources directory. For example,
if a directory of fonts was at the path
/Applications/MyApp.app/Contents/Resources/Stuff/MyFonts/, you should
specify the string Stuff/MyFonts/ for the value of this key.
macOS app Instructions:
- Select your Xcode project in the project navigator
- Select your
app target
- Click the + button and to add a New Copy Files Phase
- Select Resources for the destination
- Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.
- Drag and drop the font files into the file list of the Copy Files build phase.
UIAppFonts
is for iOS:
UIAppFonts (
Array
- iOS) Specifies any app-provided fonts that should
be made available through the normal mechanisms. Each item in the
array is a string containing the name of a font file (including
filename extension) that is located in the app’s bundle. The system
loads the specified fonts and makes them available for use by the app
when that app is run.
This key is supported in iOS 3.2 and later.
add a comment |
Try doing this from the interface builder, in the attributes inspector .
From IB i have access only to installed system fonts. I want to load my own font.
– C-Viorel
Dec 28 '14 at 21:57
1
In IB ,attributes inspector (font line) click the "T" and click font then custom. If you want (ex MyFont), first you have to loaded into OS X(Font Book) ,then you can select your font.Sorry for my bad english .
– Name
Dec 28 '14 at 22:05
but that resolve the problem just for me . if i install a .ttf font in fontBook i can use it very easy, but , then every user who use my app needs to install that font, and i am pretty sure about one thing : User is lazy.
– C-Viorel
Dec 28 '14 at 22:12
1
First you need to put your font in the project and use ATSApplicationFontsPath key in the info.plist .More info developer.apple.com/library/mac/documentation/General/Reference/…
– Name
Dec 28 '14 at 22:25
Application fonts resource path is the new key name for ATSApplicationFontsPath, so i already did that, but , is possible to do it wrong.
– C-Viorel
Dec 28 '14 at 22:30
|
show 2 more comments
By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.
add a comment |
For those whose font family is called something like My-Custom-Font-Family:
be aware that in code you should instantiate your custom font like this: NSFont(name: "MyCustomFontFamily-Bold", size: 20)
Spaces and "-" are ignored and font type is written after "-". I did not see this in any docs and spend a few hours trying to figure out wtf was wrong.
Also if you want to get list of all available fonts you can use this code
for font in NSFontManager.shared.availableFonts {
print(font)
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27680893%2fhow-to-use-custom-fonts-in-a-mac-application%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
First add the desired font you want to embed to your OSX app to your project:
Then click project > Info, then click the plus sign and add a new key "Application fonts resource path" and type the name of your fonts there creating an array of strings:
Now you can select custom font and the name of the font will show there, you still need to use the Font Book to make it available inside Xcode.
I think i get crazy! I done this, exactly like you said , but , nothing . Added font is not present in font list.
– C-Viorel
Dec 29 '14 at 7:06
Can you send me the font link? The problem might be with the Font selected. Have you tried with another font ?
– Leo Dabus
Dec 29 '14 at 7:07
2
Application fonts resource path is a string type and I can't add array of strings
– myatmins
Jun 11 '16 at 20:28
2
hi, what if Application fonts resource path is a string not a array, I couldn't add font like you did with that image
– stan liu
Sep 8 '16 at 4:38
3
For me this was the issue, the font MUST be installed in the system (ie. Font Book) before it can be embedded in the application. This seems ridiculous, but I'm assuming the explanation is so you can use it in Interface Builder, but even if you only create the font in code, it needs to be installed in Font Book initially, then you can remove it if you want to. And Apple does not mention any of that on the page for how to embed fonts in your app so it is very confusing. Also, for macOS, I'm using the plist key "Fonts Provided By Application" and not "Application fonts resource path".
– Ben Stahl
Mar 1 at 19:41
|
show 11 more comments
First add the desired font you want to embed to your OSX app to your project:
Then click project > Info, then click the plus sign and add a new key "Application fonts resource path" and type the name of your fonts there creating an array of strings:
Now you can select custom font and the name of the font will show there, you still need to use the Font Book to make it available inside Xcode.
I think i get crazy! I done this, exactly like you said , but , nothing . Added font is not present in font list.
– C-Viorel
Dec 29 '14 at 7:06
Can you send me the font link? The problem might be with the Font selected. Have you tried with another font ?
– Leo Dabus
Dec 29 '14 at 7:07
2
Application fonts resource path is a string type and I can't add array of strings
– myatmins
Jun 11 '16 at 20:28
2
hi, what if Application fonts resource path is a string not a array, I couldn't add font like you did with that image
– stan liu
Sep 8 '16 at 4:38
3
For me this was the issue, the font MUST be installed in the system (ie. Font Book) before it can be embedded in the application. This seems ridiculous, but I'm assuming the explanation is so you can use it in Interface Builder, but even if you only create the font in code, it needs to be installed in Font Book initially, then you can remove it if you want to. And Apple does not mention any of that on the page for how to embed fonts in your app so it is very confusing. Also, for macOS, I'm using the plist key "Fonts Provided By Application" and not "Application fonts resource path".
– Ben Stahl
Mar 1 at 19:41
|
show 11 more comments
First add the desired font you want to embed to your OSX app to your project:
Then click project > Info, then click the plus sign and add a new key "Application fonts resource path" and type the name of your fonts there creating an array of strings:
Now you can select custom font and the name of the font will show there, you still need to use the Font Book to make it available inside Xcode.
First add the desired font you want to embed to your OSX app to your project:
Then click project > Info, then click the plus sign and add a new key "Application fonts resource path" and type the name of your fonts there creating an array of strings:
Now you can select custom font and the name of the font will show there, you still need to use the Font Book to make it available inside Xcode.
edited May 9 '17 at 19:44
AJcodez
14.5k95797
14.5k95797
answered Dec 29 '14 at 0:18
Leo Dabus
130k30264340
130k30264340
I think i get crazy! I done this, exactly like you said , but , nothing . Added font is not present in font list.
– C-Viorel
Dec 29 '14 at 7:06
Can you send me the font link? The problem might be with the Font selected. Have you tried with another font ?
– Leo Dabus
Dec 29 '14 at 7:07
2
Application fonts resource path is a string type and I can't add array of strings
– myatmins
Jun 11 '16 at 20:28
2
hi, what if Application fonts resource path is a string not a array, I couldn't add font like you did with that image
– stan liu
Sep 8 '16 at 4:38
3
For me this was the issue, the font MUST be installed in the system (ie. Font Book) before it can be embedded in the application. This seems ridiculous, but I'm assuming the explanation is so you can use it in Interface Builder, but even if you only create the font in code, it needs to be installed in Font Book initially, then you can remove it if you want to. And Apple does not mention any of that on the page for how to embed fonts in your app so it is very confusing. Also, for macOS, I'm using the plist key "Fonts Provided By Application" and not "Application fonts resource path".
– Ben Stahl
Mar 1 at 19:41
|
show 11 more comments
I think i get crazy! I done this, exactly like you said , but , nothing . Added font is not present in font list.
– C-Viorel
Dec 29 '14 at 7:06
Can you send me the font link? The problem might be with the Font selected. Have you tried with another font ?
– Leo Dabus
Dec 29 '14 at 7:07
2
Application fonts resource path is a string type and I can't add array of strings
– myatmins
Jun 11 '16 at 20:28
2
hi, what if Application fonts resource path is a string not a array, I couldn't add font like you did with that image
– stan liu
Sep 8 '16 at 4:38
3
For me this was the issue, the font MUST be installed in the system (ie. Font Book) before it can be embedded in the application. This seems ridiculous, but I'm assuming the explanation is so you can use it in Interface Builder, but even if you only create the font in code, it needs to be installed in Font Book initially, then you can remove it if you want to. And Apple does not mention any of that on the page for how to embed fonts in your app so it is very confusing. Also, for macOS, I'm using the plist key "Fonts Provided By Application" and not "Application fonts resource path".
– Ben Stahl
Mar 1 at 19:41
I think i get crazy! I done this, exactly like you said , but , nothing . Added font is not present in font list.
– C-Viorel
Dec 29 '14 at 7:06
I think i get crazy! I done this, exactly like you said , but , nothing . Added font is not present in font list.
– C-Viorel
Dec 29 '14 at 7:06
Can you send me the font link? The problem might be with the Font selected. Have you tried with another font ?
– Leo Dabus
Dec 29 '14 at 7:07
Can you send me the font link? The problem might be with the Font selected. Have you tried with another font ?
– Leo Dabus
Dec 29 '14 at 7:07
2
2
Application fonts resource path is a string type and I can't add array of strings
– myatmins
Jun 11 '16 at 20:28
Application fonts resource path is a string type and I can't add array of strings
– myatmins
Jun 11 '16 at 20:28
2
2
hi, what if Application fonts resource path is a string not a array, I couldn't add font like you did with that image
– stan liu
Sep 8 '16 at 4:38
hi, what if Application fonts resource path is a string not a array, I couldn't add font like you did with that image
– stan liu
Sep 8 '16 at 4:38
3
3
For me this was the issue, the font MUST be installed in the system (ie. Font Book) before it can be embedded in the application. This seems ridiculous, but I'm assuming the explanation is so you can use it in Interface Builder, but even if you only create the font in code, it needs to be installed in Font Book initially, then you can remove it if you want to. And Apple does not mention any of that on the page for how to embed fonts in your app so it is very confusing. Also, for macOS, I'm using the plist key "Fonts Provided By Application" and not "Application fonts resource path".
– Ben Stahl
Mar 1 at 19:41
For me this was the issue, the font MUST be installed in the system (ie. Font Book) before it can be embedded in the application. This seems ridiculous, but I'm assuming the explanation is so you can use it in Interface Builder, but even if you only create the font in code, it needs to be installed in Font Book initially, then you can remove it if you want to. And Apple does not mention any of that on the page for how to embed fonts in your app so it is very confusing. Also, for macOS, I'm using the plist key "Fonts Provided By Application" and not "Application fonts resource path".
– Ben Stahl
Mar 1 at 19:41
|
show 11 more comments
As "Application fonts resource path" is now a string type in XCode 7.3.1 and I couldn't seem to find a way to use an Array for multiple fonts, I used "." in the Info.plist:
Application fonts resource path String .
and this seemed to work to pick up all my custom fonts in a Resources folder dynamically e.g. using Swift
labelText.font = NSFont(name: "DS-Digital", size: 48)
However, to see it in XCode design mode (to choose a font from drop-down menu), I needed to first add the font to Font Book.
However, Font Book was not required for the dynamic method to work :)
This solution saved me!! Thanks
– Silviu St
Oct 23 '16 at 15:16
this is not working for me any other solution ??
– Devang
Jan 11 '17 at 10:01
"." is working for me.
– R0CKSTAR
Feb 15 '17 at 3:37
Also found if you place the fonts into a folder, say "Fonts", you can use "Fonts" for the string value.
– R0CKSTAR
Feb 15 '17 at 3:48
add a comment |
As "Application fonts resource path" is now a string type in XCode 7.3.1 and I couldn't seem to find a way to use an Array for multiple fonts, I used "." in the Info.plist:
Application fonts resource path String .
and this seemed to work to pick up all my custom fonts in a Resources folder dynamically e.g. using Swift
labelText.font = NSFont(name: "DS-Digital", size: 48)
However, to see it in XCode design mode (to choose a font from drop-down menu), I needed to first add the font to Font Book.
However, Font Book was not required for the dynamic method to work :)
This solution saved me!! Thanks
– Silviu St
Oct 23 '16 at 15:16
this is not working for me any other solution ??
– Devang
Jan 11 '17 at 10:01
"." is working for me.
– R0CKSTAR
Feb 15 '17 at 3:37
Also found if you place the fonts into a folder, say "Fonts", you can use "Fonts" for the string value.
– R0CKSTAR
Feb 15 '17 at 3:48
add a comment |
As "Application fonts resource path" is now a string type in XCode 7.3.1 and I couldn't seem to find a way to use an Array for multiple fonts, I used "." in the Info.plist:
Application fonts resource path String .
and this seemed to work to pick up all my custom fonts in a Resources folder dynamically e.g. using Swift
labelText.font = NSFont(name: "DS-Digital", size: 48)
However, to see it in XCode design mode (to choose a font from drop-down menu), I needed to first add the font to Font Book.
However, Font Book was not required for the dynamic method to work :)
As "Application fonts resource path" is now a string type in XCode 7.3.1 and I couldn't seem to find a way to use an Array for multiple fonts, I used "." in the Info.plist:
Application fonts resource path String .
and this seemed to work to pick up all my custom fonts in a Resources folder dynamically e.g. using Swift
labelText.font = NSFont(name: "DS-Digital", size: 48)
However, to see it in XCode design mode (to choose a font from drop-down menu), I needed to first add the font to Font Book.
However, Font Book was not required for the dynamic method to work :)
answered Aug 19 '16 at 13:30
Chris Payne
19114
19114
This solution saved me!! Thanks
– Silviu St
Oct 23 '16 at 15:16
this is not working for me any other solution ??
– Devang
Jan 11 '17 at 10:01
"." is working for me.
– R0CKSTAR
Feb 15 '17 at 3:37
Also found if you place the fonts into a folder, say "Fonts", you can use "Fonts" for the string value.
– R0CKSTAR
Feb 15 '17 at 3:48
add a comment |
This solution saved me!! Thanks
– Silviu St
Oct 23 '16 at 15:16
this is not working for me any other solution ??
– Devang
Jan 11 '17 at 10:01
"." is working for me.
– R0CKSTAR
Feb 15 '17 at 3:37
Also found if you place the fonts into a folder, say "Fonts", you can use "Fonts" for the string value.
– R0CKSTAR
Feb 15 '17 at 3:48
This solution saved me!! Thanks
– Silviu St
Oct 23 '16 at 15:16
This solution saved me!! Thanks
– Silviu St
Oct 23 '16 at 15:16
this is not working for me any other solution ??
– Devang
Jan 11 '17 at 10:01
this is not working for me any other solution ??
– Devang
Jan 11 '17 at 10:01
"." is working for me.
– R0CKSTAR
Feb 15 '17 at 3:37
"." is working for me.
– R0CKSTAR
Feb 15 '17 at 3:37
Also found if you place the fonts into a folder, say "Fonts", you can use "Fonts" for the string value.
– R0CKSTAR
Feb 15 '17 at 3:48
Also found if you place the fonts into a folder, say "Fonts", you can use "Fonts" for the string value.
– R0CKSTAR
Feb 15 '17 at 3:48
add a comment |
ATSApplicationFontsPath
is for macOS:
ATSApplicationFontsPath (
String
- macOS) identifies the location of a
font file or directory of fonts in the bundle’s Resources directory.
If present, macOS activates the fonts at the specified path for use by
the bundled app. The fonts are activated only for the bundled app and
not for the system as a whole. The path itself should be specified as
a relative directory of the bundle’s Resources directory. For example,
if a directory of fonts was at the path
/Applications/MyApp.app/Contents/Resources/Stuff/MyFonts/, you should
specify the string Stuff/MyFonts/ for the value of this key.
macOS app Instructions:
- Select your Xcode project in the project navigator
- Select your
app target
- Click the + button and to add a New Copy Files Phase
- Select Resources for the destination
- Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.
- Drag and drop the font files into the file list of the Copy Files build phase.
UIAppFonts
is for iOS:
UIAppFonts (
Array
- iOS) Specifies any app-provided fonts that should
be made available through the normal mechanisms. Each item in the
array is a string containing the name of a font file (including
filename extension) that is located in the app’s bundle. The system
loads the specified fonts and makes them available for use by the app
when that app is run.
This key is supported in iOS 3.2 and later.
add a comment |
ATSApplicationFontsPath
is for macOS:
ATSApplicationFontsPath (
String
- macOS) identifies the location of a
font file or directory of fonts in the bundle’s Resources directory.
If present, macOS activates the fonts at the specified path for use by
the bundled app. The fonts are activated only for the bundled app and
not for the system as a whole. The path itself should be specified as
a relative directory of the bundle’s Resources directory. For example,
if a directory of fonts was at the path
/Applications/MyApp.app/Contents/Resources/Stuff/MyFonts/, you should
specify the string Stuff/MyFonts/ for the value of this key.
macOS app Instructions:
- Select your Xcode project in the project navigator
- Select your
app target
- Click the + button and to add a New Copy Files Phase
- Select Resources for the destination
- Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.
- Drag and drop the font files into the file list of the Copy Files build phase.
UIAppFonts
is for iOS:
UIAppFonts (
Array
- iOS) Specifies any app-provided fonts that should
be made available through the normal mechanisms. Each item in the
array is a string containing the name of a font file (including
filename extension) that is located in the app’s bundle. The system
loads the specified fonts and makes them available for use by the app
when that app is run.
This key is supported in iOS 3.2 and later.
add a comment |
ATSApplicationFontsPath
is for macOS:
ATSApplicationFontsPath (
String
- macOS) identifies the location of a
font file or directory of fonts in the bundle’s Resources directory.
If present, macOS activates the fonts at the specified path for use by
the bundled app. The fonts are activated only for the bundled app and
not for the system as a whole. The path itself should be specified as
a relative directory of the bundle’s Resources directory. For example,
if a directory of fonts was at the path
/Applications/MyApp.app/Contents/Resources/Stuff/MyFonts/, you should
specify the string Stuff/MyFonts/ for the value of this key.
macOS app Instructions:
- Select your Xcode project in the project navigator
- Select your
app target
- Click the + button and to add a New Copy Files Phase
- Select Resources for the destination
- Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.
- Drag and drop the font files into the file list of the Copy Files build phase.
UIAppFonts
is for iOS:
UIAppFonts (
Array
- iOS) Specifies any app-provided fonts that should
be made available through the normal mechanisms. Each item in the
array is a string containing the name of a font file (including
filename extension) that is located in the app’s bundle. The system
loads the specified fonts and makes them available for use by the app
when that app is run.
This key is supported in iOS 3.2 and later.
ATSApplicationFontsPath
is for macOS:
ATSApplicationFontsPath (
String
- macOS) identifies the location of a
font file or directory of fonts in the bundle’s Resources directory.
If present, macOS activates the fonts at the specified path for use by
the bundled app. The fonts are activated only for the bundled app and
not for the system as a whole. The path itself should be specified as
a relative directory of the bundle’s Resources directory. For example,
if a directory of fonts was at the path
/Applications/MyApp.app/Contents/Resources/Stuff/MyFonts/, you should
specify the string Stuff/MyFonts/ for the value of this key.
macOS app Instructions:
- Select your Xcode project in the project navigator
- Select your
app target
- Click the + button and to add a New Copy Files Phase
- Select Resources for the destination
- Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.
- Drag and drop the font files into the file list of the Copy Files build phase.
UIAppFonts
is for iOS:
UIAppFonts (
Array
- iOS) Specifies any app-provided fonts that should
be made available through the normal mechanisms. Each item in the
array is a string containing the name of a font file (including
filename extension) that is located in the app’s bundle. The system
loads the specified fonts and makes them available for use by the app
when that app is run.
This key is supported in iOS 3.2 and later.
edited Aug 3 at 5:04
answered Aug 3 at 4:55
Andrew
6,31433243
6,31433243
add a comment |
add a comment |
Try doing this from the interface builder, in the attributes inspector .
From IB i have access only to installed system fonts. I want to load my own font.
– C-Viorel
Dec 28 '14 at 21:57
1
In IB ,attributes inspector (font line) click the "T" and click font then custom. If you want (ex MyFont), first you have to loaded into OS X(Font Book) ,then you can select your font.Sorry for my bad english .
– Name
Dec 28 '14 at 22:05
but that resolve the problem just for me . if i install a .ttf font in fontBook i can use it very easy, but , then every user who use my app needs to install that font, and i am pretty sure about one thing : User is lazy.
– C-Viorel
Dec 28 '14 at 22:12
1
First you need to put your font in the project and use ATSApplicationFontsPath key in the info.plist .More info developer.apple.com/library/mac/documentation/General/Reference/…
– Name
Dec 28 '14 at 22:25
Application fonts resource path is the new key name for ATSApplicationFontsPath, so i already did that, but , is possible to do it wrong.
– C-Viorel
Dec 28 '14 at 22:30
|
show 2 more comments
Try doing this from the interface builder, in the attributes inspector .
From IB i have access only to installed system fonts. I want to load my own font.
– C-Viorel
Dec 28 '14 at 21:57
1
In IB ,attributes inspector (font line) click the "T" and click font then custom. If you want (ex MyFont), first you have to loaded into OS X(Font Book) ,then you can select your font.Sorry for my bad english .
– Name
Dec 28 '14 at 22:05
but that resolve the problem just for me . if i install a .ttf font in fontBook i can use it very easy, but , then every user who use my app needs to install that font, and i am pretty sure about one thing : User is lazy.
– C-Viorel
Dec 28 '14 at 22:12
1
First you need to put your font in the project and use ATSApplicationFontsPath key in the info.plist .More info developer.apple.com/library/mac/documentation/General/Reference/…
– Name
Dec 28 '14 at 22:25
Application fonts resource path is the new key name for ATSApplicationFontsPath, so i already did that, but , is possible to do it wrong.
– C-Viorel
Dec 28 '14 at 22:30
|
show 2 more comments
Try doing this from the interface builder, in the attributes inspector .
Try doing this from the interface builder, in the attributes inspector .
answered Dec 28 '14 at 21:55
Name
17918
17918
From IB i have access only to installed system fonts. I want to load my own font.
– C-Viorel
Dec 28 '14 at 21:57
1
In IB ,attributes inspector (font line) click the "T" and click font then custom. If you want (ex MyFont), first you have to loaded into OS X(Font Book) ,then you can select your font.Sorry for my bad english .
– Name
Dec 28 '14 at 22:05
but that resolve the problem just for me . if i install a .ttf font in fontBook i can use it very easy, but , then every user who use my app needs to install that font, and i am pretty sure about one thing : User is lazy.
– C-Viorel
Dec 28 '14 at 22:12
1
First you need to put your font in the project and use ATSApplicationFontsPath key in the info.plist .More info developer.apple.com/library/mac/documentation/General/Reference/…
– Name
Dec 28 '14 at 22:25
Application fonts resource path is the new key name for ATSApplicationFontsPath, so i already did that, but , is possible to do it wrong.
– C-Viorel
Dec 28 '14 at 22:30
|
show 2 more comments
From IB i have access only to installed system fonts. I want to load my own font.
– C-Viorel
Dec 28 '14 at 21:57
1
In IB ,attributes inspector (font line) click the "T" and click font then custom. If you want (ex MyFont), first you have to loaded into OS X(Font Book) ,then you can select your font.Sorry for my bad english .
– Name
Dec 28 '14 at 22:05
but that resolve the problem just for me . if i install a .ttf font in fontBook i can use it very easy, but , then every user who use my app needs to install that font, and i am pretty sure about one thing : User is lazy.
– C-Viorel
Dec 28 '14 at 22:12
1
First you need to put your font in the project and use ATSApplicationFontsPath key in the info.plist .More info developer.apple.com/library/mac/documentation/General/Reference/…
– Name
Dec 28 '14 at 22:25
Application fonts resource path is the new key name for ATSApplicationFontsPath, so i already did that, but , is possible to do it wrong.
– C-Viorel
Dec 28 '14 at 22:30
From IB i have access only to installed system fonts. I want to load my own font.
– C-Viorel
Dec 28 '14 at 21:57
From IB i have access only to installed system fonts. I want to load my own font.
– C-Viorel
Dec 28 '14 at 21:57
1
1
In IB ,attributes inspector (font line) click the "T" and click font then custom. If you want (ex MyFont), first you have to loaded into OS X(Font Book) ,then you can select your font.Sorry for my bad english .
– Name
Dec 28 '14 at 22:05
In IB ,attributes inspector (font line) click the "T" and click font then custom. If you want (ex MyFont), first you have to loaded into OS X(Font Book) ,then you can select your font.Sorry for my bad english .
– Name
Dec 28 '14 at 22:05
but that resolve the problem just for me . if i install a .ttf font in fontBook i can use it very easy, but , then every user who use my app needs to install that font, and i am pretty sure about one thing : User is lazy.
– C-Viorel
Dec 28 '14 at 22:12
but that resolve the problem just for me . if i install a .ttf font in fontBook i can use it very easy, but , then every user who use my app needs to install that font, and i am pretty sure about one thing : User is lazy.
– C-Viorel
Dec 28 '14 at 22:12
1
1
First you need to put your font in the project and use ATSApplicationFontsPath key in the info.plist .More info developer.apple.com/library/mac/documentation/General/Reference/…
– Name
Dec 28 '14 at 22:25
First you need to put your font in the project and use ATSApplicationFontsPath key in the info.plist .More info developer.apple.com/library/mac/documentation/General/Reference/…
– Name
Dec 28 '14 at 22:25
Application fonts resource path is the new key name for ATSApplicationFontsPath, so i already did that, but , is possible to do it wrong.
– C-Viorel
Dec 28 '14 at 22:30
Application fonts resource path is the new key name for ATSApplicationFontsPath, so i already did that, but , is possible to do it wrong.
– C-Viorel
Dec 28 '14 at 22:30
|
show 2 more comments
By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.
add a comment |
By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.
add a comment |
By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.
By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.
answered Feb 17 at 7:57
Kelin Sasha
225
225
add a comment |
add a comment |
For those whose font family is called something like My-Custom-Font-Family:
be aware that in code you should instantiate your custom font like this: NSFont(name: "MyCustomFontFamily-Bold", size: 20)
Spaces and "-" are ignored and font type is written after "-". I did not see this in any docs and spend a few hours trying to figure out wtf was wrong.
Also if you want to get list of all available fonts you can use this code
for font in NSFontManager.shared.availableFonts {
print(font)
}
add a comment |
For those whose font family is called something like My-Custom-Font-Family:
be aware that in code you should instantiate your custom font like this: NSFont(name: "MyCustomFontFamily-Bold", size: 20)
Spaces and "-" are ignored and font type is written after "-". I did not see this in any docs and spend a few hours trying to figure out wtf was wrong.
Also if you want to get list of all available fonts you can use this code
for font in NSFontManager.shared.availableFonts {
print(font)
}
add a comment |
For those whose font family is called something like My-Custom-Font-Family:
be aware that in code you should instantiate your custom font like this: NSFont(name: "MyCustomFontFamily-Bold", size: 20)
Spaces and "-" are ignored and font type is written after "-". I did not see this in any docs and spend a few hours trying to figure out wtf was wrong.
Also if you want to get list of all available fonts you can use this code
for font in NSFontManager.shared.availableFonts {
print(font)
}
For those whose font family is called something like My-Custom-Font-Family:
be aware that in code you should instantiate your custom font like this: NSFont(name: "MyCustomFontFamily-Bold", size: 20)
Spaces and "-" are ignored and font type is written after "-". I did not see this in any docs and spend a few hours trying to figure out wtf was wrong.
Also if you want to get list of all available fonts you can use this code
for font in NSFontManager.shared.availableFonts {
print(font)
}
answered Nov 20 at 17:16
Mike.P
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27680893%2fhow-to-use-custom-fonts-in-a-mac-application%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
From another SO answer (sorry can't find it now): the name string can be found by opening the font in Font Book and using the string next to
PostScript name
that's shown in the inspector pane.– Todd
Nov 21 at 17:04