Re: Fonts in TableView
Re: Fonts in TableView
- Subject: Re: Fonts in TableView
- From: Alastair Houghton <email@hidden>
- Date: Mon, 07 Nov 2016 09:43:05 +0000
On 6 Nov 2016, at 06:18, Quincey Morris <email@hidden> wrote:
>
> 5. It’s rather indeterminate what glyphs the bounding box should reflect. In particular, in digital typography using Unicode characters, a font as perceived by the user may be a composite of multiple actual fonts. For example, there’s likely code in the text system that provides a Euro glyph for every font that doesn’t have it.
What happens on macOS and iOS is that *all* characters that are out-of-repertoire are rendered using an alternative font automatically. By default, this uses the system default “font cascading list”, which is language specific. This isn’t specific to the Euro character (indeed, most modern fonts already have that glyph), but covers everything that can’t be found in the currently selected font.
> There is probably no perfect strategy that works for every font. However, for the kinds of design decisions that Apple made when it started doing typography properly (in the early 1990s, the days of the Font Wars between Apple and Microsoft), I recommend you use the following calculation to compute the line height of text:
>
> line height = font ascender + font descender + font leading
>
> using the 3 values reported by the NSFont. (I can’t remember, the descender may be negative, in which case you’d invert the sign.) Depending on your goals, you might also add some margin above and below the line height (1 or 2 points top and bottom) to prevent your rows from looking cramped.
You might also consider using NSLayoutManager’s -defaultLineHeightForFont: method, which does pretty much the above calculation - you can see exactly what it does in the following Stack Overflow post.
http://stackoverflow.com/questions/5511830/how-does-line-spacing-work-in-core-text-and-why-is-it-different-from-nslayoutm/5635981#5635981
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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