Revision: 20110
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20110
Author:   bdiego
Date:     2009-05-08 21:47:40 +0200 (Fri, 08 May 2009)

Log Message:
-----------
Cleanup blendfont.

Now that we only work with Freetype2, I don't see any point to keep
wrapping the functions.

Also remove the reference code, it's something that we don't go to used.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.h
    
branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal_types.h

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf.c    
2009-05-08 19:37:14 UTC (rev 20109)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf.c    
2009-05-08 19:47:40 UTC (rev 20110)
@@ -95,8 +95,8 @@
 
        for (i= 0; i < global_font_num; i++) {
                font= global_font[i];
-               if(font && font->free)
-                       (*font->free)(font);
+               if (font)
+                       blf_font_free(font);
        }
 
        blf_font_exit();
@@ -128,8 +128,6 @@
        i= blf_search(name);
        if (i >= 0) {
                font= global_font[i];
-               font->ref++;
-               printf("Increment reference (%d): %s\n", font->ref, name);
                return(i);
        }
 
@@ -169,8 +167,6 @@
        i= blf_search(name);
        if (i >= 0) {
                font= global_font[i];
-               font->ref++;
-               printf("Increment reference (%d): %s\n", font->ref, name);
                return(i);
        }
 
@@ -268,8 +264,8 @@
        FontBLF *font;
 
        font= global_font[global_font_cur];
-       if (font && font->size_set)
-               (*font->size_set)(font, size, dpi);
+       if (font)
+               blf_font_size(font, size, dpi);
 }
 
 void BLF_blur(int size)
@@ -326,7 +322,7 @@
         */
 
        font= global_font[global_font_cur];
-       if (font && font->draw) {
+       if (font) {
                if (font->mode == BLF_MODE_BITMAP) {
                        glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
                        glPushAttrib(GL_ENABLE_BIT);
@@ -335,7 +331,7 @@
                        glDisable(GL_BLEND);
                        glRasterPos3f(font->pos[0], font->pos[1], font->pos[2]);
 
-                       (*font->draw)(font, str);
+                       blf_font_draw(font, str);
 
                        glPopAttrib();
                        glPopClientAttrib();
@@ -352,7 +348,7 @@
                        if (font->flags & BLF_ROTATION)
                                glRotatef(font->angle, 0.0f, 0.0f, 1.0f);
 
-                       (*font->draw)(font, str);
+                       blf_font_draw(font, str);
 
                        glPopMatrix();
                        glDisable(GL_BLEND);
@@ -366,8 +362,8 @@
        FontBLF *font;
 
        font= global_font[global_font_cur];
-       if (font && font->boundbox_get)
-               (*font->boundbox_get)(font, str, box);
+       if (font)
+               blf_font_boundbox(font, str, box);
 }
 
 float BLF_width(char *str)
@@ -375,8 +371,8 @@
        FontBLF *font;
 
        font= global_font[global_font_cur];
-       if (font && font->width_get)
-               return((*font->width_get)(font, str));
+       if (font)
+               return(blf_font_width(font, str));
        return(0.0f);
 }
 
@@ -418,8 +414,8 @@
        FontBLF *font;
 
        font= global_font[global_font_cur];
-       if (font && font->height_get)
-               return((*font->height_get)(font, str));
+       if (font)
+               return(blf_font_height(font, str));
        return(0.0f);
 }
 

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c       
2009-05-08 19:37:14 UTC (rev 20109)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c       
2009-05-08 19:47:40 UTC (rev 20110)
@@ -72,7 +72,7 @@
        GlyphCacheBLF *gc;
        FT_Error err;
 
