/** Derives a font with the same name and style as this one, at the specified size. */ public Font derive (float size) { return new Font(name, style, size); }
@Override public boolean equals(Object other) { if (other instanceof TextFormat) { TextFormat ofmt = (TextFormat)other; return (font == ofmt.font || (font != null && font.equals(ofmt.font))) && antialias == ofmt.antialias; } else { return false; } }
static void configContext(Context2d ctx, TextFormat format) { Font font = getFont(format); String style = ""; switch (font.style()) { case BOLD: style = "bold"; break; case ITALIC: style = "italic"; break; case BOLD_ITALIC: style = "bold italic"; break; default: break; // nada } ctx.setFont(style + " " + font.size() + "px " + font.name()); ctx.setTextBaseline(Context2d.TextBaseline.TOP); }
int y = oldFont.getBaseline(); int x = 0; int i = 0; Font font = oldFont.derive(Font.PLAIN, size--); g.setFont(font); x += font.getAdvance(content, i, length); i += length;
int fontWidth = ScreenDimension.getFontWidth(); return fontWidth == 320 ? new DefaultTextRenderer(gc, baseFont.derive(Font.PLAIN,10,Ui.UNITS_pt), baseFont.derive(Font.PLAIN,6,Ui.UNITS_pt)) : new DefaultTextRenderer(gc, baseFont.derive(Font.PLAIN,12,Ui.UNITS_pt), baseFont.derive(Font.PLAIN,8,Ui.UNITS_pt)); int pixelWidth = font.getAdvance(text); gc.setFont(font);
@Override public int hashCode() { int hash = (antialias ? 1 : 0); if (font != null) hash ^= font.hashCode(); return hash; } }
@Override public int hashCode() { int hash = (antialias ? 1 : 0); if (font != null) hash ^= font.hashCode(); return hash; } }
/** Derives a font with the same name and style as this one, at the specified size. */ public Font derive (float size) { return new Font(name, style, size); }
@Override public Block resize (float size) { return new Block(_gfx, text, style.withFont(style.font.derive(size)), wrap, align); }
@Override public boolean equals(Object other) { if (other instanceof TextFormat) { TextFormat ofmt = (TextFormat)other; return (font == ofmt.font || (font != null && font.equals(ofmt.font))) && antialias == ofmt.antialias; } else { return false; } }
@Override public Span resize (float size) { return new Span(_gfx, text, style.withFont(style.font.derive(size))); }
if (_font == null || !_font.equals(nfont)) {
/** 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. */
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); } });
/** 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. */
TextLayout capF = game.graphics.layoutText("F", new TextFormat(F_FONT.derive(96))); canvas.fillText(capF, 15, 5); });
/** 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)); }