• 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
drawGlyphsForGlyphRange layout issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

drawGlyphsForGlyphRange layout issue


  • Subject: drawGlyphsForGlyphRange layout issue
  • From: "email@hidden" <email@hidden>
  • Date: Fri, 21 Sep 2012 11:54:12 +0100

The following is used to draw a glyph representing a tab character in an NSLayoutManager subclass.
When using say the Monaco font everything looks fine.
When switching to Menlo however the glyphs drawn in the method below are positioned lower on the line than those drawn by the super implementation.
The same is true when switching between a range of fonts - some align okay, others are lowered.

I am aware that a flipped context is required but this seems to be so.

There is obviously something about the layout that I am missing here which is implemented by the super implementation.
Any pointers would be appreciated.

- (void)drawGlyphsForGlyphRange:(NSRange)glyphRange atPoint:(NSPoint)containerOrigin
{
    if (showInvisibleCharacters) {

		NSString *completeString = [[self textStorage] string];
		NSInteger lengthToRedraw = NSMaxRange(glyphRange);

		NSGraphicsContext *context = [NSGraphicsContext currentContext];
        	NSLog(@"Context isFlipped = % d", [context isFlipped]);	// result: context is flipped

		for (NSInteger idx = glyphRange.location; idx < lengthToRedraw; idx++) {
			unichar characterToCheck = [completeString characterAtIndex:idx];
			if (characterToCheck == '\t') {
				NSPoint pointToDrawAt = [self locationForGlyphAtIndex:idx];
				NSRect glyphFragment = [self lineFragmentRectForGlyphAtIndex:idx effectiveRange:NULL];
				pointToDrawAt.x += glyphFragment.origin.x;
				pointToDrawAt.y = glyphFragment.origin.y;
				[self.tabCharacter drawAtPoint:pointToDrawAt withAttributes:self.attributes];
			}
		}
    }

    [super drawGlyphsForGlyphRange:glyphRange atPoint:containerOrigin];
}

Regards

Jonathan Mitchell
Mugginsoft LLP









_______________________________________________

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: drawGlyphsForGlyphRange layout issue
      • From: Graham Cox <email@hidden>
    • Re: drawGlyphsForGlyphRange layout issue
      • From: Kyle Sluder <email@hidden>
    • Re: drawGlyphsForGlyphRange layout issue
      • From: Ross Carter <email@hidden>
  • Prev by Date: Re: Autosave in place - common use case that makes me hate it
  • Next by Date: Re: Autosave in place - common use case that makes me hate it
  • Previous by thread: Re: Autosave in place - common use case that makes me hate it
  • Next by thread: Re: drawGlyphsForGlyphRange layout issue
  • Index(es):
    • Date
    • Thread