Java 类java.awt.font.GlyphMetrics 实例源码

项目:OpenJSharp    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:OpenJSharp    文件:StandardGlyphVector.java   
@Override
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length()) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
            strike.getGlyphMetrics( glyphs.charAt( ix ) );
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                      (byte)0);
    return gm;
}
项目:jdk8u-jdk    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:openjdk-jdk10    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:openjdk9    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:jdk8u_jdk    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:lookaside_java-1.8.0-openjdk    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:cachebox3.0    文件:FontSystem.java   
@Override
public MissingGlyph getGlyph(String unicode)
{
    FontRenderContext frc = new FontRenderContext(null, true, true);
    GlyphVector vec = sysFont.createGlyphVector(frc, unicode);

    Glyph glyph = (Glyph)glyphCache.get(unicode);
    if (glyph == null)
    {
        glyph = new Glyph();
        glyph.setPath(vec.getGlyphOutline(0));

        GlyphMetrics gm = vec.getGlyphMetrics(0);
        glyph.setHorizAdvX((int)gm.getAdvanceX());
        glyph.setVertAdvY((int)gm.getAdvanceY());
        glyph.setVertOriginX(0);
        glyph.setVertOriginY(0);

        glyphCache.put(unicode, glyph);
    }

    return glyph;
}
项目:javify    文件:FreetypeGlyphVector.java   
public Shape getGlyphLogicalBounds(int glyphIndex)
{
  GlyphMetrics gm = getGlyphMetrics( glyphIndex );
  if( gm == null )
    return null;
  Rectangle2D r = gm.getBounds2D();
  Point2D p = getGlyphPosition( glyphIndex );

  double[] bounds = new double[] {p.getX() + r.getX() - gm.getLSB(),
                                  p.getY() + r.getY(),
                                  p.getX() + r.getX() - gm.getLSB() + gm.getAdvanceX(),
                                  p.getY() + r.getY() + r.getHeight()};

  if (glyphTransforms[glyphIndex] != null)
    glyphTransforms[glyphIndex].transform(bounds, 0, bounds, 0, 2);

  return new Rectangle2D.Double(bounds[0], bounds[1], bounds[2] - bounds[0],
                                bounds[3] - bounds[1]);
}
项目:jvm-stm    文件:FreetypeGlyphVector.java   
public Shape getGlyphLogicalBounds(int glyphIndex)
{
  GlyphMetrics gm = getGlyphMetrics( glyphIndex );
  if( gm == null )
    return null; 
  Rectangle2D r = gm.getBounds2D();
  Point2D p = getGlyphPosition( glyphIndex );

  double[] bounds = new double[] {p.getX() + r.getX() - gm.getLSB(),
                                  p.getY() + r.getY(),
                                  p.getX() + r.getX() - gm.getLSB() + gm.getAdvanceX(),
                                  p.getY() + r.getY() + r.getHeight()};

  if (glyphTransforms[glyphIndex] != null)
    glyphTransforms[glyphIndex].transform(bounds, 0, bounds, 0, 2);

  return new Rectangle2D.Double(bounds[0], bounds[1], bounds[2] - bounds[0],
                                bounds[3] - bounds[1]);
}
项目:jcadencii    文件:BLabel.java   
private GlyphVector getWrappedGlyphVector(String str, float wrapping,
    Font font, FontRenderContext frc) {
    Point2D gmPos = new Point2D.Double(0.0d, 0.0d);
    GlyphVector gv = font.createGlyphVector(frc, str);
    float lineheight = (float) gv.getLogicalBounds().getHeight();
    float xpos = 0.0f;
    float advance = 0.0f;
    int lineCount = 0;
    GlyphMetrics gm;

    for (int i = 0; i < gv.getNumGlyphs(); i++) {
        gm = gv.getGlyphMetrics(i);
        advance = gm.getAdvance();

        if ((xpos < wrapping) && (wrapping <= (xpos + advance))) {
            lineCount++;
            xpos = 0.0f;
        }

        gmPos.setLocation(xpos, lineheight * lineCount);
        gv.setGlyphPosition(i, gmPos);
        xpos = xpos + advance;
    }

    return gv;
}
项目:infobip-open-jdk-8    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:jdk8u-dev-jdk    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:jdk7-jdk    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:libgdxcn    文件:Glyph.java   
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) {
        int padTop = unicodeFont.getPaddingTop();
        int padRight = unicodeFont.getPaddingRight();
        int padBottom = unicodeFont.getPaddingBottom();
        int padLeft = unicodeFont.getPaddingLeft();
        int glyphSpacing = 1; // Needed to prevent filtering problems.
        width = (short)(glyphWidth + padLeft + padRight + glyphSpacing);
        height = (short)(glyphHeight + padTop + padBottom + glyphSpacing);
        yOffset = (short)(unicodeFont.getAscent() + bounds.y - padTop);
    }

    shape = vector.getGlyphOutline(index, -bounds.x + unicodeFont.getPaddingLeft(), -bounds.y + unicodeFont.getPaddingTop());

    isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
}
项目:openjdk-source-code-learn    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:OLD-OpenJDK8    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:GdxStudio    文件:Glyph.java   
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) {
        int padTop = unicodeFont.getPaddingTop();
        int padRight = unicodeFont.getPaddingRight();
        int padBottom = unicodeFont.getPaddingBottom();
        int padLeft = unicodeFont.getPaddingLeft();
        int glyphSpacing = 1; // Needed to prevent filtering problems.
        width = (short)(glyphWidth + padLeft + padRight + glyphSpacing);
        height = (short)(glyphHeight + padTop + padBottom + glyphSpacing);
        yOffset = (short)(unicodeFont.getAscent() + bounds.y - padTop);
    }

    shape = vector.getGlyphOutline(index, -bounds.x + unicodeFont.getPaddingLeft(), -bounds.y + unicodeFont.getPaddingTop());

    isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
}
项目:cn1    文件:LinuxGlyph.java   
/**
 * Default Glyph constructor
 */
