• 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
underlining for misspelled words draws in the wrong place
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

underlining for misspelled words draws in the wrong place


  • Subject: underlining for misspelled words draws in the wrong place
  • From: Robert Clair <email@hidden>
  • Date: Wed, 23 Feb 2005 17:19:44 -0500

The text system seems to keep track of misspelling (when the "Check Spelling
as You Type" option is selected) by placing a temporary attribute of
NSSpellingState with a value of "1" on the characters in its text storage
that correspond to the misspelled word. This is by experiment with the
debugger - the archives, Google and the Apple web site are silent on
the matter of "NSSpellingState".


Who actually draws the underlining ? It seems to be something called
from within  -[NSLayoutManager  drawGlyphsForGlyphRange:atPoint:].

This is based on:

1) overriding -[NSLayoutManager temporaryAttributesAtCharacterIndex:effectiveRange:]
(which retrieves the temporary attributes)


2) placing a breakpoint in it and noticing it is only ever called from
-[NSLayoutManager drawGlyphsForGlyphRange:atPoint:] or stuff below it


3) changing the overridden routine to always return an empty dictionary and noticing that
the underlining of misspelled words goes away.


I use -[NSLayoutManager drawGlyphsForGlyphRange:atPoint:] with a transformed
coordinate system to display arbitrarily scaled, rotated and positioned text. The problem
is: the text is transformed as I expect, but the underlining isn't. It resolutely appears where
the text would be if I drew it without the transforms.



I'm not sure how this can happen but it seems to behave as if it were saving the context and setting
the transform to be the identity (actually identity then scaleYBy: -1 ).


An alternative is to leave the overridden -[NSLayoutManager temporaryAttributesAtCharacterIndex:effectiveRange:]
returning an empty dictionary to turn off the system's drawing and make my own routine
that would call [super temporaryAttributesAtCharacterIndex:effectiveRange:] to get the
attributes and draw them myself. This is rather unpleasant.


Anyone have any ideas ?

TIA


Bob Clair

_______________________________________________
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


  • Follow-Ups:
    • Re: underlining for misspelled words draws in the wrong place
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: Receiving notification of New or Open document?
  • Next by Date: Re: Recommendations for localization management
  • Previous by thread: Re: IB crash with custom binding
  • Next by thread: Re: underlining for misspelled words draws in the wrong place
  • Index(es):
    • Date
    • Thread