当前位置: 首页>>代码示例>>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;未经允许,请勿转载。