/** Configures the font used to display the HUD. Must be called before adding rows. */ public Hud setFont (Font font) { if (!_rows.isEmpty()) throw new IllegalStateException("Set font before adding rows."); _fmt = _fmt.withFont(font); return this; }
/** Returns a clone of this text format with the font configured as specified. */ public TextFormat withFont(String name, Font.Style style, float size) { return withFont(new Font(name, style, size)); } /** Returns a clone of this text format with the font configured as specified. */
/** Returns a clone of this text format with the font configured as specified. */ public TextFormat withFont(String name, Font.Style style, float size) { return withFont(new Font(name, style, size)); } /** Returns a clone of this text format with the font configured as specified. */
/** Returns a clone of this text format with the font configured as specified. */ public TextFormat withFont(String name, float size) { return withFont(new Font(name, size)); }
/** Returns a clone of this text format with the font configured as specified. */ public TextFormat withFont(String name, float size) { return withFont(new Font(name, size)); }
public void draw(Canvas canvas) { // draw a rounded rect directly canvas.setFillGradient(graphics().createLinearGradient( 0, 0, 100, 100, new int[] { 0xFF0000FF, 0xFF00FF00 }, new float[] { 0, 1 })); TextLayout capF = graphics().layoutText("F", new TextFormat().withFont(F_FONT.derive(96))); canvas.fillText(capF, 15, 5); } });
public void draw(Canvas canvas) { canvas.setFillColor(0xFFCCCCCC).fillRect(0, 0, 50, 50); canvas.setFillColor(0xFFCCCCCC).fillRect(50, 50, 50, 50); TextLayout capF = graphics().layoutText("F", new TextFormat().withFont(F_FONT)); float theta = -FloatMath.PI/4, tsin = FloatMath.sin(theta), tcos = FloatMath.cos(theta); canvas.setFillColor(0xFF000000).fillText(capF, 0, 0); canvas.transform(tcos, -tsin, tsin, tcos, 50, 50); canvas.setFillColor(0xFF000000).fillText(capF, 0, 0); } });
@Override public void init() { String text = "The quick brown fox jumped over the lazy dog."; TextFormat format = new TextFormat(). withFont(graphics().createFont("Helvetica", Font.Style.PLAIN, 18)); TextBlock block = new TextBlock(graphics().layoutText(text, format, new TextWrap(100))); float x = 5; for (float scale : new float[] { 1f, 2f, 3f }) { float swidth = block.bounds.width() * scale, sheight = block.bounds.height() * scale; CanvasImage image = graphics().createImage(swidth, sheight); image.canvas().setStrokeColor(0xFFFFCCCC).strokeRect(0, 0, swidth-0.5f, sheight-0.5f); image.canvas().scale(scale, scale); image.canvas().setFillColor(0xFF000000); block.fill(image.canvas(), TextBlock.Align.RIGHT, 0, 0); graphics().rootLayer().addAt(graphics().createImageLayer(image), x, 5); addInfo(image, x + swidth/2, sheight + 10); x += swidth + 5; } }