public TerminalRenderer(RenderEngine engine, Tessellator buff) {
this.render = engine;
this.buff = buff;
BufferedImage image;
try {
image = ImageIO.read(getClass().getResourceAsStream(
"/font/default.png"));
} catch (IOException e) {
throw new RuntimeException();
}
int w = image.getWidth();
int h = image.getHeight();
int[] rgbData = new int[w * h];
image.getRGB(0, 0, w, h, rgbData, 0, w);
for (int chrIndex = 0; chrIndex < 256; chrIndex++) {
int x = chrIndex % 16;
int y = chrIndex / 16;
int wide = 7;
while (wide >= 0) {
int baseIndex = x * 8 + wide;
boolean isEmpty = true;
for (int lY = 0; lY < 8; lY++) {
int index = (y * 8 + lY) * w;
if ((rgbData[baseIndex + index] & 0xFF) > 0) {
isEmpty = false;
break;
}
}
if (!isEmpty)
break;
wide--;
}
if (chrIndex == 32) // Space is 2 wide
wide = 2;
charWidth[chrIndex] = (wide + 2);
}
// Fix control chars
for (int index = 0xB0; index < 0xDF; index++)
charWidth[index] = FONT_WIDTH;
// Setup the texture
charTexture = engine.allocateAndSetupTexture(image);
}
TerminalRenderer.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:someluigis-peripherals
作者:
评论列表
文章目录