• 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
font metrics vs layout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

font metrics vs layout


  • Subject: font metrics vs layout
  • From: Dale Miller <email@hidden>
  • Date: Tue, 12 Dec 2006 16:24:18 -0700

I wish to create an NSTextView (subclass) using any ONE of the available FIXED-PITCH fonts (No kerning, no ligatures). I need to be able to pre-calculate the character cell used in layout in order to size the view/scroll view based on the number of rows and columns desired. I have been able to obtain all the font metrics and default line height, but I can't make sense of how they are used/misused by the Apple text machine. I have gone through the exercise of comparing for several different fonts, the font metrics with the character cell used in layout ( as returned by "rectArrayforCharacterRange:..." of layoutmanager. For font sizes of 10,12,14, and 16, the cell returned has integral dimensions, but not for font size 18. The bounding box, advancement, etc. measurements returned for the font metrics are all non-integral values and do not in any combination (including those in Apple's "conceptual" documentation) combine to get the integral values returned from the "rectArray" or other methods.
In addition, to get these values, I have to actually set up all of the text system (except for the views) and layout at least one character. The AppKit NSString "sizewithAttributes" method returns a height which is several pixels greater than the "defaultLineHeight" method.
Let me restate the questions:
1) Am I missing something that would enable me to get the dimensions of the character cell (this might not be the correct typographic term) without having to go to such great lengths (for fixed-pitch, non-kerned, no ligatures) ?
2) It appears that for 10-,12-,14-, and 16- point fonts, the metrics (ascender+descender+leading, and maximum advancement) are just rounded to get the character cell, except that this fails for the 18- point font.) What's the idea?
3) Obviously, the text machine is making a programmed decision on how to lay out the text, as far as line height and character advancement. Is it possible to get the algorithm (or a description of it)?
Thanks,


Dale Miller
dalelmiller  /at/  cableone.net



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Prev by Date: Announcing CocoaICU
  • Next by Date: [Q] Windows code page list?
  • Previous by thread: Re: Announcing CocoaICU
  • Next by thread: [Q] Windows code page list?
  • Index(es):
    • Date
    • Thread