@@ -315,19 +315,16 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false
315315 text : String ,
316316 pos : Vec3d ,
317317 size : Float = 0.5f,
318- font : SDFFontAtlas ? = null ,
318+ font : SDFFontAtlas = FontHandler .activeFont ,
319319 style : SDFStyle = SDFStyle (),
320320 centered : Boolean = true,
321321 rotation : Vec3d ? = null
322322 ) {
323- val atlas = font ? : FontHandler .getDefaultFont()
324- fontAtlas = atlas
325-
326323 val anchorX = (pos.x - cameraPos.x).toFloat()
327324 val anchorY = (pos.y - cameraPos.y).toFloat()
328325 val anchorZ = (pos.z - cameraPos.z).toFloat()
329326
330- val textWidth = if (centered) atlas .getStringWidthNormalized(text, 1f ) else 0f
327+ val textWidth = if (centered) FontHandler .getStringWidthNormalized(text, 1f ) else 0f
331328 val startX = - textWidth / 2f
332329
333330 val rotationMatrix: Matrix4f ? = if (rotation != null ) {
@@ -341,29 +338,29 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false
341338 val shadowColor = style.shadow.color
342339 val offsetX = style.shadow.offsetX
343340 val offsetY = style.shadow.offsetY
344- buildTextQuads(atlas, text, startX + offsetX, offsetY,
341+ buildTextQuads(text, startX + offsetX, offsetY,
345342 shadowColor.red, shadowColor.green, shadowColor.blue, shadowColor.alpha,
346- anchorX, anchorY, anchorZ, size, rotationMatrix, style, activeOutlineId, 0 )
343+ anchorX, anchorY, anchorZ, size, rotationMatrix, style, font, activeOutlineId, 0 )
347344 }
348345
349346 if (style.glow != null ) {
350347 val glowColor = style.glow.color
351- buildTextQuads(atlas, text, startX, 0f ,
348+ buildTextQuads(text, startX, 0f ,
352349 glowColor.red, glowColor.green, glowColor.blue, glowColor.alpha,
353- anchorX, anchorY, anchorZ, size, rotationMatrix, style, activeOutlineId, 1 )
350+ anchorX, anchorY, anchorZ, size, rotationMatrix, style, font, activeOutlineId, 1 )
354351 }
355352
356353 if (style.outline != null ) {
357354 val outlineColor = style.outline.color
358- buildTextQuads(atlas, text, startX, 0f ,
355+ buildTextQuads(text, startX, 0f ,
359356 outlineColor.red, outlineColor.green, outlineColor.blue, outlineColor.alpha,
360- anchorX, anchorY, anchorZ, size, rotationMatrix, style, activeOutlineId, 2 )
357+ anchorX, anchorY, anchorZ, size, rotationMatrix, style, font, activeOutlineId, 2 )
361358 }
362359
363360 val mainColor = style.color
364- buildTextQuads(atlas, text, startX, 0f ,
361+ buildTextQuads(text, startX, 0f ,
365362 mainColor.red, mainColor.green, mainColor.blue, 255 ,
366- anchorX, anchorY, anchorZ, size, rotationMatrix, style, activeOutlineId)
363+ anchorX, anchorY, anchorZ, size, rotationMatrix, style, font, activeOutlineId)
367364 }
368365
369366 private val screenWidth get() = mc.window?.scaledWidth?.toFloat() ? : 1920f
@@ -1166,21 +1163,18 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false
11661163 x : Float ,
11671164 y : Float ,
11681165 size : Float = 0.02f,
1169- font : SDFFontAtlas ? = null ,
1166+ font : SDFFontAtlas = FontHandler .activeFont ,
11701167 style : SDFStyle = SDFStyle (),
11711168 centered : Boolean = false
11721169 ) {
1173- val atlas = font ? : FontHandler .getDefaultFont()
1174- fontAtlas = atlas
1175-
11761170 val pixelX = toPixelX(x)
11771171 val pixelY = toPixelY(y)
11781172
11791173 val targetPixelHeight = toPixelSize(size)
11801174
1181- val pixelSize = targetPixelHeight * atlas .baseSize / atlas .ascent
1175+ val pixelSize = targetPixelHeight * font .baseSize / font .ascent
11821176
1183- val normalizedTextWidth = if (centered) atlas .getStringWidthNormalized(text, size) else 0f
1177+ val normalizedTextWidth = if (centered) font .getStringWidthNormalized(text, size) else 0f
11841178 val textWidth = normalizedTextWidth * screenWidth
11851179 val startX = - textWidth / 2f
11861180
@@ -1189,30 +1183,30 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false
11891183 val offsetX = style.shadow.offsetX * pixelSize
11901184 val offsetY = - style.shadow.offsetY * pixelSize
11911185 val layer = nextLayer()
1192- buildScreenTextQuads(atlas , text, startX + offsetX, offsetY,
1186+ buildScreenTextQuads(font , text, startX + offsetX, offsetY,
11931187 shadowColor.red, shadowColor.green, shadowColor.blue, shadowColor.alpha,
11941188 pixelX, pixelY, pixelSize, style, layer, 0 )
11951189 }
11961190
11971191 if (style.glow != null ) {
11981192 val glowColor = style.glow.color
11991193 val layer = nextLayer()
1200- buildScreenTextQuads(atlas , text, startX, 0f ,
1194+ buildScreenTextQuads(font , text, startX, 0f ,
12011195 glowColor.red, glowColor.green, glowColor.blue, glowColor.alpha,
12021196 pixelX, pixelY, pixelSize, style, layer, 1 )
12031197 }
12041198
12051199 if (style.outline != null ) {
12061200 val outlineColor = style.outline.color
12071201 val layer = nextLayer()
1208- buildScreenTextQuads(atlas , text, startX, 0f ,
1202+ buildScreenTextQuads(font , text, startX, 0f ,
12091203 outlineColor.red, outlineColor.green, outlineColor.blue, outlineColor.alpha,
12101204 pixelX, pixelY, pixelSize, style, layer, 2 )
12111205 }
12121206
12131207 val mainColor = style.color
12141208 val mainLayer = nextLayer()
1215- buildScreenTextQuads(atlas , text, startX, 0f ,
1209+ buildScreenTextQuads(font , text, startX, 0f ,
12161210 mainColor.red, mainColor.green, mainColor.blue, mainColor.alpha,
12171211 pixelX, pixelY, pixelSize, style, mainLayer, 3 )
12181212 }
@@ -1264,7 +1258,6 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false
12641258 }
12651259
12661260 private fun buildTextQuads (
1267- atlas : SDFFontAtlas ,
12681261 text : String ,
12691262 startX : Float ,
12701263 startY : Float ,
@@ -1273,6 +1266,7 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false
12731266 scale : Float ,
12741267 rotationMatrix : Matrix4f ? ,
12751268 style : SDFStyle ,
1269+ atlas : SDFFontAtlas = FontHandler .activeFont,
12761270 outlineId : Int? = null,
12771271 layerType : Int = 3
12781272 ) {
0 commit comments