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 229671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:47:08+00:00 2026-05-11T19:47:08+00:00

Before I ask my questions, this is from Apple’s documentation re: how to determine

  • 0

Before I ask my questions, this is from Apple’s documentation re: how to determine the width of a string using Quartz:

If text measurements are important to your application, it is possible
to calculate them using Quartz 2D functions. However, you might first
consider using ATSUI, whose strength is in text layout and
measurement. ATSUI has several functions that obtain text metrics. Not
only can you obtain after-layout text metrics, but in the rare cases
you need them, you can obtain before-layout text metrics. Unlike
Quartz, for which you must perform the calculations yourself, ATSUI
computes the measurements for you. For example, you can obtain the
image bounding rectangle for text by calling the ATSUI function
ATSUMeasureTextImage.

If you decide that Quartz text suits your needs better than ATSUI (or
Cocoa), you can follow these steps to measure the width of text before
Quartz draws it:

  1. Call the function CGContextGetTextPosition to obtain the current text position.
  2. Set the text drawing mode to kCGTextInvisible using the function CGContextSetTextDrawingMode.
  3. Draw the text by calling the function CGContextShowText to draw the text at the current text position.
  4. Determine the final text position by calling the function CGContextGetTextPosition.
  5. Subtract the starting position from the ending position to determine the width of the text.

Here are my questions:

  1. Is this really the best way to determine the width of a string using Core Graphics? It seems flimsy and since my text co-exists with 2D graphical elements, I’d like to use the same context for all rendering. I was hoping there would be some compact method, like:

    CGContextGetTextWidthAndHeight(context, text);
    
  2. I read that ATSUI is outdated and going to be replaced by Core Text. Is that true and if so, is it in iOS?

  • 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-11T19:47:08+00:00Added an answer on May 11, 2026 at 7:47 pm

    On the iPhone SDK, there’s a family of methods on NSString that provide what you want.

    As of iOS 7.0, these methods are:

    - boundingRectWithSize:options:attributes:context:
    - sizeWithAttributes:
    

    On older versions of iOS we had these, now deprecated:

    – sizeWithFont:  
    – sizeWithFont:forWidth:lineBreakMode:  
    – sizeWithFont:constrainedToSize:  
    – sizeWithFont:constrainedToSize:lineBreakMode:  
    – sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ask this kind of question before, but it seems my previous question
Before I do this I figured I would ask if it was the best
I have a model Question with a field called userid , before one ask
Before I write my own I will ask all y'all. I'm looking for a
Before you answer this I have never developed anything popular enough to attain high
Before I start, I know there is this post and it doesn't answer my
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of
I have asked this question before and it seemed that the code I was
This seems like a simple question to ask but, is it generally a good
somewhat related to: libxml2 from java yes, this question is rather long-winded - sorry.

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.