-       err= FT_Set_Char_Size((FT_Face)font->engine, 0, (size * 64), dpi, dpi);
+       err= FT_Set_Char_Size(font->face, 0, (size * 64), dpi, dpi);
        if (err) {
                /* FIXME: here we can go through the fixed size and choice a 
close one */
                printf("The current font don't support the size, %d and dpi, 
%d\n", size, dpi);
@@ -99,7 +99,6 @@
        unsigned int c;
        GlyphBLF *g, *g_prev;
        FT_Vector delta;
-       FT_Face face;
        FT_UInt glyph_index, g_prev_index;
        int pen_x, pen_y;
        int i, has_kerning;
@@ -107,11 +106,10 @@
        if (!font->glyph_cache)
                return;
 
-       face= (FT_Face)font->engine;
        i= 0;
        pen_x= 0;
        pen_y= 0;
-       has_kerning= FT_HAS_KERNING(face);
+       has_kerning= FT_HAS_KERNING(font->face);
        g_prev= NULL;
        g_prev_index= 0;
 
@@ -120,7 +118,7 @@
                if (c == 0)
                        break;
 
-               glyph_index= FT_Get_Char_Index(face, c);
+               glyph_index= FT_Get_Char_Index(font->face, c);
                g= blf_glyph_search(font->glyph_cache, c);
                if (!g)
                        g= blf_glyph_add(font, glyph_index, c);
@@ -144,7 +142,7 @@
                        delta.x= 0;
                        delta.y= 0;
 
-                       FT_Get_Kerning(face, g_prev_index, glyph_index, 
FT_KERNING_UNFITTED, &delta);
+                       FT_Get_Kerning(font->face, g_prev_index, glyph_index, 
FT_KERNING_UNFITTED, &delta);
                        pen_x += delta.x >> 6;
                }
 
@@ -163,7 +161,6 @@
        GlyphBLF *g, *g_prev;
        FT_Vector delta;
        FT_UInt glyph_index, g_prev_index;
-       FT_Face face;
        rctf gbox;
        int pen_x, pen_y;
        int i, has_kerning;
@@ -171,7 +168,6 @@
        if (!font->glyph_cache)
                return;
 
-       face= (FT_Face)font->engine;
        box->xmin= 32000.0f;
        box->xmax= -32000.0f;
        box->ymin= 32000.0f;
@@ -180,7 +176,7 @@
        i= 0;
        pen_x= 0;
        pen_y= 0;
-       has_kerning= FT_HAS_KERNING(face);
+       has_kerning= FT_HAS_KERNING(font->face);
        g_prev= NULL;
        g_prev_index= 0;
 
@@ -189,7 +185,7 @@
                if (c == 0)
                        break;
 
-               glyph_index= FT_Get_Char_Index(face, c);
+               glyph_index= FT_Get_Char_Index(font->face, c);
                g= blf_glyph_search(font->glyph_cache, c);
                if (!g)
                        g= blf_glyph_add(font, glyph_index, c);
@@ -213,7 +209,7 @@
                        delta.x= 0;
                        delta.y= 0;
 
-                       FT_Get_Kerning(face, g_prev_index, glyph_index, 
FT_KERNING_UNFITTED, &delta);
+                       FT_Get_Kerning(font->face, g_prev_index, glyph_index, 
FT_KERNING_UNFITTED, &delta);
                        pen_x += delta.x >> 6;
                }
 
@@ -278,7 +274,7 @@
                blf_glyph_cache_free(gc);
        }
 
-       FT_Done_Face((FT_Face)font->engine);
+       FT_Done_Face(font->face);
        if (font->filename)
                MEM_freeN(font->filename);
        if (font->name)
@@ -289,7 +285,6 @@
 void blf_font_fill(FontBLF *font)
 {
        font->mode= BLF_MODE_TEXTURE;
-       font->ref= 1;
        font->aspect= 1.0f;
        font->pos[0]= 0.0f;
        font->pos[1]= 0.0f;
@@ -305,37 +300,32 @@
        font->cache.first= NULL;
        font->cache.last= NULL;
        font->glyph_cache= NULL;
+       font->blur= 0;
        glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
-
-       font->size_set= blf_font_size;
-       font->draw= blf_font_draw;
-       font->boundbox_get= blf_font_boundbox;
-       font->width_get= blf_font_width;
-       font->height_get= blf_font_height;
-       font->free= blf_font_free;
 }
 
 FontBLF *blf_font_new(char *name, char *filename)
 {
        FontBLF *font;
        FT_Error err;
-       FT_Face face;
 
-       err= FT_New_Face(global_ft_lib, filename, 0, &face);
-       if (err)
+       font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new");
+       err= FT_New_Face(global_ft_lib, filename, 0, &font->face);
+       if (err) {
+               MEM_freeN(font);
                return(NULL);
+       }
 
-       err= FT_Select_Charmap(face, ft_encoding_unicode);
+       err= FT_Select_Charmap(font->face, ft_encoding_unicode);
        if (err) {
                printf("Can't set the unicode character map!\n");
-               FT_Done_Face(face);
+               FT_Done_Face(font->face);
+               MEM_freeN(font);
                return(NULL);
        }
 
-       font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new");
        font->name= BLI_strdup(name);
        font->filename= BLI_strdup(filename);
-       font->engine= (void *)face;
        blf_font_fill(font);
        return(font);
 }
