Vertical positioning issue with drawStringInRect:withAttributes: in zoomed view
Vertical positioning issue with drawStringInRect:withAttributes: in zoomed view
- Subject: Vertical positioning issue with drawStringInRect:withAttributes: in zoomed view
- From: "Matt Gemmell" <email@hidden>
- Date: Wed, 7 Feb 2007 11:30:18 +0000
Hi folks,
I'm having an issue with drawing text using drawInRect:withAttributes:
when my view is zoomed. I include a link to a screenshot of the issue
below.
I'm implementing zooming for my NSView subclass using
-scaleUnitSquareToSize:, which works great. However, as usual there
are some things which I want to always draw at the same size on screen
regardless of the zoom factor (resize-handles on selected objects,
etc) including an overlay which shows the size of an object live
during drag-resizing. It's modelled from the Dashcode size-overlay
when dragging the Canvas area, incidentally.
This all works fine, except that when I'm drawing the actual string
containing the size, it doesn't draw at the same vertical position
within the rectangle I'm telling it to draw itself in. You can see the
issue here:
http://mattgemmell.com/images/scaled_string_drawing.png
The percentages are the zoom-factors applied to the view at the time I
took each screenshot. Notice how, even though the red rectangles are
all vertically-centered within the grey overlay, the text doesn't
actually draw at the same vertical position within those red
rectangles each time (note how it draws lower in the red area at 50%
zoom, and higher in the red area at 200% zoom).
This behaviour leads me to assume (perhaps incorrectly) that there's
something in the string-drawing attributes which isn't being suitably
scaled (the only thing I'm explicitly scaling at the moment is the
font-size).
I don't believe it's anything to do with the obvious NSParagraphStyle
properties (lineSpacing, paragraphSpacingBefore, and such), since they
all default to zero/unlimited values. The paragraph style I use is
+defaultParagraphStyle, but with NSRightTextAlignment (so that the
numbers show sensibly if one has more digits than the other), and with
NSLineBreakByWordWrapping.
Does anyone have any suggestions as to what could be happening?
Cheers,
-Matt
--
Matt Gemmell
mattgemmell.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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