@Override public float ascent() { return (float)font.ctFont.getAscent(); }
@Override public float ascent() { return (float)font.getAscent(); }
private RoboTextLayout(RoboGraphics gfx, String text, TextFormat format, CTFont font, CTLine fillLine) { super(text, format, computeBounds(font, fillLine.getImageBounds(gfx.scratchCtx)), (float)(font.getAscent()+font.getDescent())); this.font = font; this.fillLine = fillLine; }
private static Rectangle computeBounds(CTFont font, CGRect bounds) { // the y coordinate of bounds is a little tricky: iOS reports y as the number of pixels to // below the baseline that the text extends (the descent, but precisely for this text, not the // font's "maximum" descent) and the value is negative (due to the inverted coordinate system); // so we have to do some math to recover the desired y value which is the number of pixels // below the top-left of the line bounding box float ascent = (float)font.getAscent(); return new Rectangle((float)bounds.getMinX(), ascent - (float)(bounds.getHeight() + bounds.getMinY()), (float)bounds.getWidth(), (float)bounds.getHeight()); } }
private static Rectangle computeBounds(RoboFont font, CGRect bounds) { // the y coordinate of bounds is a little tricky: iOS reports y as the number of pixels to // below the baseline that the text extends (the descent, but precisely for this text, not the // font's "maximum" descent) and the value is negative (due to the inverted coordinate system); // so we have to do some math to recover the desired y value which is the number of pixels // below the top-left of the line bounding box float ascent = (float)font.ctFont.getAscent(); return new Rectangle((float)bounds.getMinX(), ascent - (float)(bounds.getHeight() + bounds.getMinY()), (float)bounds.getWidth(), (float)bounds.getHeight()); } }