mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -04:00
never post init font twice
This commit is contained in:
parent
d92bc3fdec
commit
3254d1823f
@ -19,15 +19,15 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||
|
||||
class BitmapCodeRenderer(
|
||||
override val texture: Texture,
|
||||
override var uvStart: Vec2,
|
||||
override var uvEnd: Vec2,
|
||||
override val uvStart: Vec2,
|
||||
override val uvEnd: Vec2,
|
||||
override val width: Float,
|
||||
override val height: Float,
|
||||
override val ascent: Float,
|
||||
) : AscentedCodePointRenderer {
|
||||
|
||||
fun updateArray() {
|
||||
uvStart = uvStart * texture.array.uvEnd
|
||||
uvEnd = uvEnd * texture.array.uvEnd
|
||||
uvStart *= texture.array.uvEnd
|
||||
uvEnd *= texture.array.uvEnd
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import java.util.stream.IntStream
|
||||
class BitmapFontType(
|
||||
val chars: Int2ObjectOpenHashMap<CodePointRenderer>,
|
||||
) : PostInitFontType {
|
||||
private var postInit = false
|
||||
|
||||
init {
|
||||
chars.trim()
|
||||
@ -48,10 +49,12 @@ class BitmapFontType(
|
||||
}
|
||||
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
if (postInit) return
|
||||
for (char in chars.values) {
|
||||
if (char !is BitmapCodeRenderer) continue
|
||||
char.updateArray()
|
||||
}
|
||||
postInit = true
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,11 +36,14 @@ import java.io.InputStream
|
||||
class LegacyUnicodeFontType(
|
||||
val chars: Array<UnicodeCodeRenderer?>,
|
||||
) : PostInitFontType {
|
||||
private var postInit = false
|
||||
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
if (postInit) return
|
||||
for (char in chars) {
|
||||
char?.updateArray()
|
||||
}
|
||||
postInit = true
|
||||
}
|
||||
|
||||
override fun get(codePoint: Int): UnicodeCodeRenderer? {
|
||||
|
@ -30,6 +30,9 @@ import java.io.InputStream
|
||||
import javax.imageio.ImageIO
|
||||
|
||||
object TextureUtil {
|
||||
private val COMPONENTS_4 = intArrayOf(0, 1, 2, 3)
|
||||
private val COMPONENTS_3 = intArrayOf(0, 1, 2)
|
||||
private val COMPONENTS_1 = intArrayOf(0, 0, 0)
|
||||
|
||||
fun ResourceLocation.texture(): ResourceLocation {
|
||||
return this.extend(prefix = "textures/", suffix = ".png")
|
||||
@ -58,9 +61,9 @@ object TextureUtil {
|
||||
val dataOutput = DataOutputStream(byteOutput)
|
||||
|
||||
val samples = when (image.raster.numBands) {
|
||||
4 -> intArrayOf(0, 1, 2, 3)
|
||||
3 -> intArrayOf(0, 1, 2)
|
||||
else -> intArrayOf(0, 0, 0)
|
||||
4 -> COMPONENTS_4
|
||||
3 -> COMPONENTS_3
|
||||
else -> COMPONENTS_1
|
||||
}
|
||||
|
||||
for (y in 0 until image.height) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user