當前位置: 首頁>>代碼示例>>Java>>正文


Java GlyphMetrics類代碼示例

本文整理匯總了Java中java.awt.font.GlyphMetrics的典型用法代碼示例。如果您正苦於以下問題:Java GlyphMetrics類的具體用法?Java GlyphMetrics怎麽用?Java GlyphMetrics使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GlyphMetrics類屬於java.awt.font包,在下文中一共展示了GlyphMetrics類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getGlyphMetrics

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:StandardGlyphVector.java

示例2: getGlyphMetrics

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
@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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:StandardGlyphVector.java

示例3: getGlyph

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
@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;
}
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:24,代碼來源:FontSystem.java

示例4: getGlyphLogicalBounds

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
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]);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:20,代碼來源:FreetypeGlyphVector.java

示例5: getGlyphLogicalBounds

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
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]);
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:20,代碼來源:FreetypeGlyphVector.java

示例6: getWrappedGlyphVector

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
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;
}
 
開發者ID:Icenowy,項目名稱:jcadencii,代碼行數:27,代碼來源:BLabel.java

示例7: Glyph

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
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);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:27,代碼來源:Glyph.java

示例8: LinuxGlyph

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:LinuxGlyph.java

示例9: WinGlyph

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:WinGlyph.java

示例10: getGlyphMetrics

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
@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;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:FLGlyph.java

示例11: writeGlyph

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
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);
}
 
開發者ID:phuseman,項目名稱:r2cat,代碼行數:24,代碼來源:PDFFontEmbedderType3.java

示例12: Glyph

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:36,代碼來源:Glyph.java

示例13: getGlyphMetrics

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
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};
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:13,代碼來源:BMFontUtil.java

示例14: runTest

import java.awt.font.GlyphMetrics; //導入依賴的package包/類
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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:TextMeasureTests.java


注:本文中的java.awt.font.GlyphMetrics類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。