[Bf-taskforce25] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19912]....

Diego B bdiego at gmail.com
Fri Apr 24 17:01:02 CEST 2009


On Fri, Apr 24, 2009 at 6:25 AM, Ton Roosendaal <ton at blender.org> wrote:
> Hi all,
>
> I'd like to get feedback for font support in Blender.
>
> Our code still supports fallback on bitmap fonts if you build without
> freetype. I wonder if that's a useful spec to still support?
>

Well I think that what is not useful is the "bitmap draw mode", because the
new function shadow/kernel don't work and the text is really ugly and hard to
read, but using this font with the "texture draw mode" work fine and have the
same option that freetype2 (well, not the same, the size of the
internal font are fixed
to what we have built-in, right now helv 10, 12, helvb 8, 10, 12, scr
12, 14, 15).

So we have some options here:
 1) Drop the internal bitmap font and always work with freetype2 (so,
freetype2 is not more optional).
 2) Drop only the "bitmap draw mode", so we can keep internal font and
freetype2 but always draw using texture.
 3) Keep all and work in the Style to handle "bitmap draw mode"

Also when we talk about this some time ago, one of things was move to
texture font by default and keep
the bitmap font one "release" more, and then drop it (if I don't remember bad).

I go to start right now a wiki to put the info about the blenfont, so
it's more easy talk about this :)

> -Ton-
>
> ------------------------------------------------------------------------
> Ton Roosendaal  Blender Foundation   ton at blender.org    www.blender.org
> Blender Institute BV  Entrepotdok 57A  1018AD Amsterdam The Netherlands
>
> On 23 Apr, 2009, at 23:57, Diego Borghetti wrote:
>
>> Revision: 19912
>>
>> http://projects.blender.org/plugins/scmsvn/viewcvs.php?
>> view=rev&root=bf-blender&revision=19912
>> Author:   bdiego
>> Date:     2009-04-23 23:57:41 +0200 (Thu, 23 Apr 2009)
>>
>> Log Message:
>> -----------
>> Move texture draw to blf_util.c, now both font used it.
>>
>> A little cleanup on the internal font, it's possible load the old
>> bmfont with: BLF_load_mem(name, NULL, 0) where name can be: helv,
>> helvb or scr.
>>
>> Note that the internal font also support both draw, texture and bitmap,
>> by default always used texture.
>>
>> Remove some old lang function that I left there and don't exist any
>> more
>> because the locale are now in the RNA.
>>
>> Small changes to Style's, so if we build without freetype2 by default
>> go back to the internal font, this is a little ugly (and have the old
>> problem of scale) but now blender always show text (need work a little
>> more there).
>>
>> Modified Paths:
>> --------------
>>     branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
>>     branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
>>
>> branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c
>>
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal.c
>>
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal.h
>>
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal_types.h
>>
>> branches/blender2.5/blender/source/blender/blenfont/intern/blf_lang.c
>>
>> branches/blender2.5/blender/source/blender/blenfont/intern/blf_util.c
>>
>> branches/blender2.5/blender/source/blender/editors/interface/
>> interface_style.c
>>
>> Modified: branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
>> ===================================================================
>> ---
>> branches/blender2.5/blender/source/blender/blenfont/BLF_api.h 2009-04
>> -23 21:19:42 UTC (rev 19911)
>> +++
>> branches/blender2.5/blender/source/blender/blenfont/BLF_api.h 2009-04
>> -23 21:57:41 UTC (rev 19912)
>> @@ -43,6 +43,12 @@
>>  void BLF_set(int fontid);
>>  int BLF_get(void);
>>
>> +/*
>> + * Return the font type, can be freetype2 or internal, -1 if
>> + * some error happen (no current font).
>> + */
>> +int BLF_type_get(void);
>> +
>>  void BLF_aspect(float aspect);
>>  void BLF_position(float x, float y, float z);
>>  void BLF_size(int size, int dpi);
>> @@ -74,26 +80,18 @@
>>  void BLF_enable(int option);
>>  void BLF_disable(int option);
>>
>> -/* Read the .Blanguages file, return 1 on success or 0 if fails. */
>> -int BLF_lang_init(void);
>> +/*
>> + * Search the path directory to the locale files, this try all
>> + * the case for Linux, Win and Mac.
>> + */
>> +void BLF_lang_init(void);
>>
>> -/* Free the memory allocate for the .Blanguages. */
>> -void BLF_lang_exit(void);
>> +/* Set the current locale. */
>> +void BLF_lang_set(const char *);
>>
>> -/* Set the current Language. */
>> -void BLF_lang_set(int id);
>> +/* Set the current encoding name. */
>> +void BLF_lang_encoding_name(const char *str);
>>
>> -/* Return a string with all the Language available. */
>> -char *BLF_lang_pup(void);
>> -
>> -/* Return the number of invalid lines in the .Blanguages file,
>> - * zero means no error found.
>> - */
>> -int BLF_lang_error(void);
>> -
>> -/* Return the code string for the specified language code. */
>> -char *BLF_lang_find_code(short langid);
>> -
>>  /* Add a path to the font dir paths. */
>>  void BLF_dir_add(const char *path);
>>
>> @@ -114,4 +112,8 @@
>>  #define BLF_MODE_TEXTURE 0
>>  #define BLF_MODE_BITMAP 1
>>
>> +/* font->type */
>> +#define BLF_FONT_FREETYPE2 0
>> +#define BLF_FONT_INTERNAL 1
>> +
>>  #endif /* BLF_API_H */
>>
>> Modified:
>> branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
>> ===================================================================
>> ---
>> branches/blender2.5/blender/source/blender/blenfont/intern/blf.c      2009
>> -04-23 21:19:42 UTC (rev 19911)
>> +++
>> branches/blender2.5/blender/source/blender/blenfont/intern/blf.c      2009
>> -04-23 21:57:41 UTC (rev 19912)
>> @@ -185,7 +185,7 @@
>>       if (!font) {
>>  #ifdef WITH_FREETYPE2
>>               if (!mem || !mem_size) {
>> -                     printf("Can't load font, %s from memory!!\n", name);
>> +                     printf("Can't load font: %s from memory!!\n", name);
>>                       return(-1);
>>               }
>>
>> @@ -193,7 +193,7 @@
>>  #endif /* WITH_FREETYPE2 */
>>
>>               if (!font) {
>> -                     printf("Can't load font, %s from memory!!\n", name);
>> +                     printf("Can't load font: %s from memory!!\n", name);
>>                       return(-1);
>>               }
>>       }
>> @@ -215,6 +215,16 @@
>>       return(global_font_cur);
>>  }
>>
>> +int BLF_type_get(void)
>> +{
>> +     FontBLF *font;
>> +
>> +     font= global_font[global_font_cur];
>> +     if (font)
>> +             return(font->type);
>> +     return(-1);
>> +}
>> +
>>  void BLF_enable(int option)
>>  {
>>       FontBLF *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-04-23 21:19:42 UTC (rev 19911)
>> +++
>> branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c
>>       2009-04-23 21:57:41 UTC (rev 19912)
>> @@ -433,69 +433,6 @@
>>       MEM_freeN(g);
>>  }
>>
>> -static void blf_glyph_texture_draw(float uv[2][2], float dx, float
>> y1, float dx1, float y2)
>> -{
>> -
>> -     glBegin(GL_QUADS);
>> -     glTexCoord2f(uv[0][0], uv[0][1]);
>> -     glVertex2f(dx, y1);
>> -
>> -     glTexCoord2f(uv[0][0], uv[1][1]);
>> -     glVertex2f(dx, y2);
>> -
>> -     glTexCoord2f(uv[1][0], uv[1][1]);
>> -     glVertex2f(dx1, y2);
>> -
>> -     glTexCoord2f(uv[1][0], uv[0][1]);
>> -     glVertex2f(dx1, y1);
>> -     glEnd();
>> -
>> -}
>> -
>> -static void blf_glyph_texture5_draw(float uv[2][2], float x1, float
>> y1, float x2, float y2)
>> -{
>> -     float soft[25]= {
>> -             1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f,
>> -             1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
>> -             2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f,
>> -             1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
>> -             1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f};
>> -
>> -     float color[4], *fp= soft;
>> -     int dx, dy;
>> -
>> -     glGetFloatv(GL_CURRENT_COLOR, color);
>> -
>> -     for(dx=-2; dx<3; dx++) {
>> -             for(dy=-2; dy<3; dy++, fp++) {
>> -                     glColor4f(color[0], color[1], color[2], fp[0]*color[3]);
>> -                     blf_glyph_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy);
>> -             }
>> -     }
>> -
>> -     glColor4fv(color);
>> -}
>> -
>> -static void blf_glyph_texture3_draw(float uv[2][2], float x1, float
>> y1, float x2, float y2)
>> -{
>> -     float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f,
>> 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f};
>> -     float color[4], *fp= soft;
>> -     int dx, dy;
>> -
>> -     glGetFloatv(GL_CURRENT_COLOR, color);
>> -
>> -     for(dx=-1; dx<2; dx++) {
>> -             for(dy=-1; dy<2; dy++, fp++) {
>> -                     glColor4f(color[0], color[1], color[2], fp[0]*color[3]);
>> -                     blf_glyph_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy);
>> -             }
>> -     }
>> -
>> -     glColor4fv(color);
>> -}
>> -
>> -
>> -
>>  int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x,
>> float y)
>>  {
>>       GlyphTextureBLF *gt;
>> @@ -525,11 +462,11 @@
>>               glBindTexture(GL_TEXTURE_2D, gt->tex);
>>
>>       if (font->blur==3)
>> -             blf_glyph_texture3_draw(gt->uv, dx, y1, dx1, y2);
>> +             blf_texture3_draw(gt->uv, dx, y1, dx1, y2);
>>       else if (font->blur==5)
>> -             blf_glyph_texture5_draw(gt->uv, dx, y1, dx1, y2);
>> +             blf_texture5_draw(gt->uv, dx, y1, dx1, y2);
>>       else
>> -             blf_glyph_texture_draw(gt->uv, dx, y1, dx1, y2);
>> +             blf_texture_draw(gt->uv, dx, y1, dx1, y2);
>>
>>       return(1);
>>  }
>>
>> Modified:
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal.c
>> ===================================================================
>> ---
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal.c        2009-04-23 21:19:42 UTC (rev 19911)
>> +++
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal.c        2009-04-23 21:57:41 UTC (rev 19912)
>> @@ -141,7 +141,58 @@
>>
>>  void blf_internal_size(FontBLF *font, int size, int dpi)
>>  {
>> -     return;
>> +     /* dpi don't work here and size is limit to:
>> +      * helv: 10, 12
>> +      * helvb: 8, 10, 12
>> +      * scr: 12, 14, 15
>> +      */
>> +     font->dpi= dpi;
>> +
>> +     if (font->size != size) {
>> +             if (!strcmp(font->name, "helv")) {
>> +                     if (size == 12) {
>> +                             font->engine= (void *)&blf_font_helv12;
>> +                             font->size= 12;
>> +                     }
>> +                     else {
>> +                             font->engine= (void *)&blf_font_helv10;
>> +                             font->size= 10;
>> +                     }
>> +             }
>> +             else if (!strcmp(font->name, "helvb")) {
>> +                     if (size == 10) {
>> +                             font->engine= (void *)&blf_font_helvb10;
>> +                             font->size= 10;
>> +                     }
>> +                     else if (size == 12) {
>> +                             font->engine= (void *)&blf_font_helvb12;
>> +                             font->size= 12;
>> +                     }
>> +                     else {
>> +                             font->engine= (void *)&blf_font_helvb8;
>> +                             font->size= 8;
>> +                     }
>> +             }
>> +             else { /* scr */
>> +                     if (size == 14) {
>> +                             font->engine= (void *)&blf_font_scr14;
>> +                             font->size= 14;
>> +                     }
>> +                     else if (size == 15) {
>> +                             font->engine= (void *)&blf_font_scr15;
>> +                             font->size= 15;
>> +                     }
>> +                     else {
>> +                             font->engine= (void *)&blf_font_scr12;
>> +                             font->size= 12;
>> +                     }
>> +             }
>> +
>> +             if (font->mode == BLF_MODE_TEXTURE) {
>> +                     if (blf_internal_get_texture(font) != 0)
>> +                             printf("Can't create texture font!!\n");
>> +             }
>> +     }
>>  }
>>
>>  void blf_internal_texture_draw(FontBLF *font, char *str)
>> @@ -149,7 +200,8 @@
>>       FontDataBLF *data;
>>       CharDataBLF *cd;
>>       unsigned char c;
>> -     float pos, cell_x, cell_y, x, y, z;
>> +     float pos, x, y;
>> +     float uv[2][2];
>>       int base_line;
>>       GLint cur_tex;
>>       float dx, dx1, dy, dy1;
>> @@ -159,7 +211,6 @@
>>       pos= 0;
>>       x= 0.0f;
>>       y= 0.0f;
>> -     z= 0.0f;
>>
>>       glGetIntegerv(GL_TEXTURE_2D_BINDING_EXT, &cur_tex);
>>       if (cur_tex != data->texid)
>> @@ -169,8 +220,10 @@
>>               cd= &data->chars[c];
>>
>>               if (cd->data_offset != -1) {
>> -                     cell_x= (c%16)/16.0;
>> -                     cell_y= (c/16)/16.0;
>> +                     uv[0][0]= ((c%16)/16.0) + 1.0/16.0;
>> +                     uv[0][1]= (c/16)/16.0;
>> +                     uv[1][0]= (c%16)/16.0;
>> +                     uv[1][1]= ((c/16)/16.0) + 1.0/16.0;
>>
>>                       dx= x + pos + 16.0;
>>                       dx1= x + pos + 0.0;
>> @@ -189,19 +242,12 @@
>>                                       goto next_tex_char;
>>                       }
>>
>> -                     glBegin(GL_QUADS);
>> -                     glTexCoord2f(cell_x + 1.0/16.0, cell_y);
>> -                     glVertex3f(dx, dy, z);
>> -
>> -                     glTexCoord2f(cell_x + 1.0/16.0, cell_y + 1.0/16.0);
>> -                     glVertex3f(dx, dy1, z);
>> -
>> -                     glTexCoord2f(cell_x, cell_y + 1.0/16.0);
>> -                     glVertex3f(dx1, dy1, z);
>> -
>> -                     glTexCoord2f(cell_x, cell_y);
>> -                     glVertex3f(dx1, dy, z);
>> -                     glEnd();
>> +                     if (font->blur == 3)
>> +                             blf_texture3_draw(uv, dx, dy, dx1, dy1);
>> +                     else if (font->blur == 5)
>> +                             blf_texture5_draw(uv, dx, dy, dx1, dy1);
>> +                     else
>> +                             blf_texture_draw(uv, dx, dy, dx1, dy1);
>>               }
>>  next_tex_char:
>>               pos += cd->advance;
>> @@ -328,39 +374,19 @@
>>       font->name= BLI_strdup(name);
>>       font->filename= NULL;
>>
>> -     if (!strcmp(name, "helv10")) {
>> +     if (!strcmp(name, "helv")) {
>>               font->engine= (void *)&blf_font_helv10;
>>               font->size= 10;
>>       }
>>  #ifndef BLF_INTERNAL_MINIMAL
>> -     else if (!strcmp(name, "helv12")) {
>> -             font->engine= (void *)&blf_font_helv12;
>> -             font->size= 12;
>> -     }
>> -     else if (!strcmp(name, "helvb8")) {
>> +     else if (!strcmp(name, "helvb")) {
>>               font->engine= (void *)&blf_font_helvb8;
>>               font->size= 8;
>>       }
>> -     else if (!strcmp(name, "helvb10")) {
>> -             font->engine= (void *)&blf_font_helvb10;
>> -             font->size= 10;
>> -     }
>> -     else if (!strcmp(name, "helvb12")) {
>> -             font->engine= (void *)&blf_font_helvb12;
>> -             font->size= 12;
>> -     }
>> -     else if (!strcmp(name, "scr12")) {
>> +     else if (!strcmp(name, "scr")) {
>>               font->engine= (void *)&blf_font_scr12;
>>               font->size= 12;
>>       }
>> -     else if (!strcmp(name, "scr14")) {
>> -             font->engine= (void *)&blf_font_scr14;
>> -             font->size= 14;
>> -     }
>> -     else if (!strcmp(name, "scr15")) {
>> -             font->engine= (void *)&blf_font_scr15;
>> -             font->size= 15;
>> -     }
>>  #endif
>>       else
>>               font->engine= NULL;
>>
>> Modified:
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal.h
>> ===================================================================
>> ---
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal.h        2009-04-23 21:19:42 UTC (rev 19911)
>> +++
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal.h        2009-04-23 21:57:41 UTC (rev 19912)
>> @@ -32,6 +32,10 @@
>>  unsigned int blf_hash(unsigned int val);
>>  int blf_utf8_next(unsigned char *buf, int *iindex);
>>
>> +void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1,
>> float y2);
>> +void blf_texture5_draw(float uv[2][2], float x1, float y1, float x2,
>> float y2);
>> +void blf_texture3_draw(float uv[2][2], float x1, float y1, float x2,
>> float y2);
>> +
>>  char *blf_dir_search(const char *file);
>>  int blf_dir_split(const char *str, char *file, int *size);
>>
>>
>> Modified:
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal_types.h
>> ===================================================================
>> ---
>> branches/blender2.5/blender/source/blender/blenfont/intern/
>> blf_internal_types.h  2009-04-23 21:19:42 UTC (rev 19911)
>>
>> @@ Diff output truncated at 10240 characters. @@
>>
>> _______________________________________________
>> Bf-blender-cvs mailing list
>> Bf-blender-cvs at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>>
>
> _______________________________________________
> Bf-taskforce25 mailing list
> Bf-taskforce25 at blender.org
> http://lists.blender.org/mailman/listinfo/bf-taskforce25
>


More information about the Bf-taskforce25 mailing list