public float getDescent() { return _fm.getDescent(); }
/** * Returns the colorized square size. * * @param fontMetrics * @return the colorized square size. */ public static int getSquareSize(FontMetrics fontMetrics) { return fontMetrics.getHeight() - 2 * fontMetrics.getDescent(); }
/** * Returns the leading area of the font described by the * receiver. A font's <em>leading area</em> is the space * above its ascent which may include accents or other marks. * * @return the leading space of the font */ public int getLeading() { /* * HiHPI rounding problem (bug 490743 comment 17): * * API clients expect this invariant: * getHeight() == getLeading() + getAscent() + getDescent() * * Separate rounding of each RHS term can break the invariant. * * An additional problem is that ascent and descent are more important to * be as close as possible to the real value. Any necessary rounding * adjustment should go into leading, that's why compute this as a derived * value here: */ return getHeight() - getAscent() - getDescent(); }
/** * @param fontMetrics */ public void setFontMetrics(FontMetrics fontMetrics) { if (fontMetrics != null) { _fontAscent = fontMetrics.getAscent(); _fontDescent = fontMetrics.getDescent(); _fontLeading = fontMetrics.getLeading(); // if (_fragments == null || _fragments.isEmpty()) // { // this._ascent = _fontAscent + _fontLeading; // this._descent = _fontDescent; // if (this._height < this._ascent + this._descent) // { // this._height = this._ascent + this._descent; // } // } } else { _fontAscent = 0; _fontDescent = 0; _fontLeading = 0; } }
@Override public Point draw(GC gc, StyledText textWidget, Color color, int x, int y) { Image image = getImage(); gc.drawImage(image, x, y + gc.getFontMetrics().getDescent()); Rectangle bounds = image.getBounds(); return new Point(bounds.width, bounds.height); }
/** * Calculates the bounds of the text in the box as measured by the given * graphics context and font metrics. * * @param gc graphics context from which the measurements are done * @return point representing the dimensions of the text's bounds */ private Point calculateTextBounds(final GC gc) { final SWTGraphics2D g2 = new SWTGraphics2D(gc, Display.getDefault()); g2.setFont(font); final FontMetrics fm = g2.getSWTFontMetrics(); final Point textBounds = new Point(0, 0); boolean firstLine = true; final Iterator lineIterator = lines.iterator(); while (lineIterator.hasNext()) { String line = (String) lineIterator.next(); Point lineBounds = gc.stringExtent(line); if (firstLine) { textBounds.x = lineBounds.x; textBounds.y += fm.getAscent() + fm.getDescent() + fm.getLeading(); firstLine = false; } else { textBounds.x = Math.max(lineBounds.x, textBounds.x); textBounds.y += fm.getHeight(); } } return textBounds; }
public int getFontBaselineHeight() { if (fontBaselineHeight == -1) { Font font = getFont(); GC gc = new GC(getDisplay()); gc.setFont(font); FontMetrics fm = gc.getFontMetrics(); fontBaselineHeight = fm.getHeight() - fm.getDescent(); gc.dispose(); } return fontBaselineHeight; }
public int getFontBaselineHeight() { if (fontBaselineHeight == -1) { Font font = getFont(); GC gc = new GC(getDisplay()); gc.setFont(font); FontMetrics fm = gc.getFontMetrics(); fontBaselineHeight = fm.getHeight() - fm.getDescent(); gc.dispose(); } return fontBaselineHeight; }
protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); graphics.setFont(getFont()); // TODO (cs) this lookup to find " :" is a hack // that's specialized for element and type label text // we need to make the TopLevelComponent use two labels in this case // String string = getText(); int index = string.indexOf(" :"); if (index != -1) { string = string.substring(0, index); } // end hack Point p = getTextLocation(); Dimension textSize = FigureUtilities.getTextExtents(string, getFont()); int textWidth = textSize.width; int textHeight = textSize.height; int descent = graphics.getFontMetrics().getDescent(); int lineY = bounds.y + p.y + textHeight - descent + 1; int lineX = bounds.x + p.x; graphics.drawLine(lineX, lineY, lineX + textWidth, lineY); } }
public int getFontBaselineHeight() { if (fontBaselineHeight == -1) { Control c = getMessageControl(); if (c == null) return 0; GC gc = new GC(c.getDisplay()); gc.setFont(c.getFont()); FontMetrics fm = gc.getFontMetrics(); fontBaselineHeight = fm.getHeight() - fm.getDescent(); gc.dispose(); } return fontBaselineHeight; }
public int getFontBaselineHeight() { if (fontBaselineHeight == -1) { Control c = getMessageControl(); if (c == null) return 0; GC gc = new GC(c.getDisplay()); gc.setFont(c.getFont()); FontMetrics fm = gc.getFontMetrics(); fontBaselineHeight = fm.getHeight() - fm.getDescent(); gc.dispose(); } return fontBaselineHeight; }
FontMetrics fm = gc.getFontMetrics(); int lineHeight = fm.getHeight(); int descent = fm.getDescent();
FontMetrics fm = gc.getFontMetrics(); int lineHeight = fm.getHeight(); int descent = fm.getDescent();
private Point getDrawPointForText(String displayString) { Font font = getCSSStyle().getCSSFont().getSwtFont(); int x = 0; int y = 0; Rectangle box = _blockBox.toRectangle().getCopy().expand( _blockBox.getBorderPaddingInsets().getAdded( _blockBox._marginInsets)); x = box.x - FigureUtilities.getTextWidth(displayString, font); x = x - (TEXT_PADDING - FigureUtilities.getFontMetrics(font) .getDescent()); return new Point(x, y); }
/** * Draw square of the given rgb. * * @param rgb the rgb color * @param gc the graphic context * @param textWidget the text widget * @param x the location y * @param y the location y * @return the square width. */ private int drawSquare(RGB rgb, GC gc, StyledText textWidget, int x, int y) { FontMetrics fontMetrics = gc.getFontMetrics(); int size = getSquareSize(fontMetrics); x += fontMetrics.getLeading(); y += fontMetrics.getDescent(); Rectangle rect = new Rectangle(x, y, size, size); // Fill square gc.setBackground(getColor(rgb, textWidget.getDisplay())); gc.fillRectangle(rect); // Draw square box gc.setForeground(textWidget.getForeground()); gc.drawRectangle(rect); return getSquareWidth(gc.getFontMetrics()); }
FontMetrics metrics = layout.getLineMetrics(0); printLayout.setAscent(metrics.getAscent() + metrics.getLeading()); printLayout.setDescent(metrics.getDescent()); String[] lineLabels = printOptions.lineLabels; if (lineLabels != null) {
FontMetrics metrics = layout.getLineMetrics(0); printLayout.setAscent(metrics.getAscent() + metrics.getLeading()); printLayout.setDescent(metrics.getDescent()); String[] lineLabels = printOptions.lineLabels; if (lineLabels != null) {
FontMetrics metrics = layout.getLineMetrics(0); printLayout.setAscent(metrics.getAscent() + metrics.getLeading()); printLayout.setDescent(metrics.getDescent()); String[] lineLabels = printOptions.lineLabels; if (lineLabels != null) {
FontMetrics metrics = layout.getLineMetrics(0); printLayout.setAscent(metrics.getAscent() + metrics.getLeading()); printLayout.setDescent(metrics.getDescent()); String[] lineLabels = printOptions.lineLabels; if (lineLabels != null) {
FontMetrics metrics = layout.getLineMetrics(0); printLayout.setAscent(metrics.getAscent() + metrics.getLeading()); printLayout.setDescent(metrics.getDescent()); String[] lineLabels = printOptions.lineLabels; if (lineLabels != null) {