mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
unihex font type: read buffered from zip
This commit is contained in:
parent
4e187b9985
commit
7ad39a72d7
@ -60,10 +60,7 @@ class UnifontTexture(
|
||||
private fun TextureData.set(row: Int, offset: Int, x: Int, y: Int) {
|
||||
val index = ((row * UnifontRasterizer.HEIGHT + y) * size.x + offset + x) * 4
|
||||
|
||||
buffer.put(index + 0, 0xFF.toByte())
|
||||
buffer.put(index + 1, 0xFF.toByte())
|
||||
buffer.put(index + 2, 0xFF.toByte())
|
||||
buffer.put(index + 3, 0xFF.toByte())
|
||||
buffer.putInt(index, 0xFFFFFFFF.toInt())
|
||||
}
|
||||
|
||||
private fun rasterize(row: Int, offset: Int, width: Int, data: ByteArray): CodePointRenderer {
|
||||
|
@ -23,6 +23,7 @@ import de.bixilon.minosoft.gui.rendering.font.types.factory.FontTypeFactory
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.listCast
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.InputStream
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
@ -48,6 +49,7 @@ class UnihexFontType(
|
||||
|
||||
fun load(context: RenderContext, hexFile: ResourceLocation, sizes: List<SizeOverride>): UnihexFontType? {
|
||||
val stream = ZipInputStream(context.connection.assetsManager[hexFile])
|
||||
val buffered = BufferedInputStream(stream)
|
||||
|
||||
val chars = Int2ObjectOpenHashMap<ByteArray>()
|
||||
var totalWidth = 0
|
||||
@ -55,7 +57,7 @@ class UnihexFontType(
|
||||
val entry = stream.nextEntry ?: break
|
||||
if (!entry.name.endsWith(".hex")) continue
|
||||
|
||||
totalWidth += stream.readUnihex(chars)
|
||||
totalWidth += buffered.readUnihex(chars)
|
||||
}
|
||||
if (chars.isEmpty()) return null
|
||||
|
||||
@ -72,6 +74,8 @@ class UnihexFontType(
|
||||
rasterized[entry.intKey] = rasterizer.add(entry.value)
|
||||
}
|
||||
|
||||
rasterized.trim()
|
||||
|
||||
return UnihexFontType(rasterized)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user