/** * @return full height of this text run which is sum of ascent, descent and leading */ public float getHeight(){ double h = layout.getAscent() + layout.getDescent() + getLeading(); return (float)h; }
/** * @return the leading height before/after a text line */ public float getLeading() { // fix invalid leadings (leading == 0) double l = layout.getLeading(); if (l == 0) { // see https://stackoverflow.com/questions/925147 // we use a 115% value instead of the 120% proposed one, as this seems to be closer to LO/OO l = (layout.getAscent()+layout.getDescent())*0.15; } return (float)l; }
int height = ((Float) (layout.getDescent() + layout.getAscent() + layout.getLeading())).intValue(); currentX, currentY); currentY += textLayout.getDescent() + textLayout.getLeading();
nextY += layout.getAscent() + layout.getDescent() + layout.getLeading();
(float) tX, textY); textY += tl.getDescent() + tl.getLeading() + (interline - 1.0f) * tl.getAscent();
FontRenderContext context = g2d.getFontRenderContext(); Font font = new Font("Arial", Font.BOLD, 48); TextLayout txt = new TextLayout(text, font, context); Rectangle2D bounds = txt.getBounds(); int x = (int) ((getWidth() - (int) bounds.getWidth()) / 2); int y = (int) ((getHeight() - (bounds.getHeight() - txt.getDescent())) / 2); y += txt.getAscent() - txt.getDescent();
double getLineHeight() { double height = Float.NEGATIVE_INFINITY; for (LineComponent component : components) { double ch = component.getGlyphVector().getVisualBounds().getHeight() - component.getLayout().getDescent(); if (ch > height) { height = ch; } } return height; }
private void drawLines(WrappedLines lines, Graphics2D g) { Colors colors = look.colors(); float y = originY(lines); for(TextLayout line : lines.list) { float x = xFor(line); y += line.getAscent() - line.getDescent(); Color shadowColor = colors.shadow(); g.setColor(shadowColor); line.draw(g, x-1, y-1); g.setColor(colors.text()); line.draw(g, x, y); y += line.getDescent(); } }
int y = (int) ((getHeight() - (bounds.getHeight() - txt.getDescent())) / 2); y += txt.getAscent() - txt.getDescent();
float getLineOffset() { float offset = Float.NEGATIVE_INFINITY; for (LineComponent component : components) { float co = component.getLayout().getAscent() + component.getLayout().getDescent() + component.getLayout().getLeading(); if (co > offset) { offset = co; } } return offset; }
layout.draw(g, x + inset, yPos); yPos += layout.getDescent() + layout.getLeading() - 2;
textLayout.draw(g2d, textX + glowSize / 2, textY + glowSize / 2); textY += textLayout.getDescent() + textLayout.getLeading(); // Move down to top of next line.
while (lineMeasurer.getPosition() < paragraphEnd) { TextLayout layout = lineMeasurer.nextLayout(maxTextWidth); layoutHeight += layout.getAscent() + layout.getDescent() + layout.getLeading(); } else if (Position.BELOW == this.position) { posX += -layout.getAdvance() * 0.5f; posY += (layout.getAscent() + layout.getDescent() + layout.getLeading()) * 0.5f; } else if (Position.BELOW_LEFT == this.position) { posX += -layout.getAdvance(); posY += (layout.getAscent() + layout.getDescent() + layout.getLeading()) * 0.5f; } else if (Position.BELOW_RIGHT == this.position) { posY += (layout.getAscent() + layout.getDescent() + layout.getLeading()) * 0.5f; } else if (Position.ABOVE == this.position) { posX += -layout.getAdvance() * 0.5f; posY += layout.getAscent() + layout.getDescent() + layout.getLeading() - layoutHeight; } else if (Position.ABOVE_LEFT == this.position) { posX += -layout.getAdvance(); posY += layout.getAscent() + layout.getDescent() + layout.getLeading() - layoutHeight; } else if (Position.ABOVE_RIGHT == this.position) { posY += layout.getAscent() + layout.getDescent() + layout.getLeading() - layoutHeight; } else if (Position.LEFT == this.position) { posX += -layout.getAdvance(); drawPosY += layout.getAscent() + layout.getDescent() + layout.getLeading(); if (filter != Filter.NONE) { this.paintFront.setColor(colorF);
private float getVerticalAlignmentValue(TextLayout layout, int vertAlign) { if (vertAlign == WMFConstants.TA_BOTTOM) return -layout.getDescent(); else if (vertAlign == WMFConstants.TA_TOP) return layout.getAscent(); else return 0; }
public void update( TextLayout textLayout ) { ascent = Math.max( ascent, textLayout.getAscent() ); descent = Math.max( descent, textLayout.getDescent() ); leading = Math.max( leading, textLayout.getLeading() ); }
/** * @return full height of this text run which is sum of ascent, descent and leading */ public float getHeight(){ double h = layout.getAscent() + layout.getDescent() + getLeading(); return (float)h; }
/** get the vertical Alignment value for the text. */ private float getVerticalAlignmentValue(TextLayout layout, int vertAlign) { if (vertAlign == WMFConstants.TA_BASELINE) return -layout.getAscent(); else if (vertAlign == WMFConstants.TA_TOP) return (layout.getAscent() + layout.getDescent()); else return 0; } }
public float getHeight(FontRenderContext fontRenderContext) { TextLayout tl = getTextLayout(fontRenderContext); return tl.getLeading() + tl.getAscent() + tl.getDescent(); }
public void layout(FontRenderContext fontRenderContext) { this.textLayout = new TextLayout(attributedString.getIterator(), fontRenderContext); int textHeight = (int) (textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading()); int totalHeight = textHeight + getInsetsTop() + getInsetsBottom(); setHeight(totalHeight); }
public void layout(FontRenderContext fontRenderContext) { this.textLayout = new TextLayout(attributedString.getIterator(), fontRenderContext); int textHeight = (int) (textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading()); int totalHeight = textHeight + getInsetsTop() + getInsetsBottom(); setHeight(totalHeight); }