• 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: What's wrong with this font thing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's wrong with this font thing?


  • Subject: Re: What's wrong with this font thing?
  • From: Aki Inoue <email@hidden>
  • Date: Wed, 29 Oct 2008 17:05:42 -0700

The "threshold" being discussed here is the boundary between the screen font vs printer font in NSFont jargon.

For font size smaller than 16pt, we automatically substitute the default printer font to its corresponding screen font.
The metrics gap is caused by the substitution.


You can disable the auto-substitution with NSStringDrawingDisableScreenFontSubstitution flag.

When you change the scale/font size, the baseline shifts naturally when you layout from the top.
In order to keep it fixed at the baseline, you need to layout/render on it.
-drawInRect:withAttributes: always render from the top.


To render with the baseline, use -drawWithRect:options:attributes:.

Aki

On 2008/10/29, at 16:37, Randall Meadows wrote:

On Oct 29, 2008, at 5:15 PM, Peter Ammon wrote:

Trying to find the right font size to just fit the text seems a bit archaic. Here is a different approach:

- Measure the string with some font
- Divide the space available by the measured width to find the scale factor
- Use CGContextScaleCTM() to apply the scale to the current transform
- Draw the string with that font. It will scale nicely and fit into the available space.

Doing that also shifts the rect that I'm trying to draw into. I'm doing multiple NSString drawInRect:withAttributes: calls, all within a single view.
_______________________________________________


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: What's wrong with this font thing?
      • From: Randall Meadows <email@hidden>
References: 
 >What's wrong with this font thing? (From: Randall Meadows <email@hidden>)
 >Re: What's wrong with this font thing? (From: Peter Ammon <email@hidden>)
 >Re: What's wrong with this font thing? (From: Randall Meadows <email@hidden>)

  • Prev by Date: Re: What's wrong with this font thing?
  • Next by Date: Re: NSTableColumn unbindable when NSSegmentedCell is used?
  • Previous by thread: Re: What's wrong with this font thing?
  • Next by thread: Re: What's wrong with this font thing?
  • Index(es):
    • Date
    • Thread