diff --git a/assets/opencomputers/textures/font/ascii.png b/assets/opencomputers/textures/font/ascii.png index c3f1f5e5f..d6b81c9ef 100644 Binary files a/assets/opencomputers/textures/font/ascii.png and b/assets/opencomputers/textures/font/ascii.png differ diff --git a/li/cil/oc/client/gui/MonospaceFontRenderer.scala b/li/cil/oc/client/gui/MonospaceFontRenderer.scala index 073665b23..a48b55721 100644 --- a/li/cil/oc/client/gui/MonospaceFontRenderer.scala +++ b/li/cil/oc/client/gui/MonospaceFontRenderer.scala @@ -30,40 +30,31 @@ object MonospaceFontRenderer { // Set up the display lists. { - // The font texture is 16x12, but chars are really only 10x12. - val charsPerRow = 16 val (charWidth, charHeight) = (MonospaceFontRenderer.fontWidth * 2, MonospaceFontRenderer.fontHeight * 2) - val uStep = 1.0 / charsPerRow - val vStep = 1.0 / 12 * 240 / 256 // Correct for padding at bottom. - val uOffset = uStep * 3 / 16 - val uSize = uStep * 10 / 16 - val vOffset = vStep * 1 / 20 - val vSize = vStep * 18 / 20 + val cols = 256 / charWidth + val uStep = charWidth / 256.0 + val vStep = charHeight / 256.0 val t = Tessellator.instance - // Special case for whitespace: just translate, don't render. - GL11.glNewList(charLists + 32, GL11.GL_COMPILE) - GL11.glTranslatef(charWidth, 0, 0) - GL11.glEndList() // Now create lists for all printable chars. - for (index <- (33 until 0x7F).union(0x9F until 0xFF)) { - // The font texture does not contain the 0-1F range, nor the 0x7F to - // 0x9F range (control chars as per Character.isISOControl). - val textureIndex = - (if (index - 32 >= 0x7F) index - (0x9F - 0x7F) else index) - 32 - val x = textureIndex % charsPerRow - val y = textureIndex / charsPerRow - val u = x * uStep + uOffset - val v = y * vStep + vOffset + for (index <- 1 until 0xFF) { + val x = (index - 1) % cols + val y = (index - 1) / cols + val u = x * uStep + val v = y * vStep GL11.glNewList(charLists + index, GL11.GL_COMPILE) t.startDrawingQuads() - t.addVertexWithUV(0, charHeight, 0, u, v + vSize) - t.addVertexWithUV(charWidth, charHeight, 0, u + uSize, v + vSize) - t.addVertexWithUV(charWidth, 0, 0, u + uSize, v) + t.addVertexWithUV(0, charHeight, 0, u, v + vStep) + t.addVertexWithUV(charWidth, charHeight, 0, u + uStep, v + vStep) + t.addVertexWithUV(charWidth, 0, 0, u + uStep, v) t.addVertexWithUV(0, 0, 0, u, v) t.draw() GL11.glTranslatef(charWidth, 0, 0) GL11.glEndList() } + // Special case for whitespace: just translate, don't render. + GL11.glNewList(charLists + ' ', GL11.GL_COMPILE) + GL11.glTranslatef(charWidth, 0, 0) + GL11.glEndList() } def drawString(value: Array[Char], x: Int, y: Int) = {