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 protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]