Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/main/kotlin/gg/essential/elementa/font/BasicFontRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ class BasicFontRenderer(
shadow: Boolean,
shadowColor: Color?
) {
val scaledPointSize = scale * regularFontInfo.atlas.size

if (shadow) {
drawStringNow(
vertexConsumer,
Expand All @@ -148,7 +146,7 @@ class BasicFontRenderer(
),
x + 1,
y + 1,
scaledPointSize,
scale,
)
}
drawStringNow(
Expand All @@ -158,7 +156,7 @@ class BasicFontRenderer(
color,
x,
y,
scaledPointSize,
scale,
)
}

Expand All @@ -181,8 +179,10 @@ class BasicFontRenderer(
color: Color,
x: Float,
y: Float,
originalPointSize: Float
scale: Float,
) {
val scaledPointSize = scale * regularFontInfo.atlas.size

var currentX = x
var i = 0
while (i < string.length) {
Expand All @@ -204,22 +204,22 @@ class BasicFontRenderer(
val planeBounds = glyph.planeBounds

if (planeBounds != null) {
val width = (planeBounds.r - planeBounds.l) * originalPointSize
val height = (planeBounds.t - planeBounds.b) * originalPointSize
val width = (planeBounds.r - planeBounds.l) * scaledPointSize
val height = (planeBounds.t - planeBounds.b) * scaledPointSize

drawGlyph(
vertexConsumer,
matrixStack,
glyph,
color,
currentX,
y + regularFontInfo.atlas.baseCharHeight - planeBounds.t * originalPointSize,
y + regularFontInfo.atlas.baseCharHeight * scale - planeBounds.t * scaledPointSize,
width,
height
)
}

currentX += computeAdvance(regularFontInfo, glyph) * originalPointSize
currentX += computeAdvance(regularFontInfo, glyph) * scaledPointSize
i++
}

Expand Down
Loading