Drawing FULL NSAttributedString
Drawing FULL NSAttributedString
- Subject: Drawing FULL NSAttributedString
- From: "Rimas M." <email@hidden>
- Date: Wed, 27 Apr 2011 18:34:45 +0300
Hi folks,
Last few days I am trying to solve very strange puzzle - how to draw
FULL attributed string.
Short story:
I have a NSTextStorage object, which holds my formatted string
information. I am editing it via NSTextView (NSLayoutManager +
NSTextContainer + my NSTextStorage) mechanism. That works great until
I am dealing with drawing. To find out rect, which will be required to
fit my text, I am using -
(NSRect)usedRectForTextContainer:(NSTextContainer *)aTextContainer of
NSLayoutManager. To draw actual content I am using
drawBackgroundForGlyphRange:(NSRange)glyphsToShow
atPoint:(NSPoint)origin and
drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin
from the same NSLayoutManager. And that works great for 90% of time.
But I need 100%.
Problem:
Actually I am dealing with two drawing problems:
1. When my attributed string (NSTextStorage) has a shadow, made by
using Fonts panel, it is NOT INCLUDED when trying to find out used
rect by calling [myLayoutManager
usedRectForTextContainer:myTextContainer]. Never. The situation can be
easily demonstrated with TextEdit:
https://www.dropbox.com/s/vt21zpq46xl0gb5/Text-with-cropped-shadow.png
. The same I am getting in my app. But I need a shadow, therefor I
have set it. To draw it correctly, I need a bounding (used) rect,
which counts in a shadow attribute. Is it possible at all using cocoa
text system?
2. With some fonts (for example Eccentric Std, Palemonas, some others
which i can't remember right now) the [myLayoutManager
usedRectForTextContainer:myTextContainer] returns rect which does not
covers WHOLE text. Sometimes diacritic symbols of the very top line
are missing (https://www.dropbox.com/s/dpjjugzxcnp771r/Missing-diacrytic-symbol.png
<- both letters are the same "Alt + e + e = é" combination), sometimes
the first left symbol is cropped
(https://www.dropbox.com/s/33mfgoqwbgwcvg1/Cropped-left-side-1.png,
https://www.dropbox.com/s/kbgfdzuhcr1svht/Cropped-left-side-2.png,
https://www.dropbox.com/s/ntxgufl8e562uep/Cropped-left-side-3.png).
Question is the same - how to get rect, which would fit my whole text.
Any help is very appreciate.
p.s. don't hesitate to ask for an additional information. I could even
make a small sample app if required.
Regards,
Rimas M.
_______________________________________________
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