YetiCharacterLabelExample icon indicating copy to clipboard operation
YetiCharacterLabelExample copied to clipboard

Glyphs not rendering at correct positions

Open MrBendel opened this issue 10 years ago • 1 comments

Hey,

Love this project! Been using code abstracted from it for my own project but I noticed a few things while working on it. For one, the glyphs don't render properly. If you call [super setAttributedText:attributedText]; when setting the attributed text you can see how off it is. Also multi-line text doesn't render. I'm investigating but it looks like you need CGRect lineFragmentRect = [self.layoutManager lineFragmentRectForGlyphAtIndex:glyphIndex effectiveRange:nil]; to get the correct y-position of the line fragment. I'll post any updates I make that seem to help resolve the issue.

many thanks!

MrBendel avatar Mar 26 '15 01:03 MrBendel

Scratch previous suggestion, looks like it can be simplified:

CGFloat centerY = CGRectGetHeight(self.bounds) * 0.5 - CGRectGetHeight(layoutRect) * 0.5; glyphRect.origin.y += centerY;

Not sure what CGPoint location = [self.layoutManager locationForGlyphAtIndex:glyphIndex]; is returning, but it seems to throw things off vertically. Also, adjusting the line height multiplier on the attributes causes all sorts of rendering issues.

MrBendel avatar Mar 26 '15 02:03 MrBendel