Package java.awt.font

Examples of java.awt.font.GlyphMetrics


   * @param unicodeFont The font this glyph forms part of
   */
  public Glyph(int codePoint, Rectangle bounds, GlyphVector vector, int index, UnicodeFont unicodeFont) {
    this.codePoint = codePoint;

    GlyphMetrics metrics = vector.getGlyphMetrics(index);
    int lsb = (int)metrics.getLSB();
    if (lsb > 0) lsb = 0;
    int rsb = (int)metrics.getRSB();
    if (rsb > 0) rsb = 0;

    int glyphWidth = bounds.width - lsb - rsb;
    int glyphHeight = bounds.height;
    if (glyphWidth > 0 && glyphHeight > 0) {
View Full Code Here


    // xOffset and xAdvance will be incorrect for unicode characters such as combining marks or non-spacing characters
    // (eg Pnujabi's "\u0A1C\u0A47") that require the context of surrounding glyphs to determine spacing, but thisis the
    // best we can do with the BMFont format.
    char[] chars = Character.toChars(codePoint);
    GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
    GlyphMetrics metrics = vector.getGlyphMetrics(0);
    int xOffset = vector.getGlyphPixelBounds(0, null, 0, 0).x - unicodeFont.getPaddingLeft();
    int xAdvance = (int)(metrics.getAdvanceX() + unicodeFont.getPaddingAdvanceX() + unicodeFont.getPaddingLeft() + unicodeFont
      .getPaddingRight());
    return new int[] {xOffset, xAdvance};
  }
View Full Code Here

TOP

Related Classes of java.awt.font.GlyphMetrics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.