• 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: Small caps in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Small caps in NSTextView


  • Subject: Re: Small caps in NSTextView
  • From: vincent habchi <email@hidden>
  • Date: Thu, 22 Jul 2010 19:07:42 +0200

Ross,

thanks a lot for your hints.

> Small caps is not a trivial thing to implement, especially if you care about how they look.

Not too much. I just want to dynamically highlight keywords in a SQL sentence (e.g. out of "select * from" -> "SELECT * FROM"). My present solution is to get the NSTextView string in the -(void)textDidChange: method of the delegate, then analyze the string. If I recognize a keyword, I replace it in the text by a [NSString uppercaseString] version with -(void)replaceCharactersInRange:WithString:

> Regarding modifying the text storage contents: the problem is not so much with changing text to small caps, but rather with changing it back. If you modify the  string to change Apple to APPLE, then you cannot know whether APPLE should be changed back to Apple or apple. This problem can be solved by subclassing NSGlyphGenerator to return an uppercase character if a custom SmallCaps attribute is present in the attributed string.

That's the problem. I tried to solve it by storing the original version and reverting to it if necessary, but it works only in the "current" token ("selec" -> "SELECT" -> "selecti" -> "SELECT" -> "selec"), and cannot be applied to already fully processed keywords. That's why I was looking to attributes, that do not modify text, and can be easily reverted.

I share your opinion about Small Caps, they look beautiful when properly printed. I used them from time to time in the settings of some articles of the magazine I am in care of, it's gorgeous, but in small amounts.

Cheers and thanks again,
Vincent_______________________________________________

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

References: 
 >Small caps in NSTextView (From: Vincent Habchi <email@hidden>)
 >Re: Small caps in NSTextView (From: Ross Carter <email@hidden>)

  • Prev by Date: Re: Small caps in NSTextView
  • Next by Date: Re: print object by %@
  • Previous by thread: Re: Small caps in NSTextView
  • Next by thread: Deselect keyboard focus of an NSMatrix cell
  • Index(es):
    • Date
    • Thread