Search in sources :

Example 1 with CGPath

use of org.robovm.apple.coregraphics.CGPath in project playn by threerings.

the class RoboTextLayout method wrapLines.

private static CFArray wrapLines(NSAttributedString astring, float wrapWidth) {
    CTFramesetter fs = CTFramesetter.create(astring);
    try {
        // iOS lays things out from max-y up to zero (inverted coordinate system); so we need to
        // provide a large height for our rectangle to ensure that all lines "fit"
        CGPath path = CGPath.createWithRect(new CGRect(0, 0, wrapWidth, Float.MAX_VALUE / 2), CGAffineTransform.Identity());
        CTFrame frame = fs.createFrame(new CFRange(0, 0), path, null);
        return frame.getLines();
    } finally {
        fs.dispose();
    }
}
Also used : CGPath(org.robovm.apple.coregraphics.CGPath) CGRect(org.robovm.apple.coregraphics.CGRect) CFRange(org.robovm.apple.corefoundation.CFRange)

Aggregations

CFRange (org.robovm.apple.corefoundation.CFRange)1 CGPath (org.robovm.apple.coregraphics.CGPath)1 CGRect (org.robovm.apple.coregraphics.CGRect)1