com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VisTextField.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #2
Source File: PatchedVisTextField.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
protected void drawText(Batch batch, BitmapFont font, float x, float y) {
	//PATCH: Disabled color markup for BitmapFont when updating GlyphLayout https://github.com/libgdx/libgdx/issues/4576
	BitmapFontData fontData = font.getData();
	boolean markupEnabled = fontData.markupEnabled;
	fontData.markupEnabled = false;
	super.drawText(batch, font, x, y);
	fontData.markupEnabled = markupEnabled;
}
 
Example #3
Source File: DialogFonts.java    From skin-composer with MIT License 4 votes vote down vote up
private void checkExistingDrawablesDialog(List<File> files, Runnable runnable) {
    boolean execute = true;
    
    fontLoop : for (var fontFile : files) {
        var bitmapFontData = new BitmapFontData(new FileHandle(fontFile), false);
        for (var imagePath : bitmapFontData.imagePaths) {
            var imageFile = new FileHandle(imagePath);
            if (main.getAtlasData().getDrawable(imageFile.nameWithoutExtension()) != null) {
                execute = false;
                break fontLoop;
            }
        }
    }
    
    if (execute) {
        runnable.run();
    } else {
        var dialog = new Dialog("Override Drawables?", getSkin()) {
            @Override
            protected void result(Object object) {
                if ((Boolean) object) {
                    runnable.run();
                }
            }
        };
        dialog.getTitleTable().padLeft(5);
        dialog.getContentTable().pad(5).padBottom(0);
        dialog.getButtonTable().pad(5);
        
        dialog.text("This font will override existing drawables.\n"
                + "Proceed?");
        
        var textButton = new TextButton("OK", getSkin());
        textButton.addListener(main.getHandListener());
        dialog.button(textButton, true);
        
        textButton = new TextButton("Cancel", getSkin());
        textButton.addListener(main.getHandListener());
        dialog.button(textButton, false);
        
        dialog.key(Keys.ENTER, true).key(Keys.ESCAPE, false);
        
        dialog.show(getStage());
    }
}
 
Example #4
Source File: BitmapFontWriter.java    From gdx-smart-font with MIT License 3 votes vote down vote up
/** 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());
}
 
Example #5
Source File: BitmapFontWriter.java    From Cubes with MIT License 3 votes vote down vote up
/** 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());
}
 
Example #6
Source File: BitmapFontWriter.java    From gdx-proto with Apache License 2.0 3 votes vote down vote up
/** 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());
}