当前位置: 首页>>代码示例>>Java>>正文


Java GlyphMetrics.getAdvance方法代码示例

本文整理汇总了Java中java.awt.font.GlyphMetrics.getAdvance方法的典型用法代码示例。如果您正苦于以下问题:Java GlyphMetrics.getAdvance方法的具体用法?Java GlyphMetrics.getAdvance怎么用?Java GlyphMetrics.getAdvance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.font.GlyphMetrics的用法示例。


在下文中一共展示了GlyphMetrics.getAdvance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: findAdvance

import java.awt.font.GlyphMetrics; //导入方法依赖的package包/类
@Override
public final float findAdvance(final char c) {

    // Check producer's inventory first
    final Glyph glyph = createGlyph(c);
    if (glyph != null) {
        return glyph.advance;
    }

    // Otherwise create the glyph vector
    final GlyphVector gv = createGlyphVector(c);
    final GlyphMetrics gm = gv.getGlyphMetrics(0);
    return gm.getAdvance();
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:15,代码来源:AbstractGlyphProducer.java


注:本文中的java.awt.font.GlyphMetrics.getAdvance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。