#include "camera.h"
#include "shaders/model_font.h"
+
+enum efont_SRglyph{
+ k_SRglyph_end = 0, /* control characters */
+ k_SRglyph_ctrl_variant = 1,
+ k_SRglyph_mod_circle = 0x1e, /* surround and center next charater */
+ k_SRglyph_mod_square = 0x1f, /* surround and center next character */
+ k_SRglyph_ascii_min = 0x20, /* standard ascii */
+ k_SRglyph_ascii_max = 0x7e,
+ k_SRglyph_ps4_square = 0x7f,/* playstation buttons */
+ k_SRglyph_ps4_triangle = 0x80,
+ k_SRglyph_ps4_circle = 0x81,
+ k_SRglyph_ps4_cross = 0x82,
+ k_SRglyph_xb1_x = 0x83,/* xbox buttons */
+ k_SRglyph_xb1_y = 0x84,
+ k_SRglyph_xb1_b = 0x85,
+ k_SRglyph_xb1_a = 0x86,
+ k_SRglyph_gen_ls = 0x87,/* generic gamepad */
+ k_SRglyph_gen_lsh = 0x88,
+ k_SRglyph_gen_lsv = 0x89,
+ k_SRglyph_gen_lshv = 0x8a,
+ k_SRglyph_gen_rs = 0x8b,
+ k_SRglyph_gen_rsh = 0x8c,
+ k_SRglyph_gen_rsv = 0x8d,
+ k_SRglyph_gen_rshv = 0x8e,
+ k_SRglyph_gen_lt = 0x8f,
+ k_SRglyph_gen_rt = 0x90,
+ k_SRglyph_gen_lb = 0x91,
+ k_SRglyph_gen_rb = 0x92,
+ k_SRglyph_gen_left = 0x93,
+ k_SRglyph_gen_up = 0x94,
+ k_SRglyph_gen_right = 0x95,
+ k_SRglyph_gen_down = 0x96,
+ k_SRglyph_gen_options = 0x97,
+ k_SRglyph_gen_shareview = 0x98,
+ k_SRglyph_kbm_m0 = 0x99,/* mouse */
+ k_SRglyph_kbm_m1 = 0x9a,
+ k_SRglyph_kbm_m01 = 0x9b,
+ k_SRglyph_kbm_m2 = 0x9c,
+ k_SRglyph_kbm_m2s = 0x9d,
+ k_SRglyph_kbm_shift = 0x9e,/* modifiers */
+ k_SRglyph_kbm_ctrl = 0x9f,
+ k_SRglyph_kbm_alt = 0xa0,
+ k_SRglyph_kbm_space = 0xa1
+};
+
typedef struct font3d font3d;
struct font3d{
mdl_context mdl;
}
VG_STATIC
-void font3d_simple_draw( font3d *font, u32 variant_id, const char *text,
+float font3d_simple_draw( font3d *font, u32 variant_id, const char *text,
camera *cam, m4x3f transform )
{
v3f offset;
shader_model_font_uPvmPrev( prev_mtx );
shader_model_font_uMdl( transform );
+ const u8 *u8str = (u8*)text;
+
for( int i=0;; i++ ){
- u32 c = text[i];
+ u32 c = u8str[i];
if(!c) break;
+ if( c == k_SRglyph_ctrl_variant ){
+ variant_id = u8str[i+1];
+ continue;
+ }
+
ent_glyph *glyph = font3d_glyph( font, variant_id, c );
if( !glyph ) continue;
if( glyph->indice_count ){
- shader_model_font_uOffset( offset );
- mesh_drawn( glyph->indice_start, glyph->indice_count );
+ if( c == k_SRglyph_mod_square || c == k_SRglyph_mod_circle ){
+ u32 c1 = u8str[i+1];
+ if( c1 == '\0' ) break;
+
+ ent_glyph *glyph1 = font3d_glyph( font, variant_id, c1 );
+
+ if( glyph1 ){
+ if( glyph1->indice_count ){
+ v3f v0;
+ v2_sub( glyph->size, glyph1->size, v0 );
+ v2_muladds( offset, v0, -0.5f, v0 );
+ v0[2] = 0.0f;
+
+ shader_model_font_uOffset( v0 );
+ mesh_drawn( glyph->indice_start, glyph->indice_count );
+
+ shader_model_font_uOffset( offset );
+ mesh_drawn( glyph1->indice_start, glyph1->indice_count );
+ offset[0] += glyph1->size[0];
+ }
+ }
+
+ i ++;
+ continue;
+ }
+ else{
+ shader_model_font_uOffset( offset );
+ mesh_drawn( glyph->indice_start, glyph->indice_count );
+ }
}
offset[0] += glyph->size[0];
}
+
+ return offset[0];
}
VG_STATIC