Package java.awt.font

Examples of java.awt.font.GlyphMetrics


  // iterate through the GlyphVector placing each glyph

  for (int i = 0; i < glyphs.getNumGlyphs(); i++) {
     
      GlyphMetrics gm = glyphs.getGlyphMetrics(i);

      float charAdvance = gm.getAdvance();

      Shape glyph = glyphs.getGlyphOutline(i);

      // if lengthAdjust was GLYPHS, then scale the glyph
      // by the lengthRatio in the X direction
View Full Code Here


            int advance = 0;

            GlyphVector gv = font.createGlyphVector(frc, new char[]{referenceChar});
            java.awt.Shape glyphOutline = gv.getGlyphOutline(0);

            GlyphMetrics metrics = gv.getGlyphMetrics(0);
            advance = (int)Math.rint(metrics.getAdvance()); //Do not scale here, DefineText needs values unscaled

            java.awt.Shape scaledShape = scaleTransform.createTransformedShape(glyphOutline);
            swfShape = createGlyphShape(scaledShape);

            GlyphEntry ge = new GlyphEntry();
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, GlyphPage.renderContext, 0.5f, 0).x - unicodeFont.getPaddingLeft();
    int xAdvance = (int)(metrics.getAdvanceX() + unicodeFont.getPaddingAdvanceX() + unicodeFont.getPaddingLeft() + unicodeFont
      .getPaddingRight());
    return new int[] {xOffset, xAdvance};
  }
View Full Code Here

  private Texture texture;

  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

  // iterate through the GlyphVector placing each glyph

  for (int i = 0; i < glyphs.getNumGlyphs(); i++) {
     
      GlyphMetrics gm = glyphs.getGlyphMetrics(i);

      float charAdvance = gm.getAdvance();

      Shape glyph = glyphs.getGlyphOutline(i);

      // if lengthAdjust was GLYPHS, then scale the glyph
      // by the lengthRatio in the X direction
View Full Code Here

        GVTLineMetrics lineMetrics = gvtFont.getLineMetrics
            ("By", awtGlyphVector.getFontRenderContext());
        float ascent = lineMetrics.getAscent() * scaleFactor;
        float descent = lineMetrics.getDescent() * scaleFactor;

        GlyphMetrics gm = awtGlyphVector.getGlyphMetrics(glyphIndex);

        Rectangle2D gmBounds = gm.getBounds2D();

        Rectangle2D bounds =
            new Rectangle2D.Double(gmBounds.getX() * scaleFactor,
                                   gmBounds.getY() * scaleFactor,
                                   gmBounds.getWidth() * scaleFactor,
                                   gmBounds.getHeight() * scaleFactor);

        return new GVTGlyphMetrics(gm.getAdvance()*scaleFactor,
                                   (ascent+descent),
                                   bounds,
                                   GlyphMetrics.STANDARD);
    }
View Full Code Here

            // if c is a transparent arabic char then need to shift the
            // following glyphs left so that the current glyph is overwritten
            char c = ci.setIndex(i + ci.getBeginIndex());
            if (ArabicTextHandler.arabicCharTransparent(c)) {
                GlyphMetrics gm = awtGlyphVector.getGlyphMetrics(i);
                shiftLeft = gm.getAdvance();
            }
        }
    }
View Full Code Here

     */
    public GVTGlyphMetrics(float horizontalAdvance,
         float verticalAdvance,
                           Rectangle2D bounds,
         byte glyphType) {
        this.gm = new GlyphMetrics(horizontalAdvance, bounds, glyphType);
        this.verticalAdvance = verticalAdvance;
    }
View Full Code Here

        Point2D pos = getGlyphPosition( glyphIndex );
        bounds.setRect( bounds.getX() - pos.getX(), bounds.getY()- pos.getY(), bounds.getWidth(), bounds.getHeight() );

        Point2D.Float advance = strike.getGlyphMetrics( glyphs.charAt( glyphIndex ) );

        return new GlyphMetrics( true, advance.x, advance.y, bounds, (byte)0 );
    }
View Full Code Here

                xform.rotate(rotate[Math.min(i, rotate.length - 1)]);
            }

            String unicode = text.substring(i, i + 1);
            Shape glyphOutline = textVector.getGlyphOutline(i);
            GlyphMetrics glyphMetrics = textVector.getGlyphMetrics(i);

            glyphOutline = xform.createTransformedShape(glyphOutline);
            addShape.append(glyphOutline, false);

            if (x != null && posPtr < x.length)
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.