• 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
NSAttributedString size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSAttributedString size


  • Subject: NSAttributedString size
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Wed, 15 Sep 2004 13:36:41 +0200

I tried to get the size of an attributed string.
But for font sizes ≤ 16.0 (Helvetica Regular) this method gives me the size of the corresponding screen font.


I have found two work-arounds:

1. [ myFont advancementForGlyph: [ myFont glyphWithName: [ myString substringWithRange: NSMakeRange( ii, 1 ) ]]];
and looping over all characters of my string. Paying attention for tabs, newlines etc.
Rather a lot of effort.
And one cannot be sure that a character and its glyph name are identical.
Also, the documentation says: "Glyph names in fonts do not always accurately identify the glyph".


2. getting a new font which is > 16.0 points and scaling the result back to the real font size.
This is not very nice, as (at least with fonts cast in lead) a 9.0 point font was different from 18.0 font scaled by 0.5.
But this seems not to be a problem with Helvetica.


Is there a method:
-(NSSize)sizeAllowingScreenFontSubstitution: (BOOL)flag ?
Or something similar?
Should something like this exist?

Gerriet.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: modifying self in init
  • Next by Date: build numbers
  • Previous by thread: Re: Get my application to be in the dock automatically.
  • Next by thread: build numbers
  • Index(es):
    • Date
    • Thread