forked from rougier/freetype-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
texture-font.c
715 lines (625 loc) · 22.1 KB
/
texture-font.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/* ===========================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 Nicolas P. Rougier. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of Nicolas P. Rougier.
* ============================================================================
*/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_STROKER_H
// #include FT_ADVANCES_H
#include FT_LCD_FILTER_H
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <wchar.h>
#include "texture-font.h"
#include "platform.h"
#define HRES 64
#define HRESf 64.f
#define DPI 72
#undef __FTERRORS_H__
#define FT_ERRORDEF( e, v, s ) { e, s },
#define FT_ERROR_START_LIST {
#define FT_ERROR_END_LIST { 0, 0 } };
const struct {
int code;
const char* message;
} FT_Errors[] =
#include FT_ERRORS_H
// ------------------------------------------------- texture_font_load_face ---
static int
texture_font_load_face(texture_font_t *self, float size,
FT_Library *library, FT_Face *face)
{
FT_Error error;
FT_Matrix matrix = {
(int)((1.0/HRES) * 0x10000L),
(int)((0.0) * 0x10000L),
(int)((0.0) * 0x10000L),
(int)((1.0) * 0x10000L)};
assert(library);
assert(size);
/* Initialize library */
error = FT_Init_FreeType(library);
if(error) {
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
return 0;
}
/* Load face */
switch (self->location) {
case TEXTURE_FONT_FILE:
error = FT_New_Face(*library, self->filename, 0, face);
break;
case TEXTURE_FONT_MEMORY:
error = FT_New_Memory_Face(*library,
self->memory.base, self->memory.size, 0, face);
break;
}
if(error) {
fprintf(stderr, "FT_Error (line %d, code 0x%02x) : %s\n",
__LINE__, FT_Errors[error].code, FT_Errors[error].message);
FT_Done_FreeType(*library);
return 0;
}
/* Select charmap */
error = FT_Select_Charmap(*face, FT_ENCODING_UNICODE);
if(error) {
fprintf(stderr, "FT_Error (line %d, code 0x%02x) : %s\n",
__LINE__, FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face(*face);
FT_Done_FreeType(*library);
return 0;
}
/* Set char size */
error = FT_Set_Char_Size(*face, (int)(size * HRES), 0, DPI * HRES, DPI);
if(error) {
fprintf(stderr, "FT_Error (line %d, code 0x%02x) : %s\n",
__LINE__, FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face(*face);
FT_Done_FreeType(*library);
return 0;
}
/* Set transform matrix */
FT_Set_Transform(*face, &matrix, NULL);
return 1;
}
static int
texture_font_get_face_with_size(texture_font_t *self, float size,
FT_Library *library, FT_Face *face)
{
return texture_font_load_face(self, size, library, face);
}
static int
texture_font_get_face(texture_font_t *self,
FT_Library *library, FT_Face *face)
{
return texture_font_get_face_with_size(self, self->size, library, face);
}
static int
texture_font_get_hires_face(texture_font_t *self,
FT_Library *library, FT_Face *face)
{
return texture_font_get_face_with_size(self,
self->size * 100.f, library, face);
}
// ------------------------------------------------------ texture_glyph_new ---
texture_glyph_t *
texture_glyph_new(void)
{
texture_glyph_t *self = (texture_glyph_t *) malloc( sizeof(texture_glyph_t) );
if(self == NULL) {
fprintf( stderr,
"line %d: No more memory for allocating data\n", __LINE__);
return NULL;
}
self->id = 0;
self->width = 0;
self->height = 0;
self->outline_type = 0;
self->outline_thickness = 0.0;
self->offset_x = 0;
self->offset_y = 0;
self->advance_x = 0.0;
self->advance_y = 0.0;
self->s0 = 0.0;
self->t0 = 0.0;
self->s1 = 0.0;
self->t1 = 0.0;
self->kerning = vector_new( sizeof(kerning_t) );
return self;
}
// --------------------------------------------------- texture_glyph_delete ---
void
texture_glyph_delete( texture_glyph_t *self )
{
assert( self );
vector_delete( self->kerning );
free( self );
}
// ---------------------------------------------- texture_glyph_get_kerning ---
float
texture_glyph_get_kerning( const texture_glyph_t * self,
const wchar_t charcode )
{
size_t i;
assert( self );
for( i=0; i<vector_size(self->kerning); ++i )
{
kerning_t * kerning = (kerning_t *) vector_get( self->kerning, i );
if( kerning->charcode == charcode )
{
return kerning->kerning;
}
}
return 0;
}
// ------------------------------------------ texture_font_generate_kerning ---
void
texture_font_generate_kerning( texture_font_t *self )
{
size_t i, j;
FT_Library library;
FT_Face face;
FT_UInt glyph_index, prev_index;
texture_glyph_t *glyph, *prev_glyph;
FT_Vector kerning;
assert( self );
/* Load font */
if(!texture_font_get_face(self, &library, &face))
return;
/* For each glyph couple combination, check if kerning is necessary */
/* Starts at index 1 since 0 is for the special backgroudn glyph */
for( i=1; i<self->glyphs->size; ++i )
{
glyph = *(texture_glyph_t **) vector_get( self->glyphs, i );
glyph_index = FT_Get_Char_Index( face, glyph->charcode );
vector_clear( glyph->kerning );
for( j=1; j<self->glyphs->size; ++j )
{
prev_glyph = *(texture_glyph_t **) vector_get( self->glyphs, j );
prev_index = FT_Get_Char_Index( face, prev_glyph->charcode );
FT_Get_Kerning( face, prev_index, glyph_index, FT_KERNING_UNFITTED, &kerning );
// printf("%c(%d)-%c(%d): %ld\n",
// prev_glyph->charcode, prev_glyph->charcode,
// glyph_index, glyph_index, kerning.x);
if( kerning.x )
{
kerning_t k = {prev_glyph->charcode, kerning.x / (float)(HRESf*HRESf)};
vector_push_back( glyph->kerning, &k );
}
}
}
FT_Done_Face( face );
FT_Done_FreeType( library );
}
// ------------------------------------------------------ texture_font_init ---
static int
texture_font_init(texture_font_t *self)
{
FT_Library library;
FT_Face face;
FT_Size_Metrics metrics;
assert(self->atlas);
assert(self->size > 0);
assert((self->location == TEXTURE_FONT_FILE && self->filename)
|| (self->location == TEXTURE_FONT_MEMORY
&& self->memory.base && self->memory.size));
self->glyphs = vector_new(sizeof(texture_glyph_t *));
self->height = 0;
self->ascender = 0;
self->descender = 0;
self->outline_type = 0;
self->outline_thickness = 0.0;
self->hinting = 1;
self->kerning = 1;
self->filtering = 1;
// FT_LCD_FILTER_LIGHT is (0x00, 0x55, 0x56, 0x55, 0x00)
// FT_LCD_FILTER_DEFAULT is (0x10, 0x40, 0x70, 0x40, 0x10)
self->lcd_weights[0] = 0x10;
self->lcd_weights[1] = 0x40;
self->lcd_weights[2] = 0x70;
self->lcd_weights[3] = 0x40;
self->lcd_weights[4] = 0x10;
/* Get font metrics at high resolution */
if (!texture_font_get_hires_face(self, &library, &face))
return -1;
self->underline_position = face->underline_position / (float)(HRESf*HRESf) * self->size;
self->underline_position = round( self->underline_position );
if( self->underline_position > -2 )
{
self->underline_position = -2.0;
}
self->underline_thickness = face->underline_thickness / (float)(HRESf*HRESf) * self->size;
self->underline_thickness = round( self->underline_thickness );
if( self->underline_thickness < 1 )
{
self->underline_thickness = 1.0;
}
metrics = face->size->metrics;
self->ascender = (metrics.ascender >> 6) / 100.0;
self->descender = (metrics.descender >> 6) / 100.0;
self->height = (metrics.height >> 6) / 100.0;
self->linegap = self->height - self->ascender + self->descender;
FT_Done_Face( face );
FT_Done_FreeType( library );
/* -1 is a special glyph */
texture_font_get_glyph( self, -1 );
return 0;
}
// --------------------------------------------- texture_font_new_from_file ---
texture_font_t *
texture_font_new_from_file(texture_atlas_t *atlas, const float pt_size,
const char *filename)
{
texture_font_t *self;
assert(filename);
self = calloc(1, sizeof(*self));
if (!self) {
fprintf(stderr,
"line %d: No more memory for allocating data\n", __LINE__);
return NULL;
}
self->atlas = atlas;
self->size = pt_size;
self->location = TEXTURE_FONT_FILE;
self->filename = strdup(filename);
if (texture_font_init(self)) {
texture_font_delete(self);
return NULL;
}
return self;
}
// ------------------------------------------- texture_font_new_from_memory ---
texture_font_t *
texture_font_new_from_memory(texture_atlas_t *atlas, float pt_size,
const void *memory_base, size_t memory_size)
{
texture_font_t *self;
assert(memory_base);
assert(memory_size);
self = calloc(1, sizeof(*self));
if (!self) {
fprintf(stderr,
"line %d: No more memory for allocating data\n", __LINE__);
return NULL;
}
self->atlas = atlas;
self->size = pt_size;
self->location = TEXTURE_FONT_MEMORY;
self->memory.base = memory_base;
self->memory.size = memory_size;
if (texture_font_init(self)) {
texture_font_delete(self);
return NULL;
}
return self;
}
// ---------------------------------------------------- texture_font_delete ---
void
texture_font_delete( texture_font_t *self )
{
size_t i;
texture_glyph_t *glyph;
assert( self );
if(self->location == TEXTURE_FONT_FILE && self->filename)
free( self->filename );
for( i=0; i<vector_size( self->glyphs ); ++i)
{
glyph = *(texture_glyph_t **) vector_get( self->glyphs, i );
texture_glyph_delete( glyph);
}
vector_delete( self->glyphs );
free( self );
}
// ----------------------------------------------- texture_font_load_glyphs ---
size_t
texture_font_load_glyphs( texture_font_t * self,
const wchar_t * charcodes )
{
size_t i, j, x, y, width, height, depth, w, h;
FT_Library library;
FT_Error error;
FT_Face face;
FT_Glyph ft_glyph;
FT_GlyphSlot slot;
FT_Bitmap ft_bitmap;
FT_UInt glyph_index;
texture_glyph_t *glyph;
FT_Int32 flags = 0;
int ft_glyph_top = 0;
int ft_glyph_left = 0;
ivec4 region;
size_t missed = 0;
char pass;
assert( self );
assert( charcodes );
width = self->atlas->width;
height = self->atlas->height;
depth = self->atlas->depth;
if (!texture_font_get_face(self, &library, &face))
return wcslen(charcodes);
/* Load each glyph */
for( i=0; i<wcslen(charcodes); ++i ) {
pass = 0;
/* Check if charcode has been already loaded */
for(j = 0; j < self->glyphs->size; ++j ) {
glyph = *(texture_glyph_t **) vector_get( self->glyphs, j );
// If charcode is -1, we don't care about outline type or thickness
// if( (glyph->charcode == charcodes[i])) {
if( (glyph->charcode == charcodes[i]) &&
((charcodes[i] == (wchar_t)(-1) ) ||
((glyph->outline_type == self->outline_type) &&
(glyph->outline_thickness == self->outline_thickness)) ))
{
pass = 1;
break;
}
}
if(pass)
continue; // don't add the item
flags = 0;
ft_glyph_top = 0;
ft_glyph_left = 0;
glyph_index = FT_Get_Char_Index( face, charcodes[i] );
// WARNING: We use texture-atlas depth to guess if user wants
// LCD subpixel rendering
if( self->outline_type > 0 )
{
flags |= FT_LOAD_NO_BITMAP;
}
else
{
flags |= FT_LOAD_RENDER;
}
if( !self->hinting )
{
flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT;
}
else
{
flags |= FT_LOAD_FORCE_AUTOHINT;
}
if( depth == 3 )
{
FT_Library_SetLcdFilter( library, FT_LCD_FILTER_LIGHT );
flags |= FT_LOAD_TARGET_LCD;
if( self->filtering )
{
FT_Library_SetLcdFilterWeights( library, self->lcd_weights );
}
}
error = FT_Load_Glyph( face, glyph_index, flags );
if( error )
{
fprintf( stderr, "FT_Error (line %d, code 0x%02x) : %s\n",
__LINE__, FT_Errors[error].code, FT_Errors[error].message );
FT_Done_Face( face );
FT_Done_FreeType( library );
return wcslen(charcodes)-i;
}
if( self->outline_type == 0 )
{
slot = face->glyph;
ft_bitmap = slot->bitmap;
ft_glyph_top = slot->bitmap_top;
ft_glyph_left = slot->bitmap_left;
}
else
{
FT_Stroker stroker;
FT_BitmapGlyph ft_bitmap_glyph;
error = FT_Stroker_New( library, &stroker );
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}
FT_Stroker_Set(stroker,
(int)(self->outline_thickness * HRES),
FT_STROKER_LINECAP_ROUND,
FT_STROKER_LINEJOIN_ROUND,
0);
error = FT_Get_Glyph( face->glyph, &ft_glyph);
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}
if( self->outline_type == 1 )
{
error = FT_Glyph_Stroke( &ft_glyph, stroker, 1 );
}
else if ( self->outline_type == 2 )
{
error = FT_Glyph_StrokeBorder( &ft_glyph, stroker, 0, 1 );
}
else if ( self->outline_type == 3 )
{
error = FT_Glyph_StrokeBorder( &ft_glyph, stroker, 1, 1 );
}
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}
if( depth == 1)
{
error = FT_Glyph_To_Bitmap( &ft_glyph, FT_RENDER_MODE_NORMAL, 0, 1);
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}
}
else
{
error = FT_Glyph_To_Bitmap( &ft_glyph, FT_RENDER_MODE_LCD, 0, 1);
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}
}
ft_bitmap_glyph = (FT_BitmapGlyph) ft_glyph;
ft_bitmap = ft_bitmap_glyph->bitmap;
ft_glyph_top = ft_bitmap_glyph->top;
ft_glyph_left = ft_bitmap_glyph->left;
FT_Stroker_Done(stroker);
}
// We want each glyph to be separated by at least one black pixel
// (for example for shader used in demo-subpixel.c)
w = ft_bitmap.width/depth + 1;
h = ft_bitmap.rows + 1;
region = texture_atlas_get_region( self->atlas, w, h );
if ( region.x < 0 )
{
missed++;
fprintf( stderr, "Texture atlas is full (line %d)\n", __LINE__ );
continue;
}
w = w - 1;
h = h - 1;
x = region.x;
y = region.y;
texture_atlas_set_region( self->atlas, x, y, w, h,
ft_bitmap.buffer, ft_bitmap.pitch );
glyph = texture_glyph_new( );
glyph->charcode = charcodes[i];
glyph->width = w;
glyph->height = h;
glyph->outline_type = self->outline_type;
glyph->outline_thickness = self->outline_thickness;
glyph->offset_x = ft_glyph_left;
glyph->offset_y = ft_glyph_top;
glyph->s0 = x/(float)width;
glyph->t0 = y/(float)height;
glyph->s1 = (x + glyph->width)/(float)width;
glyph->t1 = (y + glyph->height)/(float)height;
// Discard hinting to get advance
FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING);
slot = face->glyph;
glyph->advance_x = slot->advance.x / HRESf;
glyph->advance_y = slot->advance.y / HRESf;
vector_push_back( self->glyphs, &glyph );
if( self->outline_type > 0 )
{
FT_Done_Glyph( ft_glyph );
}
}
FT_Done_Face( face );
FT_Done_FreeType( library );
texture_atlas_upload( self->atlas );
texture_font_generate_kerning( self );
return missed;
}
// ------------------------------------------------- texture_font_get_glyph ---
texture_glyph_t *
texture_font_get_glyph( texture_font_t * self,
wchar_t charcode )
{
size_t i;
wchar_t buffer[2] = {0,0};
texture_glyph_t *glyph;
assert( self );
assert( self );
assert( self->filename );
assert( self->atlas );
/* Check if charcode has been already loaded */
for( i=0; i<self->glyphs->size; ++i )
{
glyph = *(texture_glyph_t **) vector_get( self->glyphs, i );
// If charcode is -1, we don't care about outline type or thickness
if( (glyph->charcode == charcode) &&
((charcode == (wchar_t)(-1) ) ||
((glyph->outline_type == self->outline_type) &&
(glyph->outline_thickness == self->outline_thickness)) ))
{
return glyph;
}
}
/* charcode -1 is special : it is used for line drawing (overline,
* underline, strikethrough) and background.
*/
if( charcode == (wchar_t)(-1) )
{
size_t width = self->atlas->width;
size_t height = self->atlas->height;
ivec4 region = texture_atlas_get_region( self->atlas, 5, 5 );
texture_glyph_t * glyph = texture_glyph_new( );
static unsigned char data[4*4*3] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
if ( region.x < 0 )
{
fprintf( stderr, "Texture atlas is full (line %d)\n", __LINE__ );
return NULL;
}
texture_atlas_set_region( self->atlas, region.x, region.y, 4, 4, data, 0 );
glyph->charcode = (wchar_t)(-1);
glyph->s0 = (region.x+2)/(float)width;
glyph->t0 = (region.y+2)/(float)height;
glyph->s1 = (region.x+3)/(float)width;
glyph->t1 = (region.y+3)/(float)height;
vector_push_back( self->glyphs, &glyph );
return glyph; //*(texture_glyph_t **) vector_back( self->glyphs );
}
/* Glyph has not been already loaded */
buffer[0] = charcode;
if( texture_font_load_glyphs( self, buffer ) == 0 )
{
return *(texture_glyph_t **) vector_back( self->glyphs );
}
return NULL;
}