本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData类的典型用法代码示例。如果您正苦于以下问题:Java BitmapFontData类的具体用法?Java BitmapFontData怎么用?Java BitmapFontData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BitmapFontData类属于com.badlogic.gdx.graphics.g2d.BitmapFont包,在下文中一共展示了BitmapFontData类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paste
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; //导入依赖的package包/类
void paste (String content, boolean fireChangeEvent) {
if (content == null) return;
StringBuilder buffer = new StringBuilder();
int textLength = text.length();
if (hasSelection) textLength -= Math.abs(cursor - selectionStart);
BitmapFontData data = style.font.getData();
for (int i = 0, n = content.length(); i < n; i++) {
if (!withinMaxLength(textLength + buffer.length())) break;
char c = content.charAt(i);
if (!(writeEnters && (c == ENTER_ANDROID || c == ENTER_DESKTOP))) {
if (c == '\r' || c == '\n') continue;
if (onlyFontChars && !data.hasGlyph(c)) continue;
if (filter != null && !filter.acceptChar(this, c)) continue;
}
buffer.append(c);
}
content = buffer.toString();
if (hasSelection) cursor = delete(fireChangeEvent);
if (fireChangeEvent)
changeText(text, insert(cursor, content, text));
else
text = insert(cursor, content, text);
updateDisplayText();
cursor += content.length();
}
示例2: getDependencies
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; //导入依赖的package包/类
public Array<AssetDescriptor> getDependencies(String paramString, BitmapFontLoader.BitmapFontParameter paramBitmapFontParameter)
{
Array localArray = new Array();
if ((paramBitmapFontParameter != null) && (paramBitmapFontParameter.bitmapFontData != null))
{
this.data = paramBitmapFontParameter.bitmapFontData;
return localArray;
}
FileHandle localFileHandle = resolve(paramString);
if (paramBitmapFontParameter != null);
for (boolean bool = paramBitmapFontParameter.flip; ; bool = false)
{
this.data = new BitmapFont.BitmapFontData(localFileHandle, bool);
localArray.add(new AssetDescriptor(this.data.getImagePath(), Texture.class));
return localArray;
}
}
示例3: paste
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; //导入依赖的package包/类
void paste(String content, boolean fireChangeEvent) {
if (content == null)
return;
StringBuilder buffer = new StringBuilder();
int textLength = text.length();
if (hasSelection)
textLength -= Math.abs(cursor - selectionStart);
BitmapFontData data = style.font.getData();
for (int i = 0, n = content.length(); i < n; i++) {
if (!withinMaxLength(textLength + buffer.length()))
break;
char c = content.charAt(i);
if (!(writeEnters && (c == ENTER_ANDROID || c == ENTER_DESKTOP))) {
if (c == '\r' || c == '\n')
continue;
if (onlyFontChars && !data.hasGlyph(c))
continue;
if (filter != null && !filter.acceptChar(this, c))
continue;
}
buffer.append(c);
}
content = buffer.toString();
if (hasSelection)
cursor = delete(fireChangeEvent);
if (fireChangeEvent)
changeText(text, insert(cursor, content, text));
else
text = insert(cursor, content, text);
updateDisplayText();
cursor += content.length();
}
示例4: get
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; //导入依赖的package包/类
public BitmapFont get (FileHandle file, float pixelsPerUnit) {
BitmapFont font = fonts.get(pixelsPerUnit);
if (font == null) {
Texture texture = new Texture(FileUtils.sibling(file, "png"), true);
texture.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear);
font = new BitmapFont(new BitmapFontData(file, false), new TextureRegion(texture), false);
font.getData().setScale(1f / pixelsPerUnit);
fonts.put(pixelsPerUnit, font);
}
return font;
}
示例5: updateDisplayText
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; //导入依赖的package包/类
void updateDisplayText() {
BitmapFont font = style.font;
BitmapFontData data = font.getData();
String text = this.text;
int textLength = text.length();
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < textLength; i++) {
char c = text.charAt(i);
buffer.append(data.hasGlyph(c) ? c : ' ');
}
String newDisplayText = buffer.toString();
if (passwordMode && data.hasGlyph(passwordCharacter)) {
if (passwordBuffer == null)
passwordBuffer = new StringBuilder(newDisplayText.length());
if (passwordBuffer.length() > textLength)
passwordBuffer.setLength(textLength);
else {
for (int i = passwordBuffer.length(); i < textLength; i++)
passwordBuffer.append(passwordCharacter);
}
displayText = passwordBuffer;
} else
displayText = newDisplayText;
layout.setText(font, displayText);
glyphPositions.clear();
float x = 0;
if (layout.runs.size > 0) {
GlyphRun run = layout.runs.first();
FloatArray xAdvances = run.xAdvances;
fontOffset = xAdvances.first();
for (int i = 1, n = xAdvances.size; i < n; i++) {
glyphPositions.add(x);
x += xAdvances.get(i);
}
} else
fontOffset = 0;
glyphPositions.add(x);
if (selectionStart > newDisplayText.length())
selectionStart = textLength;
}
示例6: writeFont
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; //导入依赖的package包/类
/** A utility method which writes the given font data to a file.
*
* The specified pixmaps are written to the parent directory of <tt>outFntFile</tt>, using that file's name without an
* extension for the PNG file name(s).
*
* The specified FontInfo is optional, and can be null.
*
* Typical usage looks like this:
*
* <pre>
* BitmapFontWriter.writeFont(myFontData, myFontPixmaps, Gdx.files.external("fonts/output.fnt"), new FontInfo("Arial", 16));
* </pre>
*
* @param fontData the font data
* @param pages the pixmaps to write as PNGs
* @param outFntFile the output file for the font definition
* @param info the optional font info for the header file, can be null */
public static void writeFont (BitmapFontData fontData, Pixmap[] pages, FileHandle outFntFile, FontInfo info) {
String[] pageRefs = writePixmaps(pages, outFntFile.parent(), outFntFile.nameWithoutExtension());
// write the font data
writeFont(fontData, pageRefs, outFntFile, info, pages[0].getWidth(), pages[0].getHeight());
}
示例7: writeFont
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; //导入依赖的package包/类
/** A utility method which writes the given font data to a file.
*
* The specified pixmaps are written to the parent directory of <tt>outFntFile</tt>, using that file's name without an
* extension for the PNG file name(s).
*
* The specified FontInfo is optional, and can be null.
*
* Typical usage looks like this:
*
* <pre>
* BitmapFontWriter.writeFont(myFontData, myFontPixmaps, Gdx.files.external("fonts/output.fnt"), new FontInfo("Arial", 16));
* </pre>
*
* @param fontData the font data
* @param pages the pixmaps to write as PNGs
* @param outFntFile the output file for the font definition
* @param info the optional font info for the header file, can be null */
public static void writeFont (BitmapFontData fontData, Pixmap[] pages, FileHandle outFntFile, FontInfo info) {
String[] pageRefs = writePixmaps(pages, outFntFile.parent(), outFntFile.nameWithoutExtension());
//write the font data
writeFont(fontData, pageRefs, outFntFile, info, pages[0].getWidth(), pages[0].getHeight());
}
示例8: writeFont
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData; //导入依赖的package包/类
/** A utility method which writes the given font data to a file.
*
* The specified pixmaps are written to the parent directory of <tt>outFntFile</tt>, using that file's name without an
* extension for the PNG file name(s).
*
* The specified FontInfo is optional, and can be null.
*
* Typical usage looks like this:
*
* <pre>
* BitmapFontWriter.writeFont(myFontData, myFontPixmaps, Gdx.files.external("fonts/output.fnt"), new FontInfo("Arial", 16));
* </pre>
*
* @param fontData the font data
* @param pages the pixmaps to write as PNGs
* @param outFntFile the output file for the font definition
* @param info the optional font info for the header file, can be null */
public static void writeFont (BitmapFontData fontData, Pixmap[] pages, FileHandle outFntFile, FontInfo info) {
String[] pageRefs = writePixmaps(pages, outFntFile.parent(), outFntFile.nameWithoutExtension());
// write the font data
writeFont(fontData, pageRefs, outFntFile, info, pages[0].getWidth(), pages[0].getHeight());
}