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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to