Changeset 287 for trunk/thune/gl

Show
Ignore:
Timestamp:
09/30/06 03:47:37 (2 years ago)
Author:
krobillard
Message:

Thune GL - Fixed font! bugs.

Location:
trunk/thune/gl
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/gl/TexFont.c

    r286 r287  
    499499            free( txf->kerning ); 
    500500        txf->kerning = (uint8_t*) kern.ptr; 
     501        txf->kern_bytes = kern.used; 
     502    } 
     503    else 
     504    { 
     505        txf->kerning = 0; 
     506        txf->kern_bytes = 0; 
    501507    } 
    502508#endif 
  • trunk/thune/gl/TexFont.h

    r286 r287  
    2424typedef struct 
    2525{ 
     26    TexGlyphInfo* tgi; 
     27    TexGlyphInfo** table; 
     28    uint8_t* kerning; 
     29 
    2630    int16_t tex_width; 
    2731    int16_t tex_height; 
    2832    int16_t max_ascent; 
    2933    int16_t max_descent; 
    30     int32_t num_glyphs; 
     34    int16_t num_glyphs; 
    3135    int16_t min_glyph; 
    3236    int16_t table_size; 
    33  
    34     TexGlyphInfo* tgi; 
    35     TexGlyphInfo** table; 
    36     uint8_t* kerning; 
     37    int16_t kern_bytes; 
    3738} 
    3839TexFont; 
  • trunk/thune/gl/draw_list.c

    r286 r287  
    143143 
    144144 
    145 /** 
     145/* 
    146146  Returns TexGlyphInfo of rendered glyph. 
    147147  Advances x. 
  • trunk/thune/gl/gx.c

    r286 r287  
    3333/* 
    3434#include "math3d.h" 
    35 #include "res_font.h" 
    36 #include "dlist.h" 
    3735#include <time.h> 
    3836*/ 
  • trunk/thune/gl/rfont.c

    r286 r287  
    9393    " ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz" 
    9494    "?.;,!*:\"/+-|'@#$%^&<>()[]{}_"; 
    95  
    96  
    97 static int _kernTableSize( uint8_t* kern ) 
    98 { 
    99     int count = 0; 
    100     if( kern ) 
    101     { 
    102         while( *kern++ ) 
    103             ++count; 
    104     } 
    105     return count; 
    106 } 
    10795 
    10896 
     
    145133            TexFont* btf; 
    146134            int gs, ts, ks; 
     135            TexGlyphInfo** dst; 
     136            TexGlyphInfo** src; 
     137            TexGlyphInfo** end; 
    147138 
    148139            // TODO: Track & delete texture. 
     
    154145            gs = sizeof(TexGlyphInfo) * tf.num_glyphs; 
    155146            ts = sizeof(TexGlyphInfo*) * tf.table_size; 
    156             ks = _kernTableSize( tf.kerning ); 
     147            ks = tf.kerning ? tf.kern_bytes : 0; 
    157148 
    158149            binN = ur_makeBinary( sizeof(TexFont) + gs + ts + ks ); 
    159150            bin = ur_binPtr( binN ); 
     151            bin->used = bin->avail; 
    160152 
    161153            btf = (TexFont*) bin->ptr.v; 
     
    163155 
    164156            btf->table = (TexGlyphInfo**) (btf + 1); 
    165             memCpy( btf->table, tf.table, ts ); 
    166  
    167             btf->tgi = (TexGlyphInfo*) (btf->table + tf.table_size); 
     157            btf->tgi   = (TexGlyphInfo*) (btf->table + tf.table_size); 
     158 
     159            src = tf.table; 
     160            end = src + tf.table_size; 
     161            dst = btf->table; 
     162            while( src != end ) 
     163            { 
     164                if( *src ) 
     165                    *dst++ = btf->tgi + (*src - tf.tgi); 
     166                else 
     167                    *dst++ = 0; 
     168                ++src; 
     169            } 
     170            //memCpy( btf->table, tf.table, ts ); 
     171 
    168172            memCpy( btf->tgi, tf.tgi, gs ); 
    169173 
  • trunk/thune/gl/test.t

    r286 r287  
    117117            call bg-list 
    118118        pop 
     119 
    119120        font fontA  color $ffffff 
    120121        text "Hello^/There" 
     
    122123        text -200,-200 "-200,-200" 
    123124        text mouse-pos mouse-pos 
     125 
     126        ;font fontF 
     127        ;text 0,40 "Ceti Alpha III" 
     128 
    124129        ;children ['draw get do] iter 
    125130    ] 
     
    223228 
    224229font! ["data/20thfont.ttf" 22] make :fontA 
     230;font! ["data/FederationBold_KR.ttf" 12 256,128] make :fontF 
    225231 
    226232