I'm writing custom widgets in Cocoa that display text and other types of objects (e.g. focus rings) with drop shadows.
The current text system in Cocoa, while it does render shadows, doesn't take the shadow into consideration when computing the string size.
For example, NSAttributedString's size method will return the same size for a particular string regardless of what shadow parameters it uses.
While I could argue that this is a bug, I can see where it could be trouble for the API to take the shadow into consideration. For example, multiple lines of text may have shadows such that there would be some overlap.
Having said that, I thought of doing my own workaround to ensure that the bounds I use to draw strings, etc. would take a shadow into account. If I don't, I either get clipping of the shadow, or spacing between various entities are not what I want.
Obviously, the shadow's offset can be used to increase the object's ultimate width and height; that one is easy.
But the blur radius got a bit tricky. I wrote a quick Cocoa app and ran it under 10.3.6. I noticed that the size of a shadow doesn't seem to rely upon the size of the object (e.g. thickness of a line). Also, it appears as if a blur radius of 8 is the maximum value one can use. Basically, my app allowed me to dynamically alter a shadow. I then took screenshots and analyzed them in Photoshop.
This leads me to the following equation for the amount of extra width and height an object (e.g. string) needs:
extraWidth = abs (shadowXOffset) + min (shadowBlur, 8);
extraHeight = abs (shadowYOffset) + min (shadowBlur, 8);
Is this correct? Can I bank on the fact that the shadow system is "limited" to 8 pixels/points? Is there a better method to query a shadow's rendering size?
Finally, if indeed the shadow is limited to 8 pixels of blur, won't this be a problem when wanting to scale up PDFs that contain shadows? I seem to remember scaling some in Preview.app where the "body" of my image would scale nicely, but any drop shadows would become kinda pixelated. It now makes sense that if the shadow is limited to a maximum of 8 shades of color (to represent the 8 pixels of blur), that things would get pixelated if those shades had to be used across a large area (e.g. 80 points/pixels).
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden