• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting displayName out of font file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting displayName out of font file


  • Subject: Re: Getting displayName out of font file
  • From: Ken Thomases <email@hidden>
  • Date: Fri, 26 Feb 2016 20:54:46 -0600

On Feb 26, 2016, at 7:17 AM, Gerriet M. Denkmann <email@hidden> wrote:
>
> On 26 Feb 2016, at 17:33, Ken Thomases <email@hidden> wrote:
>>
>> On Feb 26, 2016, at 4:16 AM, Gerriet M. Denkmann <email@hidden> wrote:
>>>
>>> I have a file “Some Font.ttf” and I want to know the displayName of this font, which might be “Some-Font” or “Nice Font” or anything else.
>>> Or nil if this is not a well-formatted font file.
>>> I do NOT want to install the font nor do anything with it.
>>>
>>> Short of reverse-engeneering the ttf format (which probably would be rather too much): is there a way to get this?
>>>
>>> Ideally I would line to do:
>>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>>> NSString *displayName = font.displayName;	//	font.fontName would probably also do
>>>
>>> but this seems not to exist.
>>
>> You can use CTFontManagerCreateFontDescriptorsFromURL() and then, for each descriptor, CTFontDescriptorCopyAttribute() with kCTFontDisplayNameAttribute.
>>
>> Keep in mind that you may get multiple descriptors because a font file may include multiple fonts.  Consequently, there may be multiple display names.
>
> Thanks a lot. Works perfectly.
> But did not find any font file which contains more than one descriptor. Any examples (for testing)?

Well, the very first thing I found in Font Book was the American Typewriter font family, which is in /Library/Fonts/AmericanTypewriter.ttc.  That's a TrueType font collection file, which contains various weights of the font.

There are also font suitcase files such as /System/Library/Fonts/Times.dfont.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Getting displayName out of font file
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >Getting displayName out of font file (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Getting displayName out of font file (From: Ken Thomases <email@hidden>)
 >Re: Getting displayName out of font file (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: NSURLErrorKey vs. NSURLErrorFailingURLErrorKey
  • Next by Date: Re: Getting displayName out of font file
  • Previous by thread: Re: Getting displayName out of font file
  • Next by thread: Re: Getting displayName out of font file
  • Index(es):
    • Date
    • Thread