автоскейлинг текста на табличках (пока не переключаемый)

AMD User — Сегодня, в 11:36
Изображение
наверное ветер
This commit is contained in:
YuRaNnNzZZ 2024-10-23 11:47:28 +03:00
parent 74f75ebfc6
commit 5913f56fb0
Signed by: YuRaNnNzZZ
GPG Key ID: 5F71738C85A6006D

View File

@ -35,6 +35,11 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context)
val totalHeight = lines.size * font.lineHeight + (lines.size - 1) * 2f
var y = -totalHeight / 2f
val totalWidth = lines.maxOf { font.width(it) }.toFloat()
val highest = totalWidth.coerceAtLeast(totalHeight)
val mul = if (highest > 64f) 1f / (highest / 64f) else 64f / highest
poseStack.scale(mul, mul, mul)
for (line in lines) {
font.draw(poseStack = poseStack, buffer = bufferSource, text = line, gravity = RenderGravity.TOP_CENTER, y = y, color = RGBAColor(tile.textRed, tile.textGreen, tile.textBlue, tile.textAlpha))
y += font.lineHeight + 2f