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


Java BitmapFontData类代码示例

本文整理汇总了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();
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:27,代码来源:VisTextField.java

示例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;
  }
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:18,代码来源:BitmapFontLoader.java

示例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();
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:34,代码来源:TextField.java

示例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;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:16,代码来源:FontCacheModule.java

示例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;
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:45,代码来源:TextField.java

示例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(&quot;fonts/output.fnt&quot;), new FontInfo(&quot;Arial&quot;, 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());
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:24,代码来源:BitmapFontWriter.java

示例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(&quot;fonts/output.fnt&quot;), new FontInfo(&quot;Arial&quot;, 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());
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:24,代码来源:BitmapFontWriter.java

示例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(&quot;fonts/output.fnt&quot;), new FontInfo(&quot;Arial&quot;, 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());
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:24,代码来源:BitmapFontWriter.java


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