Search in sources :

Example 1 with CTLine

use of org.robovm.apple.coretext.CTLine in project playn by threerings.

the class RoboTextLayout method layoutText.

public static RoboTextLayout layoutText(RoboGraphics gfx, final String text, TextFormat format) {
    final RoboFont font = (format.font == null) ? RoboGraphics.defaultFont : (RoboFont) format.font;
    NSAttributedStringAttributes attribs = createAttribs(font);
    CTLine line = CTLine.create(new NSAttributedString(text, attribs));
    return new RoboTextLayout(gfx, text, format, font, line);
}
Also used : NSAttributedStringAttributes(org.robovm.apple.uikit.NSAttributedStringAttributes) CTLine(org.robovm.apple.coretext.CTLine) NSAttributedString(org.robovm.apple.foundation.NSAttributedString)

Example 2 with CTLine

use of org.robovm.apple.coretext.CTLine in project playn by threerings.

the class RoboTextLayout method layoutText.

public static RoboTextLayout[] layoutText(RoboGraphics gfx, String text, TextFormat format, TextWrap wrap) {
    text = normalizeEOL(text);
    final RoboFont font = (format.font == null) ? RoboGraphics.defaultFont : (RoboFont) format.font;
    NSAttributedStringAttributes attribs = createAttribs(font);
    CFArray lines = wrapLines(new NSAttributedString(text, attribs), wrap.width);
    RoboTextLayout[] layouts = new RoboTextLayout[(int) lines.size()];
    for (int ii = 0; ii < layouts.length; ii++) {
        CTLine line = lines.get(ii, CTLine.class);
        CFRange range = line.getStringRange();
        String ltext = text.substring((int) range.getLocation(), (int) (range.getLocation() + range.getLength()));
        layouts[ii] = new RoboTextLayout(gfx, ltext, format, font, line);
    }
    return layouts;
}
Also used : NSAttributedStringAttributes(org.robovm.apple.uikit.NSAttributedStringAttributes) CFArray(org.robovm.apple.corefoundation.CFArray) NSAttributedString(org.robovm.apple.foundation.NSAttributedString) CFRange(org.robovm.apple.corefoundation.CFRange) CTLine(org.robovm.apple.coretext.CTLine) NSAttributedString(org.robovm.apple.foundation.NSAttributedString)

Aggregations

CTLine (org.robovm.apple.coretext.CTLine)2 NSAttributedString (org.robovm.apple.foundation.NSAttributedString)2 NSAttributedStringAttributes (org.robovm.apple.uikit.NSAttributedStringAttributes)2 CFArray (org.robovm.apple.corefoundation.CFArray)1 CFRange (org.robovm.apple.corefoundation.CFRange)1