• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
how to get baseline info
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: how to get baseline info
      • From: Aki Inoue <email@hidden>
  • Prev by Date: Avoid smooth scrolling when scrolling programmatically
  • Next by Date: NSScanner to find multiple occurrences of a prefix?
  • Previous by thread: Re: Avoid smooth scrolling when scrolling programmatically
  • Next by thread: Re: how to get baseline info
  • Index(es):
    • Date
    • Thread