I wrote code using CoreText to place some texts, as shown below. Red rectangle - text area, black rectangle is empty for images or other objects. I am using kCTFrameClippingPathsAttributeName tell CoreText that the black rectangle will not show texts.

Detailed image as below:

Why is some text broken into this position? The red rectangle and the black rectangle have only a small area, 1px wide, why does the text come out?
The right red frame of the rectangle (533, 40, 440, 668) , the right rectangle of the rectangle (534, 98, 440, 399) .
code:
CGPathRef textArea; // An array of clipping paths NSMutableArray * clippingPaths = [NSMutableArray array]; for (TNPageMedium *medium in self.media) { NSDictionary *clippingPathDict = @{(NSString *)kCTFramePathClippingPathAttributeName:(__bridge id)path}; [clippingPaths addObject:clippingPathDict]; } NSDictionary *optionsDict = @{(NSString*)kCTFrameClippingPathsAttributeName : clippingPaths}; // create frame using texAreaPath, an optionDictionary contains clipping paths CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(pos, 0), textAreaPath, (__bridge CFDictionaryRef)(optionsDict)); // Draw Frame CTFrameDraw(frame, context);
source share