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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:39:33+00:00 2026-05-30T05:39:33+00:00

I am having a trivial problem with applying proper top and bottom spacing for

  • 0

I am having a trivial problem with applying proper top and bottom spacing for the paragraphs in NSAttributedString. I am usng this code to set paragraph attributes:

int sf = sizeof(CGFloat);
        CTParagraphStyleSetting settings[ParagraphStylesSupported] = 
            {
                { kCTParagraphStyleSpecifierAlignment, sizeof(QuartzTextAlignment), &style.textAlignment },
                { kCTParagraphStyleSpecifierParagraphSpacingBefore, sf, &marginTop},
                { kCTParagraphStyleSpecifierParagraphSpacing, sf, &marginBot},
                { kCTParagraphStyleSpecifierMinimumLineHeight, sf, &lineHeight},

                { kCTParagraphStyleSpecifierLineSpacing, sf, &lineSpacing},
                { kCTParagraphStyleSpecifierFirstLineHeadIndent, sf, &style.firstLineIndent},

            };

            CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, ParagraphStylesSupported);


            [string addAttribute:(NSString*)kCTParagraphStyleAttributeName value:(id)paragraphStyle range:item.range];
            CFRelease(paragraphStyle);

Text properties are being applied as expected.
But there are few problems with paragraph alignment:

  1. Paragraphs are not being places after each other but flow ‘inline’ unless there is a newline \n character at the beginning of the attribute range.
  2. When I add the newline character, then paragraphs are being placed correctly one below another, but newline line height is being added to the spacing ‘ParagraphSpacing’ gaps.
  3. kCTParagraphStyleSpecifierParagraphSpacingBefore affects also the newlines character inside the paragraph range.

What Core Text layout engine interprets as a paragraph indicator?
Is it every newline character in the attributed string?

  • 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-30T05:39:35+00:00Added an answer on May 30, 2026 at 5:39 am

    In Core Text, the newline character (\n) ends a paragraph. I don’t think there is a way to tell it to use a different character.

    If you put two newlines in a row, then Core Text will act as if you have an empty paragraph, so it will put in extra spacing.

    Make sure you only have one newline after each paragraph. If your paragraphs still have too much space between them, you need to use a smaller value for kCTParagraphStyleSpecifierParagraphSpacingBefore or kCTParagraphStyleSpecifierParagraphSpacing (or both).

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

Sidebar

Related Questions

Having a brain freeze over a fairly trivial problem. If I start with an
This may be something common and trivial, but I seem to be having trouble
Having a problem getting a TreeView control to display node images. The code below
I'm having quite a frustrating problem that I'm sure is TRIVIAL. Whenever I move
I'm new to Grails, and having a problem that is no doubt trivial, but
I'm having an interesting but difficult problem with my JavaScript code. Basically, I'm trying
This should be a fairly trivial problem. I'm trying to open an ofstream using
This seems like a trivial problem, but my web searches for an answer (even
I have some trivial code that looks like this: SortedDictionary<String, long> d = new
I am trying to use boost lambda to avoid having to write trivial functors.

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.