legacy unicode font type: make chars one pixel smaller

This commit is contained in:
Bixilon 2023-06-15 14:07:18 +02:00
parent 4757e7b955
commit cf4d955df0
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 4 additions and 4 deletions

View File

@ -47,7 +47,7 @@ class LegacyUnicodeFontTypeTest {
}
fun firstChar() {
val sizes = byteArrayOf(0x19, 0x12, 0x45)
val sizes = byteArrayOf(0x09, 0x12, 0x45)
val chars = load(sizes)
val char = chars[0]!!
@ -67,7 +67,7 @@ class LegacyUnicodeFontTypeTest {
}
fun secondChar() {
val sizes = byteArrayOf(0x00, 0x28)
val sizes = byteArrayOf(0x00, 0x18)
val chars = load(sizes)
val char = chars[1]!!
@ -78,7 +78,7 @@ class LegacyUnicodeFontTypeTest {
fun `19th char`() {
val sizes = ByteArray(19)
sizes[18] = 0x9E.toByte()
sizes[18] = 0x8E.toByte()
val chars = load(sizes)
val char = chars[18]!!

View File

@ -95,7 +95,7 @@ class LegacyUnicodeFontType(
val widthByte = sizes.read()
if (widthByte < 0) throw IllegalStateException("Unexpected end of sizes stream (pageId=$pageId, x=$x, y=$y)!")
val xStart = maxOf(0, ((widthByte shr 4) and 0x0F) - 1)
val xStart = maxOf(0, ((widthByte shr 4) and 0x0F))
val width = (widthByte and 0x0F) + 1 - xStart