/** Calls {@link #setText(BitmapFont, CharSequence, int, int, Color, float, int, boolean, String) setText} with the whole * string, the font's current color, and no alignment or wrapping. */ public void setText (BitmapFont font, CharSequence str) { setText(font, str, 0, str.length(), font.getColor(), 0, Align.left, false, null); }
/** Calls {@link #setText(BitmapFont, CharSequence, int, int, Color, float, int, boolean, String) setText} with the whole * string, the font's current color, and no alignment or wrapping. */ public void setText (BitmapFont font, CharSequence str) { setText(font, str, 0, str.length(), font.getColor(), 0, Align.left, false, null); }
/** Calls {@link #setText(BitmapFont, CharSequence, int, int, Color, float, int, boolean, String) setText} with the whole * string, the font's current color, and no alignment or wrapping. */ public void setText (BitmapFont font, CharSequence str) { setText(font, str, 0, str.length(), font.getColor(), 0, Align.left, false, null); }
/** * Use the specified Batch to draw a String (often just one char long) with the default color (white), with x and y * determining the world-space coordinates for the upper-left corner. * * @param batch the LibGDX Batch to do the drawing * @param s the string to draw, often but not necessarily one char. Can be null to draw a solid block instead. * @param x x of the upper-left corner of the region of text in world coordinates. * @param y y of the upper-left corner of the region of text in world coordinates. */ public void draw(Batch batch, String s, float x, float y) { if (!initialized) { throw new IllegalStateException("This factory has not yet been initialized!"); } // + descent * 3 / 2f // - distanceFieldScaleY / 12f //height - lineTweak * 2f if (s == null || s.isEmpty() || s.charAt(0) == 0) { batch.setColor(1f,1f,1f,1f); batch.draw(block, x, y - actualCellHeight, actualCellWidth, actualCellHeight); // + descent * 1 / 3f } else { batch.setColor(SColor.FLOAT_WHITE); // round trip so FilterBatch can filter BitmapFontCache Color.abgr8888ToColor(bmpFont.getColor(), batch.getPackedColor()); bmpFont.draw(batch, s, x, y - descent + 1/* * 1.5f*//* - lineHeight * 0.2f */ /* + descent*/, width, Align.center, false); } }
/** * Use the specified Batch to draw a char with the default color (white), with x and y determining the world-space * coordinates for the upper-left corner. If c is {@code '\0'}, will draw a solid white block instead. * * @param batch the LibGDX Batch to do the drawing * @param c the char to draw. Can be {@code '\0'} to draw a solid block instead. * @param x x of the upper-left corner of the region of text in world coordinates. * @param y y of the upper-left corner of the region of text in world coordinates. */ public void draw(Batch batch, char c, float x, float y) { if (!initialized) { throw new IllegalStateException("This factory has not yet been initialized!"); } // + descent * 3 / 2f // - distanceFieldScaleY / 12f //height - lineTweak * 2f if (c == 0) { batch.setColor(1f,1f,1f,1f); batch.draw(block, x, y - actualCellHeight, actualCellWidth, actualCellHeight); // + descent * 1 / 3f } else { batch.setColor(SColor.FLOAT_WHITE); // round trip so FilterBatch can filter BitmapFontCache Color.abgr8888ToColor(bmpFont.getColor(), batch.getPackedColor()); mut.setCharAt(0, getOrDefault(c)); bmpFont.draw(batch, mut, x, y - descent + 1/* * 1.5f*//* - lineHeight * 0.2f */ /* + descent*/, width, Align.center, false); } } /**
/** * Use the specified Batch to draw a char in the specified LibGDX Color, with x and y * determining the world-space coordinates for the upper-left corner. * * @param batch the LibGDX Batch to do the drawing * @param c the char to draw. Can be {@code '\0'} to draw a solid block instead. * @param color the LibGDX Color (or SquidLib SColor) to use, as an object * @param x x of the upper-left corner of the region of text in world coordinates. * @param y y of the upper-left corner of the region of text in world coordinates. */ public void draw(Batch batch, char c, Color color, float x, float y) { if (!initialized) { throw new IllegalStateException("This factory has not yet been initialized!"); } if (c == 0) { float orig = batch.getPackedColor(); batch.setColor(color); batch.draw(block, x, y - actualCellHeight, actualCellWidth, actualCellHeight); batch.setColor(orig); } else { batch.setColor(color); // round trip so FilterBatch can filter BitmapFontCache Color.abgr8888ToColor(bmpFont.getColor(), batch.getPackedColor()); mut.setCharAt(0, getOrDefault(c)); bmpFont.draw(batch, mut, x, y - descent + 1, width, Align.center, false); } }
/** * Use the specified Batch to draw a String (often just one char long) in the specified LibGDX Color, with x and y * determining the world-space coordinates for the upper-left corner. * * @param batch the LibGDX Batch to do the drawing * @param c the char to draw. Can be {@code '\0'} to draw a solid block instead. * @param encodedColor the LibGDX Color to use, converted to float as by {@link Color#toFloatBits()} * @param x x of the upper-left corner of the region of text in world coordinates. * @param y y of the upper-left corner of the region of text in world coordinates. */ public void draw(Batch batch, char c, float encodedColor, float x, float y) { if (!initialized) { throw new IllegalStateException("This factory has not yet been initialized!"); } if (c == 0) { float orig = batch.getPackedColor(); batch.setColor(encodedColor); batch.draw(block, x, y - actualCellHeight, actualCellWidth, actualCellHeight); batch.setColor(orig); } else { batch.setColor(encodedColor); // round trip so FilterBatch can filter BitmapFontCache Color.abgr8888ToColor(bmpFont.getColor(), batch.getPackedColor()); mut.setCharAt(0, getOrDefault(c)); bmpFont.draw(batch, mut, x, y - descent + 1, width, Align.center, false); } }
Color.abgr8888ToColor(bmpFont.getColor(), batch.getPackedColor()); bmpFont.draw(batch, s, x, y - descent + 1, width, Align.center, false);
} else { Color.abgr8888ToColor(bmpFont.getColor(), batch.getPackedColor()); bmpFont.draw(batch, s, x, y - descent + 1, width, Align.center, false);
} else { Color.abgr8888ToColor(bmpFont.getColor(), batch.getPackedColor()); bmpFont.draw(batch, s, x, y - descent + 1, width, Align.center, false);
public static void setLineHeight(Label label, float height) { BitmapFont font = label.getStyle().font; BitmapFont.BitmapFontData copiedData = new BitmapFont.BitmapFontData(font.getData().fontFile, font.getData().flipped); copiedData.setLineHeight(height); Label.LabelStyle style = new Label.LabelStyle(new BitmapFont(copiedData, font.getRegion(), true), new Color(font.getColor())); label.setStyle(style); }