@@ -344,24 +334,24 @@
 {
        FontBLF *font;
        FT_Error err;
-       FT_Face face;
 
-       err= FT_New_Memory_Face(global_ft_lib, mem, mem_size, 0, &face);
-       if (err)
+       font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem");
+       err= FT_New_Memory_Face(global_ft_lib, mem, mem_size, 0, &font->face);
+       if (err) {
+               MEM_freeN(font);
                return(NULL);
+       }
 
-       err= FT_Select_Charmap(face, ft_encoding_unicode);
+       err= FT_Select_Charmap(font->face, ft_encoding_unicode);
        if (err) {
                printf("Can't set the unicode character map!\n");
-               FT_Done_Face(face);
+               FT_Done_Face(font->face);
+               MEM_freeN(font);
                return(NULL);
        }
 
-       font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem");
        font->name= BLI_strdup(name);
        font->filename= NULL;
-       font->engine= (void *)face;
-       font->blur= 0;
        blf_font_fill(font);
        return(font);
 }

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c      
2009-05-08 19:37:14 UTC (rev 20109)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c      
2009-05-08 19:47:40 UTC (rev 20110)
@@ -72,10 +72,8 @@
 GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
 {
        GlyphCacheBLF *gc;
-       FT_Face face;
        int i;
 
-       face= (FT_Face)font->engine;
        gc= (GlyphCacheBLF *)MEM_mallocN(sizeof(GlyphCacheBLF), 
"blf_glyph_cache_new");
        gc->next= NULL;
        gc->prev= NULL;
@@ -94,23 +92,23 @@
        gc->y_offs= 0;
        gc->pad= 3;
 
-       gc->num_glyphs= face->num_glyphs;
-       gc->rem_glyphs= face->num_glyphs;
-       gc->ascender= ((float)face->size->metrics.ascender) / 64.0f;
-       gc->descender= ((float)face->size->metrics.descender) / 64.0f;
+       gc->num_glyphs= font->face->num_glyphs;
+       gc->rem_glyphs= font->face->num_glyphs;
+       gc->ascender= ((float)font->face->size->metrics.ascender) / 64.0f;
+       gc->descender= ((float)font->face->size->metrics.descender) / 64.0f;
 
-       if (FT_IS_SCALABLE(face)) {
-               gc->max_glyph_width= (float)((face->bbox.xMax - 
face->bbox.xMin) *
-                                       (((float)face->size->metrics.x_ppem) /
-                                        ((float)face->units_per_EM)));
+       if (FT_IS_SCALABLE(font->face)) {
+               gc->max_glyph_width= (float)((font->face->bbox.xMax - 
font->face->bbox.xMin) *
+                                       
(((float)font->face->size->metrics.x_ppem) /
+                                        ((float)font->face->units_per_EM)));
 
-               gc->max_glyph_height= (float)((face->bbox.yMax - 
face->bbox.yMin) *
-                                       (((float)face->size->metrics.y_ppem) /
-                                        ((float)face->units_per_EM)));
+               gc->max_glyph_height= (float)((font->face->bbox.yMax - 
font->face->bbox.yMin) *
+                                       
(((float)font->face->size->metrics.y_ppem) /
+                                        ((float)font->face->units_per_EM)));
        }
        else {
-               gc->max_glyph_width= ((float)face->size->metrics.max_advance) / 
64.0f;
-               gc->max_glyph_height= ((float)face->size->metrics.height) / 
64.0f;
+               gc->max_glyph_width= 
((float)font->face->size->metrics.max_advance) / 64.0f;
+               gc->max_glyph_height= ((float)font->face->size->metrics.height) 
/ 64.0f;
        }
 
        gc->p2_width= 0;
@@ -197,7 +195,6 @@
        GlyphCacheBLF *gc;
        GlyphBLF *g;
        GlyphTextureBLF *gt;
-       FT_Face face;
        FT_Error err;
        FT_Bitmap bitmap;
        FT_BBox bbox;
@@ -216,13 +213,12 @@
        else
                do_new= 1;
 
-       face= (FT_Face)font->engine;
-       err= FT_Load_Glyph(face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP);
+       err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | 
FT_LOAD_NO_BITMAP);
        if (err)
                return(NULL);
 
        /* get the glyph. */
-       slot= face->glyph;
+       slot= font->face->glyph;
 
        err= FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
        if (err || slot->format != FT_GLYPH_FORMAT_BITMAP)
@@ -311,7 +307,6 @@
        GlyphCacheBLF *gc;
        GlyphBLF *g;
        GlyphBitmapBLF *gt;
-       FT_Face face;
        FT_Error err;
        FT_Bitmap bitmap;
        FT_BBox bbox;
@@ -333,13 +328,12 @@
        else
                do_new= 1;
 
-       face= (FT_Face)font->engine;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to