@@ -789,33 +789,44 @@ public void renderTextBatches() {
789
789
// Global text scale modifier. Make a constant?
790
790
float baseTextScale = 0.025f ;
791
791
792
+ Color tempColor = new Color ();
793
+
792
794
for (int i = 0 ; i < textToRender .size ; i ++) {
793
795
DrawableText dT = textToRender .get (i );
794
796
795
- float curXPos = 0f ;
796
- float textWidth = 0f ;
797
+ float curXPos = 0f , curZPos = 0f ;
797
798
798
799
// TODO: Handle newline characters?
799
800
800
- // Figure out the width of this text
801
- for (int ii = 0 ; ii < dT .text .length (); ii ++) {
802
- BitmapFont .Glyph glyph = font .getData ().getGlyph (dT .text .charAt (ii ));
803
- textWidth += glyph .width * dT .scale * baseTextScale ;
804
- }
801
+ GlyphLayout bounds = FontBounds .GetBounds (font , dT .text );
802
+ float textWidth = bounds .width * dT .scale * baseTextScale ;
803
+ float textHeight = bounds .height * dT .scale * baseTextScale ;
804
+
805
+ BitmapFont .Glyph glyph = font .getData ().getGlyph ('X' );
806
+
807
+ float glyphWidth , glyphHeight = glyph .height * dT .scale * baseTextScale ;
805
808
806
809
// Draw a decal per-glyph for this text
807
810
for (int ii = 0 ; ii < dT .text .length (); ii ++) {
808
- BitmapFont .Glyph glyph = font .getData ().getGlyph (dT .text .charAt (ii ));
811
+ char character = dT .text .charAt (ii );
812
+
813
+ glyph = font .getData ().getGlyph (character );
814
+
815
+ if (glyph == null && character == '\n' ) { // Newline support is in DrawableText, replaces "\\n" with "\n" there to avoid issues with font boundary calculations.
816
+ curXPos = 0 ;
817
+ curZPos += glyphHeight ;
818
+ continue ;
819
+ }
809
820
810
- float glyphWidth = glyph .width * dT .scale * baseTextScale ;
811
- float glyphHeight = glyph .height * dT .scale * baseTextScale ;
821
+ glyphWidth = glyph .width * dT .scale * baseTextScale ;
812
822
813
823
float tx = dT .parentPosition .x + curXPos ;
814
824
float ty = dT .parentPosition .y + 0.001f ; // Pull out a bit, to place directly on walls
815
- float tz = dT .parentPosition .z + (glyphHeight * 0.5f ); // Place font baseline directly on entity origin
825
+ float tz = dT .parentPosition .z - curZPos + (glyphHeight * 0.5f ); // Place font baseline directly on entity origin
816
826
817
827
// Center text on origin
818
828
tx -= textWidth * 0.5f ;
829
+ tz += textHeight * 0.5f ;
819
830
820
831
// Offset a tiny bit, because something was doing that in the glyph rendering code
821
832
tx += 0.1f * dT .scale ;
@@ -857,8 +868,8 @@ public void renderTextBatches() {
857
868
if (dT .fullbrite ) {
858
869
sd .setColor (dT .color .r , dT .color .g , dT .color .b , 1.0f );
859
870
} else {
860
- Color lightmap = GetLightmapAt (tx , tz , ty );
861
- sd .setColor (lightmap .r , lightmap .g , lightmap .b , 1.0f );
871
+ tempColor . set ( GetLightmapAt (tx , tz , ty )). mul ( dT . color );
872
+ sd .setColor (tempColor .r , tempColor .g , tempColor .b , 1.0f );
862
873
}
863
874
864
875
if (renderingForPicking )
0 commit comments