• 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
NSAttributedStrings and superscripts; scaling.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSAttributedStrings and superscripts; scaling.


  • Subject: NSAttributedStrings and superscripts; scaling.
  • From: Charlton Wilbur <email@hidden>
  • Date: Sun, 27 Feb 2005 17:36:46 -0500

All,

I have a string in my application UI that needs to have a superscript dagger in it. (This meaning is clear to the application's target audience, and so the dagger is not negotiable.) Problem 1: the Unicode dagger is a full-sized dagger. Solution 1: Use NSAttributedStrings. Problem 2: Font sizes.

Here's the code that mostly does the right thing. foundRange is the range containing the dagger character.

[attributedResult addAttribute: NSSuperscriptAttributeName value: [NSNumber numberWithInt: 1] range: foundRange];
NSFont *oldFont = [attributedResult attribute: NSFontAttributeName atIndex: foundRange.location effectiveRange: nil];
NSFont *newFont;


if (oldFont != nil)
newFont = [NSFont fontWithName: [oldFont familyName] size: [oldFont pointSize] * 0.6];
else
newFont = [NSFont systemFontOfSize: [NSFont systemFontSize] * 0.6];


[attributedResult addAttribute: NSFontAttributeName value: newFont range: foundRange];

The big issue is that in table views the 60% of system font size is considered absolute. In regular-size table views, this is not a problem; in mini and small table views, the rest of the font scales while the dagger does not, which leads to the original problem. Is there a way to specify the size of the dagger in a scalable fashion, or to explicitly scale the entire NSAttributedString in the table data source for those table views that are small? I'd really like to avoid passing a font and size parameter in, and I'd really like to avoid the necessity of making all my table views the same size.

Thanks,
Charlton

--
Charlton Wilbur
email@hidden
email@hidden

_______________________________________________
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: Why don't I get "control reaches end of non-void function" warnings?
  • Next by Date: Re: option-drag & Cocoa
  • Previous by thread: Re: Why don't I get "control reaches end of non-void function" warnings?
  • Next by thread: Where is plus arrow cursor?
  • Index(es):
    • Date
    • Thread