• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Line spacing in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Line spacing in NSTextView


  • Subject: Re: Line spacing in NSTextView
  • From: Aki Inoue <email@hidden>
  • Date: Sat, 14 Feb 2009 19:58:21 -0800

Slava,

Calculating an optimal vertical layout is pretty involved. At least, the Cocoa Text System has sophisticated logic to determine the ideal layout because of the numerous and varying design target for different fonts.

For example, as you found out, many fonts designed in 80s have pretty tight ascent and zero leading.
Modern Asian fonts tend to have enormous leading (30 ~ 40% of ascent + descent).


The Text System encapsulates the logic to determine the ideal layout. It's not just queried from a font instance. It requires the context of an entire line.

If NSTextView is too abstract for your needs, you could use NSLayoutManager.
If NSLayoutManager proved to be still too abstract, you can integrate NSATSTypesetter into your text rendering engine.


NSATSTypesetter taps into the power of CoreText and still provides additional abstraction and functionalities (attachment, all the NSParagraphStyle attributes, etc).

Aki


Is there a way to compute what the default leading would be for a
font? This is for a Mac OS backend of a cross-platform GUI toolkit, so
I can't really just use NSTextView here.

Slava

On Fri, Feb 13, 2009 at 9:16 PM, Graham Cox <email@hidden> wrote:
Line spacing (or to be more precise, leading) is an attribute of the
paragraph style. This is added to the lineheight of the font as you have
calculated.


--Graham



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Line spacing in NSTextView
      • From: Slava Pestov <email@hidden>
References: 
 >Line spacing in NSTextView (From: Slava Pestov <email@hidden>)
 >Re: Line spacing in NSTextView (From: Graham Cox <email@hidden>)
 >Re: Line spacing in NSTextView (From: Slava Pestov <email@hidden>)

  • Prev by Date: Re: Line spacing in NSTextView
  • Next by Date: Re: Where to declare/initialise an NSOperationQueue
  • Previous by thread: Re: Line spacing in NSTextView
  • Next by thread: Re: Line spacing in NSTextView
  • Index(es):
    • Date
    • Thread