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

  • Home
  • SEARCH
  • 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 9213885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:51:10+00:00 2026-06-18T01:51:10+00:00

CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL); NSRange rangeHighlight = NSMakeRange(range.location, substringToHighlight.length); if (font)

  • 0
    CTFontRef font = CTFontCreateWithName((__bridge  CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL);
    NSRange  rangeHighlight = NSMakeRange(range.location, substringToHighlight.length);
    if (font) {
        [mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(__bridge  id)font range:rangeHighlight];
        CFRelease(font); //Is this still necessary?
    }

I copy and paste this code from https://github.com/mattt/TTTAttributedLabel

  CTFontRef font = CTFontCreateWithName((CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL);
  if (font) {
    [mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(id)font range:boldRange];
    [mutableAttributedString addAttribute:@"TTTStrikeOutAttribute" value:[NSNumber numberWithBool:YES] range:strikeRange];
    CFRelease(font);
  }

When I do that I got an error saying that I got to use the keyword __bridge. What is it? I put it and compile error stop. But then I wonder if I still need to use CFRelease(font)

In addition

  1. What is CF in CFRelease?
  2. What is __bridge?
  3. Should I do CFRelease(font) after using __bridge?
  4. Where can I learn more about this?
  • 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-06-18T01:51:11+00:00Added an answer on June 18, 2026 at 1:51 am

    Yes you still need to use CFRelease(font).

    You are still the one creating the font so you need to release it as well. The __bridge part is related to how the font name is retained or not.

    1. CF is short for Core Foundation, the C level API that Foundation is built upon. CFRelease is how you release a Core Foundation object.

    2. __bridge tells ARC how it should retain or not retain an objects when translating it to a Core Foundation object. This question explains the different __bridge types.

    3. You should still release (explained above).

    4. Search for “Core Foundation”. The Design Concepts explains the general design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CTFontRef, how can i get the font name as a string?
I've a CTFontRef variable. CTFontRef aFontRef; Getting Size of Font was easy : CGFloat
For example is the following code memory safe? NSMutableAttributedString *str = ...; CTFontRef aFont
In iOS, you don't know the font file path(I mean, though you can see
I have downloaded a font from the internet. Now I want to Print the
The CTFontRef provides excellent method such as CTFontGetGlyphsForCharacters for mapping character(s) to glyph(s). My
I'm using a standard, modern singleton class with a singleton holding a CTFontRef, like
I have a CTFont that contains a font style, and sumbolic traits. I want
I'm trying to draw a custom string with color, font, size and alignment. I
There is old carbon code using FMGetFontFormat to determine if the Font is of

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.