final eu.svjatoslav.sixth.e3d.renderer.raster.Color textColor) {
final Texture texture = new Texture(text.length()
- * TextCanvas.FONT_CHAR_WIDTH_PIXELS, TextCanvas.FONT_CHAR_HEIGHT_PIXELS,
+ * TextCanvas.FONT_CHAR_WIDTH_TEXTURE_PIXELS, TextCanvas.FONT_CHAR_HEIGHT_TEXTURE_PIXELS,
maxUpscaleFactor);
// texture.graphics.setColor(Color.BLUE);
for (int c = 0; c < text.length(); c++)
texture.graphics.drawChars(new char[]{text.charAt(c),}, 0, 1,
- (c * TextCanvas.FONT_CHAR_WIDTH_PIXELS) - 0,
- (0 * TextCanvas.FONT_CHAR_HEIGHT_PIXELS) + 11);
+ (c * TextCanvas.FONT_CHAR_WIDTH_TEXTURE_PIXELS),
+ (int) (TextCanvas.FONT_CHAR_HEIGHT_TEXTURE_PIXELS / 1.45));
return texture;
}
public class TextCanvas extends TexturedRectangle {
- public static final int FONT_CHAR_WIDTH_PIXELS = 8;
- public static final int FONT_CHAR_HEIGHT_PIXELS = 16;
- public static final Font FONT = CanvasCharacter.getFont(15);
+ // character size in world coordiates
+ public static final int FONT_CHAR_WIDTH = 8;
+ public static final int FONT_CHAR_HEIGHT = 16;
+
+ // character size on texture
+ public static final int FONT_CHAR_WIDTH_TEXTURE_PIXELS = 16;
+ public static final int FONT_CHAR_HEIGHT_TEXTURE_PIXELS = 32;
+
+
+ public static final Font FONT = CanvasCharacter.getFont((int)(FONT_CHAR_HEIGHT_TEXTURE_PIXELS / 1.066));
private static final String GROUP_TEXTURE = "texture";
private static final String GROUP_CHARACTERS = "characters";
private final TextPointer size;
this.foregroundColor = foregroundColor;
// initialize underlying textured rectangle
- initialize(columns * FONT_CHAR_WIDTH_PIXELS, rows * FONT_CHAR_HEIGHT_PIXELS, 0);
+ initialize(
+ columns * FONT_CHAR_WIDTH,
+ rows * FONT_CHAR_HEIGHT,
+ columns * FONT_CHAR_WIDTH_TEXTURE_PIXELS,
+ rows * FONT_CHAR_HEIGHT_TEXTURE_PIXELS,
+ 0);
getTexture().primaryBitmap.fillColor(backgroundColor);
getTexture().resetResampledBitmapCache();
final char character, final Color foreground) {
final Graphics2D graphics = getTexture().graphics;
- getTexture().primaryBitmap.drawRectangle(column * FONT_CHAR_WIDTH_PIXELS, row
- * FONT_CHAR_HEIGHT_PIXELS, (column * FONT_CHAR_WIDTH_PIXELS)
- + FONT_CHAR_WIDTH_PIXELS, (row * FONT_CHAR_HEIGHT_PIXELS) + FONT_CHAR_HEIGHT_PIXELS,
+ getTexture().primaryBitmap.drawRectangle(
+ column * FONT_CHAR_WIDTH_TEXTURE_PIXELS,
+ row * FONT_CHAR_HEIGHT_TEXTURE_PIXELS,
+ (column * FONT_CHAR_WIDTH_TEXTURE_PIXELS) + FONT_CHAR_WIDTH_TEXTURE_PIXELS,
+ (row * FONT_CHAR_HEIGHT_TEXTURE_PIXELS) + FONT_CHAR_HEIGHT_TEXTURE_PIXELS,
backgroundColor);
graphics.setFont(FONT);
graphics.setColor(foreground.toAwtColor());
- graphics.drawChars(new char[]{character,}, 0, 1,
- (column * FONT_CHAR_WIDTH_PIXELS) - 0, (row * FONT_CHAR_HEIGHT_PIXELS) + 13);
+ graphics.drawChars(
+ new char[]{character,}, 0, 1,
+ (column * FONT_CHAR_WIDTH_TEXTURE_PIXELS) - 0,
+ (row * FONT_CHAR_HEIGHT_TEXTURE_PIXELS) + (int)(FONT_CHAR_HEIGHT_TEXTURE_PIXELS / 1.23f));
getTexture().resetResampledBitmapCache();
}
public Point3D getCharLocation(final int row, final int column) {
final Point3D coordinate = topLeft.clone();
- coordinate.translateY((row * FONT_CHAR_HEIGHT_PIXELS)
- + ((FONT_CHAR_HEIGHT_PIXELS / 2) - 3));
+ coordinate.translateY((row * FONT_CHAR_HEIGHT)
+ + (FONT_CHAR_HEIGHT / 3.2));
- coordinate.translateX((column * FONT_CHAR_WIDTH_PIXELS)
- + (FONT_CHAR_WIDTH_PIXELS / 2));
+ coordinate.translateX((column * FONT_CHAR_WIDTH)
+ + (FONT_CHAR_WIDTH / 2));
return coordinate;
}