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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:28:49+00:00 2026-06-16T17:28:49+00:00

I’ve been looking for a solution for this one all day. I have 4

  • 0

I’ve been looking for a solution for this one all day.

I have 4 NSTextFields (actually subclassed for a few custom operations), which all share the same X position.

The problem is, some have different styles (light, regular, bold) and might have different sizes.

What happens is that, even though the X origin is the same, the 1st letter always has a bit of (consistently different) left margins.

Please see pic: https://dl.dropbox.com/u/1977230/Screen%20Shot%202012-12-11%20at%2017.55.58.png

I want to make sure that all lines start exactly at the same point, say 100px from the left.

Any idea how to override that weird padding?

Cheers

  • 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-16T17:28:51+00:00Added an answer on June 16, 2026 at 5:28 pm

    The margin you’re talking about I’m pretty sure is the lineFragmentPadding on the NSTextContainer that is used by the NSTextField.

    See the NSTextContainer reference:

    http://developer.apple.com/library/Mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextContainer_Class/Reference/Reference.html

    And here’s a page from the tutorial on Text Layout:

    https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TextLayout/Concepts/CalcTextLayout.html

    It states in that article:

    The typesetter makes one final adjustment when it actually fits text
    into the rectangle. This adjustment is a small amount fixed by the
    NSTextContainer object, called the line fragment padding, which
    defines the portion on each end of the line fragment rectangle left
    blank. Text is inset within the line fragment rectangle by this amount
    (the rectangle itself is unaffected). Padding allows for small-scale
    adjustment of the text container’s region at the edges and around any
    holes and keeps text from directly abutting any other graphics
    displayed near the region. You can change the padding from its default
    value with the setLineFragmentPadding: method. Note that line fragment
    padding isn’t a suitable means for expressing margins; you should set
    the NSTextView object’s position and size for document margins or the
    paragraph margin attributes for text margins.

    Unfortunately, it looks like NSTextField‘s NSTextContainer and NSLayoutManager are private and inaccessible, but it appears they are accessible in an NSTextView:

    https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextView_Class/Reference/Reference.html#//apple_ref/occ/cl/NSTextView

    So that may be the class you need to subclass if you want to have minute control over this kind of functionality.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have been unable to fix a problem with Java Unicode and encoding. The
Let's say I'm outputting a post title and in our database, it's Hello Y’all

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.