How to use custom fonts in a mac application?












6














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)
}









share|improve this question
























  • 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


















6














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)
}









share|improve this question
























  • 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
















6












6








6


3





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)
}









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















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














6 Answers
6






active

oldest

votes


















2














First add the desired font you want to embed to your OSX app to your project:



enter image description here



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:



enter image description here



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.



enter image description here






share|improve this answer























  • 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



















19














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 :)






share|improve this answer





















  • 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



















2














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:




  1. Select your Xcode project in the project navigator

  2. Select your
    app target

  3. Click the + button and to add a New Copy Files Phase

  4. Select Resources for the destination

  5. Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.

  6. 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.







share|improve this answer































    1














    Try doing this from the interface builder, in the attributes inspector .






    share|improve this answer





















    • 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



















    0














    By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.



    1






    share|improve this answer





























      0














      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)
      }





      share|improve this answer





















        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
        });


        }
        });














        draft saved

        draft discarded


















        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









        2














        First add the desired font you want to embed to your OSX app to your project:



        enter image description here



        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:



        enter image description here



        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.



        enter image description here






        share|improve this answer























        • 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
















        2














        First add the desired font you want to embed to your OSX app to your project:



        enter image description here



        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:



        enter image description here



        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.



        enter image description here






        share|improve this answer























        • 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














        2












        2








        2






        First add the desired font you want to embed to your OSX app to your project:



        enter image description here



        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:



        enter image description here



        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.



        enter image description here






        share|improve this answer














        First add the desired font you want to embed to your OSX app to your project:



        enter image description here



        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:



        enter image description here



        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.



        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        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


















        • 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













        19














        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 :)






        share|improve this answer





















        • 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
















        19














        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 :)






        share|improve this answer





















        • 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














        19












        19








        19






        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 :)






        share|improve this answer












        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 :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        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


















        • 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











        2














        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:




        1. Select your Xcode project in the project navigator

        2. Select your
          app target

        3. Click the + button and to add a New Copy Files Phase

        4. Select Resources for the destination

        5. Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.

        6. 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.







        share|improve this answer




























          2














          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:




          1. Select your Xcode project in the project navigator

          2. Select your
            app target

          3. Click the + button and to add a New Copy Files Phase

          4. Select Resources for the destination

          5. Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.

          6. 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.







          share|improve this answer


























            2












            2








            2






            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:




            1. Select your Xcode project in the project navigator

            2. Select your
              app target

            3. Click the + button and to add a New Copy Files Phase

            4. Select Resources for the destination

            5. Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.

            6. 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.







            share|improve this answer














            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:




            1. Select your Xcode project in the project navigator

            2. Select your
              app target

            3. Click the + button and to add a New Copy Files Phase

            4. Select Resources for the destination

            5. Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.

            6. 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.








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 3 at 5:04

























            answered Aug 3 at 4:55









            Andrew

            6,31433243




            6,31433243























                1














                Try doing this from the interface builder, in the attributes inspector .






                share|improve this answer





















                • 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
















                1














                Try doing this from the interface builder, in the attributes inspector .






                share|improve this answer





















                • 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














                1












                1








                1






                Try doing this from the interface builder, in the attributes inspector .






                share|improve this answer












                Try doing this from the interface builder, in the attributes inspector .







                share|improve this answer












                share|improve this answer



                share|improve this answer










                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


















                • 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











                0














                By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.



                1






                share|improve this answer


























                  0














                  By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.



                  1






                  share|improve this answer
























                    0












                    0








                    0






                    By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.



                    1






                    share|improve this answer












                    By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.



                    1







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 17 at 7:57









                    Kelin Sasha

                    225




                    225























                        0














                        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)
                        }





                        share|improve this answer


























                          0














                          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)
                          }





                          share|improve this answer
























                            0












                            0








                            0






                            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)
                            }





                            share|improve this answer












                            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)
                            }






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 20 at 17:16









                            Mike.P

                            11




                            11






























                                draft saved

                                draft discarded




















































                                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.




                                draft saved


                                draft discarded














                                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





















































                                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







                                Popular posts from this blog

                                Costa Masnaga

                                Fotorealismo

                                Sidney Franklin