BGE Text - fix for tab drawing as an @ and not adding white space.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 9 Apr 2009 10:05:17 +0000 (10:05 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 9 Apr 2009 10:05:17 +0000 (10:05 +0000)
Tab width is always space*4.

source/blender/gpu/intern/gpu_draw.c

index c0033c89d5c71884554c187843515bc031d1cebb..7b1fc67d0c6f2149969e75b60b222e8055f3fc4b 100644 (file)
@@ -83,7 +83,9 @@ void GPU_render_text(MTFace *tface, int mode,
                Image* ima;
                int characters, index, character;
                float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
-
+               float advance_tab;
+               
+               
                /* multiline */
                float line_start= 0.0f, line_height; 
                if (v4)
@@ -107,6 +109,13 @@ void GPU_render_text(MTFace *tface, int mode,
 
                glPushMatrix();
                
+               /* get the tab width */
+               matrixGlyph((ImBuf *)ima->ibufs.first, ' ', & centerx, &centery,
+                       &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
+               
+               advance_tab= advance * 4; /* tab width could also be an option */
+               
+               
                for (index = 0; index < characters; index++) {
                        float uv[4][2];
 
@@ -118,6 +127,12 @@ void GPU_render_text(MTFace *tface, int mode,
                                line_start = 0.0f;
                                continue;
                        }
+                       else if (character=='\t') {
+                               glTranslatef(advance_tab, 0.0, 0.0);
+                               line_start -= advance_tab; /* so we can go back to the start of the line */
+                               continue;
+                               
+                       }
                        
                        // space starts at offset 1
                        // character = character - ' ' + 1;