public LinuxGlyph(char c, int glyphIndex) {
    float metrics[] = new float[6];
    int[] pxlMetrics = new int[6];

    this.pFont = 0;
    this.fontSize = 0;

    Rectangle2D.Float rect  = new Rectangle2D.Float(metrics[0],
                                                    -metrics[1],
                                                    metrics[4],
                                                    metrics[5]);
    this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);

    this.glCode = glyphIndex;
    this.glChar = c;

    Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                    -pxlMetrics[1],
                                                    pxlMetrics[4],
                                                    pxlMetrics[5]);
    this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
}
项目:cn1    文件:WinGlyph.java   
/**
 * Default Glyph constructor
 */
public WinGlyph(char c, int glyphIndex) {
    float metrics[] = new float[6];
    int[] pxlMetrics = new int[6];

    this.pFont = 0;
    this.fontSize = 0;

    Rectangle2D.Float rect  = new Rectangle2D.Float(metrics[0],
                                                    -metrics[1],
                                                    metrics[4],
                                                    metrics[5]);
    this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);

    this.glCode = glyphIndex;
    this.glChar = c;

    Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                    -pxlMetrics[1],
                                                    pxlMetrics[4],
                                                    pxlMetrics[5]);
    this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
}
项目:cn1    文件:FLGlyph.java   
@Override
public GlyphMetrics getGlyphMetrics(){
    if (glMetrics == null) {
        float[] metrics = getGlyphMetrics(glyphPointer);

        this.glMetrics = new GlyphMetrics(
                true, 
                Math.round(metrics[0]),//metrics[0], 
                Math.round(metrics[1]),//metrics[1],
                //new Rectangle2D.Double(initOutline().getBounds2D().getMinX(), initOutline().getBounds2D().getMinY(), initOutline().getBounds2D().getMaxX() + 5, initOutline().getBounds2D().getMaxY()),                    
                initOutline().getBounds2D(),//new Rectangle2D.Float(metrics[2], -metrics[5]-1,metrics[4]- metrics[2] + 1, metrics[5] - metrics[3] + 1),
                GlyphMetrics.STANDARD);
    }

    return glMetrics;
}
项目:JamVM-PH    文件:FreetypeGlyphVector.java   
public Shape getGlyphLogicalBounds(int glyphIndex)
{
  GlyphMetrics gm = getGlyphMetrics( glyphIndex );
  if( gm == null )
    return null; 
  Rectangle2D r = gm.getBounds2D();
  Point2D p = getGlyphPosition( glyphIndex );

  double[] bounds = new double[] {p.getX() + r.getX() - gm.getLSB(),
                                  p.getY() + r.getY(),
                                  p.getX() + r.getX() - gm.getLSB() + gm.getAdvanceX(),
                                  p.getY() + r.getY() + r.getHeight()};

  if (glyphTransforms[glyphIndex] != null)
    glyphTransforms[glyphIndex].transform(bounds, 0, bounds, 0, 2);

  return new Rectangle2D.Double(bounds[0], bounds[1], bounds[2] - bounds[0],
                                bounds[3] - bounds[1]);
}
项目:r2cat    文件:PDFFontEmbedderType3.java   
protected void writeGlyph(String characterName, Shape glyph,
        GlyphMetrics glyphMetrics) throws IOException {

    PDFStream glyphStream = pdf.openStream(
            createCharacterReference(characterName), new String[] {
                    "Flate", "ASCII85" });

    Rectangle2D bounds = glyphMetrics != null ? glyphMetrics.getBounds2D()
            : glyph.getBounds2D();
    double advance = glyphMetrics != null ? glyphMetrics.getAdvance()
            : getUndefinedWidth();
    glyphStream.glyph(advance, 0, bounds.getX(), bounds.getY(), bounds
            .getX()
            + bounds.getWidth(), bounds.getY() + bounds.getHeight());

    boolean windingRule = glyphStream.drawPath(glyph);
    if (windingRule) {
        glyphStream.fillEvenOdd();
    } else {
        glyphStream.fill();
    }
    pdf.close(glyphStream);
}
项目:openjdk-jdk7u-jdk    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:classpath    文件:FreetypeGlyphVector.java   
public Shape getGlyphLogicalBounds(int glyphIndex)
{
  GlyphMetrics gm = getGlyphMetrics( glyphIndex );
  if( gm == null )
    return null;
  Rectangle2D r = gm.getBounds2D();
  Point2D p = getGlyphPosition( glyphIndex );

  double[] bounds = new double[] {p.getX() + r.getX() - gm.getLSB(),
                                  p.getY() + r.getY(),
                                  p.getX() + r.getX() - gm.getLSB() + gm.getAdvanceX(),
                                  p.getY() + r.getY() + r.getHeight()};

  if (glyphTransforms[glyphIndex] != null)
    glyphTransforms[glyphIndex].transform(bounds, 0, bounds, 0, 2);

  return new Rectangle2D.Double(bounds[0], bounds[1], bounds[2] - bounds[0],
                                bounds[3] - bounds[1]);
}
项目:freeVM    文件:LinuxGlyph.java   
/**
 * Default Glyph constructor
 */
