Java 类com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData 实例源码

项目:vis-editor    文件:VisTextField.java   
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();
}
项目:ingress-indonesia-dev    文件:BitmapFontLoader.java   
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;
  }
}
项目:gaiasky    文件:TextField.java   
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();
}
项目:vis-editor    文件:FontCacheModule.java   
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;
}
项目:gaiasky    文件:TextField.java   
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;
}
项目:Cubes_2    文件:BitmapFontWriter.java   
/** 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());
}
项目:Cubes    文件:BitmapFontWriter.java   
/** 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());
}
项目:JavityEngine    文件:BitmapFontWriter.java   
/** 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());
}
项目:libgdxcn    文件:BitmapFontWriter.java   
/** 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());
}
项目:gdx-smart-font    文件:BitmapFontWriter.java   
/** 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());
}
项目:gdx-proto    文件:BitmapFontWriter.java   
/** 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());
}