diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/FontUtil.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/FontUtil.kt new file mode 100644 index 0000000..fd6b425 --- /dev/null +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/FontUtil.kt @@ -0,0 +1,13 @@ +package fr.username404.snowygui.gui + +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.Minecraft + +object FontUtil { + fun drawScaled(stack: PoseStack, text: String, x: Double, y: Double, scaleFactor: Float, color: Int = 0x000000) { + stack.scale(scaleFactor, scaleFactor, scaleFactor) + Minecraft.getInstance().font.draw(stack, text, (x / scaleFactor).toFloat(), (y / scaleFactor).toFloat(), color) + val factorToOriginal = 1F / scaleFactor + stack.scale(factorToOriginal, factorToOriginal, factorToOriginal) + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickButton.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickButton.kt index 2034238..f45713c 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickButton.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickButton.kt @@ -3,10 +3,10 @@ package fr.username404.snowygui.gui.elements import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import fr.username404.snowygui.gui.ColoredElement +import fr.username404.snowygui.gui.FontUtil import fr.username404.snowygui.gui.Renderable.Rendering.defaultRectFunc import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import net.minecraft.client.Minecraft import net.minecraft.client.gui.components.events.GuiEventListener class ClickButton( @@ -61,6 +61,8 @@ class ClickButton( defaultRectFunc() RenderSystem.enableTexture() RenderSystem.disableBlend() - if (Title != null) Minecraft.getInstance().font.draw(poseStack, Title, x.toFloat() + 1, y.toFloat(), 0x000000) + if (Title != null && poseStack != null) { + FontUtil.drawScaled(poseStack, Title, x + 1, y + 1, 0.75F) + } } } \ No newline at end of file