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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:40:44+00:00 2026-06-01T22:40:44+00:00

Several posts have noted difficulties with getting an exact height out of CTFramesetterSuggestFrameSizeWithConstraints, and

  • 0

Several posts have noted difficulties with getting an exact height out of CTFramesetterSuggestFrameSizeWithConstraints, and here, (framesetter post), @Chris DeSalvo gives what looks like the definitive fix: add a paragraph style setting with the correct line spacing adjustment.

DeSalvo gets his “leading” by removing UIFont’s ascender and descender from its lineHeight. I wondered how that would compare to CTFontGetLeading.

I worked with fonts created like this:

CTFontRef fontr = CTFontCreateWithName((CFStringRef)@"Helvetica Neue", 16.0f, NULL);
UIFont *font = [UIFont fontWithName:@"Helvetica Neue" size:16.0f];

The values were quite different:

  • 0.448 CTFontGetLeading
  • 2.360 DeSalvo’s formula: UIFont lineHeight – ascender + descender

Here are some other UIFont values:

  • 21.000 UIFont’s lineHeight
  • 15.232 UIFont’s ascender (Y coord from baseline)
  • -3.408 UIFont’s descender (Y coord from baseline)
  • 08.368 UIFont’s xHeight

And here are the CTFont values that Ken Thomases inquired about:

  • 11.568001 CTFontGetCapHeight
  • 08.368 CTFontGetXHeight
  • -15.216001, -7.696001, 38.352001, 24.928001 CTFontGetBoundingBox
  • 15.232 CTFontGetAscent
  • 03.408 CTFontGetDescent (class ref says “scaled font-descent metric scaled according to the point size and matrix of the font reference” — which apparently means that it is the absolute value of the Y coordinate from the baseline?)

I note that UIFont previously had a property specifically for “leading,” but it has been deprecated and we are advised to use lineHeight instead. So UIFont considers leading to be 21 and CTFontRef .448 for the same font? Something’s not right.

Three questions:

  1. Is “leading” really what is meant by kCTParagraphStyleSpecifierLineSpacingAdjustment?
  2. If so, which method/formula should I use to get it?
  3. If not, what should I use for the line spacing adjustment?
  • 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-01T22:40:45+00:00Added an answer on June 1, 2026 at 10:40 pm

    Answers to the 3 questions I had above:

    1. Yes, “leading” really what is meant by kCTParagraphStyleSpecifierLineSpacingAdjustment. Or at any rate, it works as expected.
    2. Use CTFontGetLeading(fontRef) to get the font’s normal leading, or plug in whatever value (as a CGFloat) you choose.
    3. N/A.

    Answers 1 and 2 work: Specifying a leading value in a paragraphStyle attribute of your attributed string will enable the Core-Text framesetter to calculate its height exactly.

    There are two caveats:

    1. If you try to calculate heights incrementally, one string at a time, each string containing an initial line break, framesetter will consider that line break to represent an entire line, not just the leading. If you want the height of the concatenated strings, you have to feed that concatenation to the framesetter. Of course, you could keep track of the incremental height differences, but there’s no way to avoid having framesetter recalculate the earlier string dimensions.
    2. CATextLayer ignores spacing adjustments (and other attributes). If framing per exact string height is an issue, you must draw direct to a CALayer.

    And there is one mystery: What is going on with UIFont’s deprecated leading? Leading and lineHeight are two distinct things.

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

Sidebar

Related Questions

I have a question about the exit button. I have read several posts on
I have found several posts on SO talking about deploying web projects with git.
I have read several posts where users were having this same issue. When compiled,
From several posts inside stackoverflow and outside, I have come to know how to
I have tried several things but I can't get the MySQL query in my
THE INFO Currently I have two tables I am working with- a POST table
I have several huge arrays (millions++ members). All those are arrays of numbers and
I have a two forms on a page. The first one has several quantity
I have a form with several input fields, i would like to go through
This is my first post, so I'm just getting to know how the community

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.