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


Java GlyphVector.getGlyphPixelBounds方法代碼示例

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


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

示例1: getGlyphMetrics

import java.awt.font.GlyphVector; //導入方法依賴的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

示例2: runTest

import java.awt.font.GlyphVector; //導入方法依賴的package包/類
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Rectangle2D r;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            r = gv.getGlyphPixelBounds(i, null, 0, 0); // !!! add opt to provide different frc?
        }
    } while (--numReps >= 0);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:TextMeasureTests.java

示例3: getGlyphBounds

import java.awt.font.GlyphVector; //導入方法依賴的package包/類
/**
 * Returns the bounds of the specified glyph.\
 * 
 * @param vector The vector the glyph is part of
 * @param index The index of the glyph within the vector
 * @param codePoint The code point associated with the glyph
 */
private Rectangle getGlyphBounds (GlyphVector vector, int index, int codePoint) {
	Rectangle bounds = vector.getGlyphPixelBounds(index, GlyphPage.renderContext, 0, 0);
	if (codePoint == ' ') bounds.width = spaceWidth;
	return bounds;
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:13,代碼來源:UnicodeFont.java


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