public LinuxGlyph(char c, int glyphIndex) {
    float metrics[] = new float[6];
    int[] pxlMetrics = new int[6];

    this.pFont = 0;
    this.fontSize = 0;

    Rectangle2D.Float rect  = new Rectangle2D.Float(metrics[0],
                                                    -metrics[1],
                                                    metrics[4],
                                                    metrics[5]);
    this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);

    this.glCode = glyphIndex;
    this.glChar = c;

    Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                    -pxlMetrics[1],
                                                    pxlMetrics[4],
                                                    pxlMetrics[5]);
    this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
}
项目:freeVM    文件:WinGlyph.java   
/**
 * Default Glyph constructor
 */
public WinGlyph(char c, int glyphIndex) {
    float metrics[] = new float[6];
    int[] pxlMetrics = new int[6];

    this.pFont = 0;
    this.fontSize = 0;

    Rectangle2D.Float rect  = new Rectangle2D.Float(metrics[0],
                                                    -metrics[1],
                                                    metrics[4],
                                                    metrics[5]);
    this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);

    this.glCode = glyphIndex;
    this.glChar = c;

    Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                    -pxlMetrics[1],
                                                    pxlMetrics[4],
                                                    pxlMetrics[5]);
    this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
}
项目:freeVM    文件:LinuxGlyph.java   
/**
 * Default Glyph constructor
 */
