how to get baseline info
how to get baseline info
- Subject: how to get baseline info
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 12 Sep 2011 15:35:13 +0700
I have a subclass of NSTextView which does:
- (void)setUpData
{
[ [ self textStorage ] setAttributedString: someAttributedString ]; // uses self.usedFont
NSLayoutManager *layoutManager = [ self layoutManager ];
baselineOffset = [ layoutManager defaultBaselineOffsetForFont: self.usedFont ];
lineHeight = [ layoutManager defaultLineHeightForFont: self.usedFont ];
}
- (void)drawRect:(NSRect)dirtyRect
{
[ super drawRect: dirtyRect ];
for( NSUInteger line = 0; line < NBR_OF_LINES; line++ )
{
CGFloat bax = lineHeight * line + baselineOffset;
[ [ NSColor blueColor ] set ]; // base line
[ NSBezierPath strokeLineFromPoint: NSMakePoint( NSMinX(dirtyRect), bax )
toPoint: NSMakePoint( NSMaxX(dirtyRect), bax )
];
};
}
This works, because currently all lines use the same font.
But how would I handle the more general case, where each line might contain several and/or different fonts?
Kind regards,
Gerriet.
_______________________________________________
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