本文整理汇总了Java中org.newdawn.slick.font.GlyphPage类的典型用法代码示例。如果您正苦于以下问题:Java GlyphPage类的具体用法?Java GlyphPage怎么用?Java GlyphPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GlyphPage类属于org.newdawn.slick.font包,在下文中一共展示了GlyphPage类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initializeFont
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* Initialise the font to be used based on configuration
*
* @param baseFont The AWT font to render
* @param size The point size of the font to generated
* @param bold True if the font should be rendered in bold typeface
* @param italic True if the font should be rendered in bold typeface
*/
private void initializeFont(Font baseFont, int size, boolean bold, boolean italic) {
Map attributes = baseFont.getAttributes();
attributes.put(TextAttribute.SIZE, new Float(size));
attributes.put(TextAttribute.WEIGHT, bold ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR);
attributes.put(TextAttribute.POSTURE, italic ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR);
try {
attributes.put(TextAttribute.class.getDeclaredField("KERNING").get(null), TextAttribute.class.getDeclaredField(
"KERNING_ON").get(null));
} catch (Exception ignored) {
}
font = baseFont.deriveFont(attributes);
FontMetrics metrics = GlyphPage.getScratchGraphics().getFontMetrics(font);
ascent = metrics.getAscent();
descent = metrics.getDescent();
leading = metrics.getLeading();
// Determine width of space glyph (getGlyphPixelBounds gives a width of zero).
char[] chars = " ".toCharArray();
GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
spaceWidth = vector.getGlyphLogicalBounds(0).getBounds().width;
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:31,代码来源:UnicodeFont.java
示例2: clearGlyphs
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* Clears all loaded and queued glyphs.
*/
public void clearGlyphs () {
for (int i = 0; i < PAGES; i++)
glyphs[i] = null;
for (Iterator iter = glyphPages.iterator(); iter.hasNext();) {
GlyphPage page = (GlyphPage)iter.next();
try {
page.getImage().destroy();
} catch (SlickException ignored) {
}
}
glyphPages.clear();
if (baseDisplayListID != -1) {
GL.glDeleteLists(baseDisplayListID, displayLists.size());
baseDisplayListID = -1;
}
queuedGlyphs.clear();
missingGlyph = null;
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:25,代码来源:UnicodeFont.java
示例3: findWidth
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* @param text the string to find the width of
* @param logical whether to add the space the letters should occupy on the end
* @return width of string.
*/
private int findWidth(String text,boolean logical) {
char[] chars = text.toCharArray();
GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
int width = 0;
int extraX = 0;
boolean startNewLine = false;
for (int glyphIndex = 0, n = vector.getNumGlyphs(); glyphIndex < n; glyphIndex++) {
int charIndex = vector.getGlyphCharIndex(glyphIndex);
int codePoint = text.codePointAt(charIndex);
Rectangle bounds = logical ? vector.getLogicalBounds().getBounds() : getGlyphBounds(vector, glyphIndex, codePoint);
if (startNewLine && codePoint != '\n') extraX = -bounds.x;
if (glyphIndex > 0) extraX += paddingLeft + paddingRight + paddingAdvanceX;
width = Math.max(width, bounds.x + extraX + bounds.width);
if (codePoint == '\n') startNewLine = true;
}
return width;
}
开发者ID:SkidJava,项目名称:BaseClient,代码行数:28,代码来源:UnicodeFont.java
示例4: initializeFont
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* Initialise the font to be used based on configuration
*
* @param baseFont The AWT font to render
* @param size The point size of the font to generated
* @param bold True if the font should be rendered in bold typeface
* @param italic True if the font should be rendered in bold typeface
*/
@SuppressWarnings({"unchecked","rawtypes"})
private void initializeFont(@Nonnull Font baseFont, int size, boolean bold, boolean italic) {
Map attributes = baseFont.getAttributes();
attributes.put(TextAttribute.SIZE, (float) size);
attributes.put(TextAttribute.WEIGHT, bold ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR);
attributes.put(TextAttribute.POSTURE, italic ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR);
try {
attributes.put(TextAttribute.class.getDeclaredField("KERNING").get(null), TextAttribute.class.getDeclaredField(
"KERNING_ON").get(null));
} catch (Exception ignored) {
}
font = baseFont.deriveFont(attributes);
FontMetrics metrics = GlyphPage.getScratchGraphics().getFontMetrics(font);
ascent = metrics.getAscent();
descent = metrics.getDescent();
leading = metrics.getLeading();
// Determine width of space glyph (getGlyphPixelBounds gives a width of zero).
char[] chars = " ".toCharArray();
GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
spaceWidth = vector.getGlyphLogicalBounds(0).getBounds().width;
}
开发者ID:FOShameDotOrg,项目名称:fuzzy-octo-shame,代码行数:33,代码来源:UnicodeFont.java
示例5: clearGlyphs
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* Clears all loaded and queued glyphs.
*/
void clearGlyphs() {
for (int i = 0; i < PAGES; i++)
glyphs[i] = null;
for (GlyphPage page : glyphPages) {
page.getImage().destroy();
}
glyphPages.clear();
if (baseDisplayListID != -1) {
GL.glDeleteLists(baseDisplayListID, displayLists.size());
baseDisplayListID = -1;
}
queuedGlyphs.clear();
missingGlyph = null;
}
开发者ID:FOShameDotOrg,项目名称:fuzzy-octo-shame,代码行数:21,代码来源:UnicodeFont.java
示例6: addGlyphs
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* Queues the glyphs in the specified text to be loaded. Note that the glyphs are not actually loaded until
* {@link #loadGlyphs()} is called.
*
* @param text The text containing the glyphs to be added
*/
public void addGlyphs(String text) {
if (text == null) throw new IllegalArgumentException("text cannot be null.");
char[] chars = text.toCharArray();
GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
for (int i = 0, n = vector.getNumGlyphs(); i < n; i++) {
int codePoint = text.codePointAt(vector.getGlyphCharIndex(i));
if (backup != null && !font.canDisplay((char) codePoint) && backup.getFont().canDisplay((char) codePoint)) {
addBackupGlyphs(new String(Character.toChars(codePoint)));
continue;
}
Rectangle bounds = getGlyphBounds(vector, i, codePoint);
getGlyph(vector.getGlyphCode(i), codePoint, bounds, vector, i);
}
}
开发者ID:itdelatrisu,项目名称:opsu,代码行数:22,代码来源:UnicodeFont.java
示例7: addGlyphs
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* Queues the glyphs in the specified text to be loaded. Note that the glyphs are not actually loaded until
* {@link #loadGlyphs()} is called.
*
* @param text The text containing the glyphs to be added
*/
public void addGlyphs(String text) {
if (text == null) throw new IllegalArgumentException("text cannot be null.");
char[] chars = text.toCharArray();
GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
for (int i = 0, n = vector.getNumGlyphs(); i < n; i++) {
int codePoint = text.codePointAt(vector.getGlyphCharIndex(i));
Rectangle bounds = getGlyphBounds(vector, i, codePoint);
getGlyph(vector.getGlyphCode(i), codePoint, bounds, vector, i);
}
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:18,代码来源:UnicodeFont.java
示例8: getHeight
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* @see org.newdawn.slick.Font#getHeight(java.lang.String)
*/
public int getHeight (String text) {
if (text == null) throw new IllegalArgumentException("text cannot be null.");
if (text.length() == 0) return 0;
if (displayListCaching) {
DisplayList displayList = (DisplayList)displayLists.get(text);
if (displayList != null) return displayList.height;
}
char[] chars = text.toCharArray();
GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
int lines = 0, height = 0;
for (int i = 0, n = vector.getNumGlyphs(); i < n; i++) {
int charIndex = vector.getGlyphCharIndex(i);
int codePoint = text.codePointAt(charIndex);
if (codePoint == ' ') continue;
Rectangle bounds = getGlyphBounds(vector, i, codePoint);
height = Math.max(height, ascent + bounds.y + bounds.height);
if (codePoint == '\n') {
lines++;
height = 0;
}
}
return lines * getLineHeight() + height;
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:32,代码来源:UnicodeFont.java
示例9: getScratchImage
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* Returns an image that can be used by effects as a temp image.
*
* @return The scratch image used for temporary operations
*/
static public BufferedImage getScratchImage() {
Graphics2D g = (Graphics2D)scratchImage.getGraphics();
g.setComposite(AlphaComposite.Clear);
g.fillRect(0, 0, GlyphPage.MAX_GLYPH_SIZE, GlyphPage.MAX_GLYPH_SIZE);
g.setComposite(AlphaComposite.SrcOver);
g.setColor(java.awt.Color.white);
return scratchImage;
}
开发者ID:j-dong,项目名称:trashjam2017,代码行数:14,代码来源:EffectUtil.java
示例10: getGlyphMetrics
import org.newdawn.slick.font.GlyphPage; //导入依赖的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
示例11: addGlyphs
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* Queues the glyphs in the specified text to be loaded. Note that the glyphs are not actually loaded until
* {@link #loadGlyphs()} is called.
*
* @param text The text containing the glyphs to be added
*/
void addGlyphs(@Nullable String text) {
if (text == null) throw new IllegalArgumentException("text cannot be null.");
char[] chars = text.toCharArray();
GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
for (int i = 0, n = vector.getNumGlyphs(); i < n; i++) {
int codePoint = text.codePointAt(vector.getGlyphCharIndex(i));
Rectangle bounds = getGlyphBounds(vector, i, codePoint);
getGlyph(vector.getGlyphCode(i), codePoint, bounds, vector, i);
}
}
开发者ID:FOShameDotOrg,项目名称:fuzzy-octo-shame,代码行数:18,代码来源:UnicodeFont.java
示例12: getHeight
import org.newdawn.slick.font.GlyphPage; //导入依赖的package包/类
/**
* @see org.newdawn.slick.Font#getHeight(CharSequence)
*/
public int getHeight (@Nullable CharSequence text) {
if (text == null) throw new IllegalArgumentException("text cannot be null.");
if (text.length() == 0) return 0;
if (displayListCaching) {
DisplayList displayList = displayLists.get(text);
if (displayList != null) return displayList.height;
}
char[] chars = toCharArray(text, 0, text.length());
GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
int lines = 0, height = 0;
for (int i = 0, n = vector.getNumGlyphs(); i < n; i++) {
int charIndex = vector.getGlyphCharIndex(i);
int codePoint = Character.codePointAt(text, charIndex);
if (codePoint == ' ') continue;
Rectangle bounds = getGlyphBounds(vector, i, codePoint);
height = Math.max(height, ascent + bounds.y + bounds.height);
if (codePoint == '\n') {
lines++;
height = 0;
}
}
return lines * getLineHeight() + height;
}
开发者ID:FOShameDotOrg,项目名称:fuzzy-octo-shame,代码行数:32,代码来源:UnicodeFont.java
注:本文中的org.newdawn.slick.font.GlyphPage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论