public LinuxGlyph(char c, int glyphIndex) {
    float metrics[] = new float[6];
    int[] pxlMetrics = new int[6];

    this.pFont = 0;
    this.fontSize = 0;

    Rectangle2D.Float rect  = new Rectangle2D.Float(metrics[0],
                                                    -metrics[1],
                                                    metrics[4],
                                                    metrics[5]);
    this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);

    this.glCode = glyphIndex;
    this.glChar = c;

    Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                    -pxlMetrics[1],
                                                    pxlMetrics[4],
                                                    pxlMetrics[5]);
    this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
}
项目:freeVM    文件:WinGlyph.java   
/**
 * Default Glyph constructor
 */
public WinGlyph(char c, int glyphIndex) {
    float metrics[] = new float[6];
    int[] pxlMetrics = new int[6];

    this.pFont = 0;
    this.fontSize = 0;

    Rectangle2D.Float rect  = new Rectangle2D.Float(metrics[0],
                                                    -metrics[1],
                                                    metrics[4],
                                                    metrics[5]);
    this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);

    this.glCode = glyphIndex;
    this.glChar = c;

    Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                    -pxlMetrics[1],
                                                    pxlMetrics[4],
                                                    pxlMetrics[5]);
    this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
}
项目:freeVM    文件:FLGlyph.java   
@Override
public GlyphMetrics getGlyphMetrics(){
    if (glMetrics == null) {
        float[] metrics = getGlyphMetrics(glyphPointer);

        this.glMetrics = new GlyphMetrics(
                true, 
                Math.round(metrics[0]),//metrics[0], 
                Math.round(metrics[1]),//metrics[1],
                //new Rectangle2D.Double(initOutline().getBounds2D().getMinX(), initOutline().getBounds2D().getMinY(), initOutline().getBounds2D().getMaxX() + 5, initOutline().getBounds2D().getMaxY()),                    
                initOutline().getBounds2D(),//new Rectangle2D.Float(metrics[2], -metrics[5]-1,metrics[4]- metrics[2] + 1, metrics[5] - metrics[3] + 1),
                GlyphMetrics.STANDARD);
    }

    return glMetrics;
}
项目:openjdk-icedtea7    文件:StandardGlyphVector.java   
public GlyphMetrics getGlyphMetrics(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }

    Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
    Point2D pt = getGlyphPosition(ix);
    vb.setRect(vb.getMinX() - pt.getX(),
               vb.getMinY() - pt.getY(),
               vb.getWidth(),
               vb.getHeight());
    Point2D.Float adv =
        getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
    GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                       vb,
                                       GlyphMetrics.STANDARD);
    return gm;
}
项目:touhou-java    文件:Glyph.java   
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) {
        int padTop = unicodeFont.getPaddingTop();
        int padRight = unicodeFont.getPaddingRight();
        int padBottom = unicodeFont.getPaddingBottom();
        int padLeft = unicodeFont.getPaddingLeft();
        int glyphSpacing = 1; // Needed to prevent filtering problems.
        width = (short)(glyphWidth + padLeft + padRight + glyphSpacing);
        height = (short)(glyphHeight + padTop + padBottom + glyphSpacing);
        yOffset = (short)(unicodeFont.getAscent() + bounds.y - padTop);
    }

    shape = vector.getGlyphOutline(index, -bounds.x + unicodeFont.getPaddingLeft(), -bounds.y + unicodeFont.getPaddingTop());

    isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
}
项目:trashjam2017    文件:Glyph.java   
/**
 * Create a new glyph
 * 
 * @param codePoint The code point in which this glyph can be found
 * @param bounds The bounds that this glrph can fill
 * @param vector The vector this glyph is part of
 * @param index The index of this glyph within the vector
 * @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) {
        int padTop = unicodeFont.getPaddingTop();
        int padRight = unicodeFont.getPaddingRight();
        int padBottom = unicodeFont.getPaddingBottom();
        int padLeft = unicodeFont.getPaddingLeft();
        int glyphSpacing = 1; // Needed to prevent filtering problems.
        width = (short)(glyphWidth + padLeft + padRight + glyphSpacing);
        height = (short)(glyphHeight + padTop + padBottom + glyphSpacing);
        yOffset = (short)(unicodeFont.getAscent() + bounds.y - padTop);
    }

    shape = vector.getGlyphOutline(index, -bounds.x + unicodeFont.getPaddingLeft(), -bounds.y + unicodeFont.getPaddingTop());

    isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
}
项目:trashjam2017    文件:BMFontUtil.java   
private int[] getGlyphMetrics (Font font, int codePoint) {
    // 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};
}
项目:Progetto-C    文件:Glyph.java   
/**
 * Create a new glyph
 * 
 * @param codePoint The code point in which this glyph can be found
 * @param bounds The bounds that this glrph can fill
 * @param vector The vector this glyph is part of
 * @param index The index of this glyph within the vector
 * @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) {
        int padTop = unicodeFont.getPaddingTop();
        int padRight = unicodeFont.getPaddingRight();
        int padBottom = unicodeFont.getPaddingBottom();
        int padLeft = unicodeFont.getPaddingLeft();
        int glyphSpacing = 1; // Needed to prevent filtering problems.
        width = (short)(glyphWidth + padLeft + padRight + glyphSpacing);
        height = (short)(glyphHeight + padTop + padBottom + glyphSpacing);
        yOffset = (short)(unicodeFont.getAscent() + bounds.y - padTop);
    }

    shape = vector.getGlyphOutline(index, -bounds.x + unicodeFont.getPaddingLeft(), -bounds.y + unicodeFont.getPaddingTop());

    isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
}
项目:Progetto-C    文件:BMFontUtil.java   
private int[] getGlyphMetrics (Font font, int codePoint) {
    // 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};
}
项目:BaseClient    文件:Glyph.java   
/**
 * Create a new glyph
 * 
 * @param codePoint The code point in which this glyph can be found
 * @param bounds The bounds that this glrph can fill
 * @param vector The vector this glyph is part of
 * @param index The index of this glyph within the vector
 * @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) {
        int padTop = unicodeFont.getPaddingTop();
        int padRight = unicodeFont.getPaddingRight();
        int padBottom = unicodeFont.getPaddingBottom();
        int padLeft = unicodeFont.getPaddingLeft();
        int glyphSpacing = 1; // Needed to prevent filtering problems.
        width = (short)(glyphWidth + padLeft + padRight + glyphSpacing);
        height = (short)(glyphHeight + padTop + padBottom + glyphSpacing);
        yOffset = (short)(unicodeFont.getAscent() + bounds.y - padTop);
    }

    shape = vector.getGlyphOutline(index, -bounds.x + unicodeFont.getPaddingLeft(), -bounds.y + unicodeFont.getPaddingTop());

    isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
}
项目:OpenJSharp    文件:TextMeasureTests.java   
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    GlyphMetrics gm;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            gm = gv.getGlyphMetrics(i);
        }
    } while (--numReps >= 0);
}
项目:jdk8u-jdk    文件:TextMeasureTests.java   
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    GlyphMetrics gm;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            gm = gv.getGlyphMetrics(i);
        }
    } while (--numReps >= 0);
}
项目:openjdk-jdk10    文件:TextMeasureTests.java   
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    GlyphMetrics gm;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            gm = gv.getGlyphMetrics(i);
        }
    } while (--numReps >= 0);
}