Skip to content

Commit

Permalink
Fixes characters from being slightly displaced and spaces showing a d…
Browse files Browse the repository at this point in the history
…ot in a LazyBitmapFont
  • Loading branch information
soywiz committed Jan 26, 2023
1 parent c8f7b34 commit 22b12d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,17 @@ class LazyBitmapFont(
}

val entry = atlas.add(rbmp, Unit)
val slice = entry.slice
val slice = entry.slice.sliceWithBounds(border, border, entry.slice.width - border, entry.slice.height - border)

//val slice = bmp.slice()
//val fm = result.fmetrics
val g = result.glyphs.first()
//val fm = it.data.fmetrics
val m = g.metrics
val xadvance = m.xadvance

//println("codePoint='$codePoint': $slice, gx=${g.x}, gy=${g.y}")

//println("codePoint=$codePoint, char='${codePoint.toChar()}', xadvance=${xadvance}, height=${m.height}, top=${m.top}, ascent=${fm.ascent}, slice=$slice")
//BitmapFont.Glyph(fontSize, codePoint, entry.slice, 0, (m.height - m.top + fm.ascent).toInt(), xadvance.toInt())
BitmapFont.Glyph(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.soywiz.korim.font

import kotlin.test.*

class LazyBitmapFontTest {
@Test
fun testEnsureSpaceIsEmpty() {
val glyph = DefaultTtfFontAsBitmap.getOrNull(' '.code)
val texture = glyph!!.texture
assertEquals(0, texture.width)
assertEquals(0, texture.height)
}
}

0 comments on commit 22b12d4

Please sign in to comment.