use of org.robovm.apple.foundation.NSAttributedString 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);
}
use of org.robovm.apple.foundation.NSAttributedString in project playn by threerings.
the class RoboTextLayout method stroke.
void stroke(CGBitmapContext bctx, float x, float y, float strokeWidth, int strokeColor) {
if (strokeLine == null || strokeWidth != this.strokeWidth || strokeColor != this.strokeColor) {
this.strokeWidth = strokeWidth;
this.strokeColor = strokeColor;
NSAttributedStringAttributes attribs = createAttribs(font);
addStroke(attribs, font, strokeWidth, strokeColor);
strokeLine = CTLine.create(new NSAttributedString(text, attribs));
}
paint(bctx, strokeLine, x, y);
}
use of org.robovm.apple.foundation.NSAttributedString in project playn by threerings.
the class RoboTextLayout method fill.
void fill(CGBitmapContext bctx, float x, float y, int fillColor) {
if (this.fillColor != fillColor) {
this.fillColor = fillColor;
NSAttributedStringAttributes attribs = createAttribs(font);
attribs.setForegroundColor(toUIColor(fillColor));
fillLine = CTLine.create(new NSAttributedString(text, attribs));
}
paint(bctx, fillLine, x, y);
}
use of org.robovm.apple.foundation.NSAttributedString 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;
}
Aggregations