From 5eecbe89b70d9332e2ca1fa91f4e00bace89b761 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Mon, 6 Nov 2023 16:39:30 +0100 Subject: [PATCH] fix default ascent --- .../font/renderer/code/RasterizedCodePointRendererTest.kt | 4 ++-- .../gui/rendering/font/types/bitmap/BitmapFontTypeTest.kt | 2 +- .../gui/rendering/font/types/dummy/DummyCodePointRenderer.kt | 2 +- .../gui/rendering/font/types/bitmap/BitmapFontType.kt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/renderer/code/RasterizedCodePointRendererTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/renderer/code/RasterizedCodePointRendererTest.kt index 755f1bc62..f94bd8892 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/renderer/code/RasterizedCodePointRendererTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/renderer/code/RasterizedCodePointRendererTest.kt @@ -74,8 +74,8 @@ class RasterizedCodePointRendererTest { fun `12px height`() { val consumer = object : DummyGUIVertexConsumer() { override fun addChar(start: Vec2, end: Vec2, index: Int) { - assertEquals(start, Vec2(10.0f, 11.0f)) // -2 for ascent height difference, +1 for normal spacing - assertEquals(end, Vec2(15.0f, 23.0f)) + assertEquals(start, Vec2(10.0f, 12.0f)) // -2 for ascent height difference, +1 for normal spacing, +1 for ascent fixing? + assertEquals(end, Vec2(15.0f, 24.0f)) } } val char = DummyCodePointRenderer(ascent = 10.0f, height = 12.0f) diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/types/bitmap/BitmapFontTypeTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/types/bitmap/BitmapFontTypeTest.kt index 5df11b8a6..3e2cb00ce 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/types/bitmap/BitmapFontTypeTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/types/bitmap/BitmapFontTypeTest.kt @@ -65,7 +65,7 @@ class BitmapFontTypeTest { return texture } - private fun load(start: IntArray, end: IntArray, width: Int = 8, height: Int = 8, ascent: Int = 8, chars: Array): BitmapFontType { + private fun load(start: IntArray, end: IntArray, width: Int = 8, height: Int = 8, ascent: Int = 7, chars: Array): BitmapFontType { val texture = createTexture(start, end, width, height, chars.size) val fontType = LOAD(BitmapFontType, texture, height, ascent, chars.map { IntStream.of(*it) }.toTypedArray()) as BitmapFontType diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/types/dummy/DummyCodePointRenderer.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/types/dummy/DummyCodePointRenderer.kt index b3409d024..74383b1b1 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/types/dummy/DummyCodePointRenderer.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/font/types/dummy/DummyCodePointRenderer.kt @@ -21,7 +21,7 @@ class DummyCodePointRenderer( override val uvStart: Vec2 = Vec2(0.1f, 0.2f), override val uvEnd: Vec2 = Vec2(0.6f, 0.7f), override val width: Float = 5.0f, - override val ascent: Float = 8.0f, + override val ascent: Float = 7.0f, override val height: Float = 8.0f, ) : AscentedCodePointRenderer { override val texture = DummyTexture() diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/font/types/bitmap/BitmapFontType.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/font/types/bitmap/BitmapFontType.kt index 6453342cb..8f3e89e26 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/font/types/bitmap/BitmapFontType.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/font/types/bitmap/BitmapFontType.kt @@ -65,7 +65,7 @@ class BitmapFontType( override fun build(context: RenderContext, manager: FontManager, data: JsonObject): BitmapFontType? { val file = data["file"]?.toString()?.let { it.toResourceLocation().texture() } ?: throw IllegalArgumentException("Missing file!") val height = data["height"]?.toInt() ?: 8 - val ascent = data["ascent"]?.toInt() ?: 8 + val ascent = data["ascent"]?.toInt() ?: 7 val chars = data["chars"]?.listCast() ?: throw IllegalArgumentException("Missing chars!") return load(file, height, ascent, chars, context) }