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