當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。