Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6380117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:13:34+00:00 2026-05-25T02:13:34+00:00

There is old carbon code using FMGetFontFormat to determine if the Font is of

  • 0

There is old carbon code using FMGetFontFormat to determine if the Font is of “True Type”. Since the API is deprecated, is there a way to find the same using CTFontRef. I used CTFontCopyAttribute, but it is returning CTTypeRef and i am not able to get the value? Any Suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:13:35+00:00Added an answer on May 25, 2026 at 2:13 am

    A CTTypeRef is a generic type. If you read the docs for the kCTFontFormatAttribute constant, they state:

    The value associated with this key is an integer represented as a
    CFNumberRef object containing one of the constants in “Font Format
    Constants.”

    That means that you need to treat the attribute as a number, which you can then convert to a short and check it against the known values for CTFontFormat:

    //get an array of all the available font names
    CFArrayRef fontFamilies = CTFontManagerCopyAvailableFontFamilyNames();
    
    //loop through the array
    for(CFIndex i = 0; i < CFArrayGetCount(fontFamilies); i++)
    {
        //get the current name
        CFStringRef fontName = CFArrayGetValueAtIndex(fontFamilies, i);
    
        //create a CTFont with the current font name
        CTFontRef font = CTFontCreateWithName(fontName, 12.0, NULL);
    
        //ask it for its font format attribute
        CFNumberRef fontFormat = CTFontCopyAttribute(font, kCTFontFormatAttribute);
    
        //release the font because we're done with it
        CFRelease(font);
    
        //if there is no format attribute just skip this one
        if(fontFormat == NULL)
        {
            NSLog(@"Could not determine the font format for font named %@.", fontName);
            continue;
        }
    
        //get the font format as a short
        SInt16 format;
        CFNumberGetValue(fontFormat, kCFNumberSInt16Type, &format);
    
        //release the number because we're done with it
        CFRelease(fontFormat);
    
        //create a human-readable string based on the format of the font
        NSString* formatName = nil;
        switch (format) {
            case kCTFontFormatOpenTypePostScript:
                formatName = @"OpenType PostScript";
                break;
            case kCTFontFormatOpenTypeTrueType:
                formatName = @"OpenType TrueType";
                break;
            case kCTFontFormatTrueType:
                formatName = @"TrueType";
                break;
            case kCTFontFormatPostScript:
                formatName = @"PostScript";
                break;
            case kCTFontFormatBitmap:
                formatName = @"Bitmap";
                break;
            case kCTFontFormatUnrecognized:
            default:
                formatName = @"Unrecognized";
                break;
        }
        NSLog(@"Font: '%@' Format: '%@'", fontName, formatName);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way in mercurial to remove old changesets from a database? I
Is there an easy way to compare the file tree of an old git
I'm refactoring some old JavaScript code and there's a lot of DOM manipulation going
I am visiting some old code, and there are quite a few events declared
I'm attempting to convert an old chunk of code containing the obsolete Carbon functions
There is some old legacy vbscript code we have that needs some sort of
There was this old game (J2ME) but I cannot find it now in google.
Here there's an old question about this code. xmpp.OnLogin += delegate(object o) { xmpp.Send(
There is two available Eclipse plugins for Maven : Eclipse IAM (old name is
Is there any documentation about introducing jBoss seam to an old Hibernate/JSF project? Have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.