Note that there are some explanatory texts on larger screens.

plurals
  1. POCoreText rendering text glitch
    text
    copied!<p>I am working on a new app. I render different documents from an NSAttributedString using Core Text. I am having trouble with strange glitches in the rendering of the text. It doesn't happen with every document. There doesn't seem to be a rhyme or reason to when it appears or not.</p> <p>Here is a cropped screen shot here to demonstrate the problem. </p> <p><img src="https://i.stack.imgur.com/ZqraO.png" alt="Glitch in rendering"></p> <p>Here is a line from the same screenshot that is rendered correctly.</p> <p><img src="https://i.stack.imgur.com/nMDEs.png" alt="Correct rendering"></p> <p><strong>The screenshots are from the same screenshot and the same document.</strong></p> <p>When the problem occurs, there are usually only 2-3 consecutive lines of text that are rendered incorrectly. The rest of the document is fine. </p> <p>Here is the code that I use to render the text in drawRect:</p> <pre><code>CGContextRef context = UIGraphicsGetCurrentContext(); float viewHeight = self.bounds.size.height; CGContextTranslateCTM(context, 0, viewHeight); CGContextScaleCTM(context, 1.0, -1.0); CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0, 1.0)); CGMutablePathRef path = CGPathCreateMutable(); CGRect bounds = CGRectMake(PADDING_LEFT, -PADDING_TOP, self.bounds.size.width-20.0, self.bounds.size.height); CGPathAddRect(path, NULL, bounds); CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFMutableAttributedStringRef)attrString); CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL); CFRelease(framesetter); CFRelease(path); CTFrameDraw(frame, context); </code></pre> <p>Any assistance is appreciated!</p> <p><strong>EDIT:</strong> This problem does not appear to exist on the iPhone 4, only on the 3GS that I have for testing.</p> <p>The glitch is always in the middle of a document.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload