mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-10 16:01:50 -04:00
trim font
This should reduce some call overhead, normally once include just contains one font type and not multiple
This commit is contained in:
parent
d9e26b1b86
commit
80790c4637
@ -49,7 +49,7 @@ class FontManager(
|
|||||||
Log.log(LogMessageType.ASSETS, LogLevels.WARN) { "Font ${DefaultFontIndices.DEFAULT} seems to be empty!" }
|
Log.log(LogMessageType.ASSETS, LogLevels.WARN) { "Font ${DefaultFontIndices.DEFAULT} seems to be empty!" }
|
||||||
}
|
}
|
||||||
|
|
||||||
return FontManager(font ?: EmptyFont)
|
return FontManager(font?.trim() ?: EmptyFont)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,6 @@ object ReferenceFontType : FontTypeFactory<FontType> {
|
|||||||
|
|
||||||
override fun build(context: RenderContext, data: JsonObject): FontType? {
|
override fun build(context: RenderContext, data: JsonObject): FontType? {
|
||||||
val index = data["id"]?.toResourceLocation()?.prefix("font/")?.suffix(".json") ?: throw IllegalArgumentException("id missing!")
|
val index = data["id"]?.toResourceLocation()?.prefix("font/")?.suffix(".json") ?: throw IllegalArgumentException("id missing!")
|
||||||
return FontLoader.load(context, index, null)
|
return FontLoader.load(context, index, null)?.trim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,15 @@ class Font(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun trim(): FontType? {
|
||||||
|
return when (providers.size) {
|
||||||
|
0 -> null
|
||||||
|
1 -> providers.first()
|
||||||
|
else -> this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val CACHE_START = ' '.code // all control chars (like ESC, CR, ...) are not used anyway (in a normal environment)
|
private const val CACHE_START = ' '.code // all control chars (like ESC, CR, ...) are not used anyway (in a normal environment)
|
||||||
private const val CACHE_SIZE = (1 shl 7) - CACHE_START // ascii
|
private const val CACHE_SIZE = (1 shl 7) - CACHE_START // ascii
|
||||||
|
Loading…
x
Reference in New Issue
Block a user