Yes!! a nice font again!!
authorDiego Borghetti <bdiego@gmail.com>
Fri, 10 Jul 2009 20:18:19 +0000 (20:18 +0000)
committerDiego Borghetti <bdiego@gmail.com>
Fri, 10 Jul 2009 20:18:19 +0000 (20:18 +0000)
Matt, I found the problem in one of my previous commit, so I revert
all my changes and now the font look good again.

Also remove all the options (kerning, overlap and user kerning), I want
to make this a little better.

source/blender/blenfont/BLF_api.h
source/blender/blenfont/intern/blf.c
source/blender/blenfont/intern/blf_font.c
source/blender/blenfont/intern/blf_glyph.c
source/blender/blenfont/intern/blf_internal_types.h
source/blender/editors/interface/interface_style.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index c373fde5693f7d6a9228a300b32f0ae20c8a46f3..53f108f87ebaa3ec0f15c6b5d66828f640e582fb 100644 (file)
@@ -90,7 +90,6 @@ void BLF_default_rotation(float angle);
 void BLF_rotation(float angle);
 void BLF_clipping(float xmin, float ymin, float xmax, float ymax);
 void BLF_blur(int size);
-void BLF_kerning(float space);
 
 void BLF_enable(int option);
 void BLF_disable(int option);
@@ -137,10 +136,7 @@ void BLF_dir_free(char **dirs, int count);
 /* font->flags. */
 #define BLF_ROTATION (1<<0)
 #define BLF_CLIPPING (1<<1)
-#define BLF_FONT_KERNING (1<<2)
-#define BLF_USER_KERNING (1<<3)
-#define BLF_SHADOW (1<<4)
-#define BLF_OVERLAP_CHAR (1<<5)
+#define BLF_SHADOW (1<<2)
 
 /* font->mode. */
 #define BLF_MODE_TEXTURE 0
index a7e599fabf9c0f813d56c36dee87b4db57513adf..9a249c2f2412085b28862e99ad220d94d5dde4a9 100644 (file)
@@ -505,15 +505,6 @@ void BLF_mode(int mode)
                font->mode= mode;
 }
 
-void BLF_kerning(float space)
-{
-       FontBLF *font;
-
-       font= global_font[global_font_cur];
-       if (font)
-               font->kerning= space;
-}
-
 void BLF_shadow(int level, float r, float g, float b, float a)
 {
        FontBLF *font;
index a3c5232cc76f8ac05011a5b55b5b255b906732ef..989746ca501344389df9900817cf29e5b35202ab 100644 (file)
@@ -101,7 +101,7 @@ void blf_font_draw(FontBLF *font, char *str)
        GlyphBLF *g, *g_prev;
        FT_Vector delta;
        FT_UInt glyph_index, g_prev_index;
-       float pen_x, pen_y, old_pen_x;
+       int pen_x, pen_y;
        int i, has_kerning;
 
        if (!font->glyph_cache)
@@ -139,33 +139,17 @@ void blf_font_draw(FontBLF *font, char *str)
                else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data))
                        g= blf_glyph_add(font, glyph_index, c);
 
-               if ((font->flags & BLF_FONT_KERNING) && has_kerning && g_prev) {
-                       old_pen_x= pen_x;
+               if (has_kerning && g_prev) {
                        delta.x= 0;
                        delta.y= 0;
 
                        if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) {
                                pen_x += delta.x >> 6;
-
-                               if (font->flags & BLF_OVERLAP_CHAR) {
-                                       if (pen_x < old_pen_x)
-                                               pen_x= old_pen_x;
-                               }
-                       }
-               }
-
-               if (font->flags & BLF_USER_KERNING) {
-                       old_pen_x= pen_x;
-                       pen_x += font->kerning;
-
-                       if (font->flags & BLF_OVERLAP_CHAR) {
-                               if (pen_x < old_pen_x)
-                                       pen_x= old_pen_x;
                        }
                }
 
                /* do not return this loop if clipped, we want every character tested */
-               blf_glyph_render(font, g, pen_x, pen_y);
+               blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
 
                pen_x += g->advance;
                g_prev= g;
@@ -180,7 +164,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
        FT_Vector delta;
        FT_UInt glyph_index, g_prev_index;
        rctf gbox;
-       float pen_x, pen_y, old_pen_x;
+       int pen_x, pen_y;
        int i, has_kerning;
 
        if (!font->glyph_cache)
@@ -223,28 +207,12 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
                else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data))
                        g= blf_glyph_add(font, glyph_index, c);
 
-               if ((font->flags & BLF_FONT_KERNING) && has_kerning && g_prev) {
-                       old_pen_x= pen_x;
+               if (has_kerning && g_prev) {
                        delta.x= 0;
                        delta.y= 0;
 
                        if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) {
                                pen_x += delta.x >> 6;
-
-                               if (font->flags & BLF_OVERLAP_CHAR) {
-                                       if (pen_x < old_pen_x)
-                                               pen_x= old_pen_x;
-                               }
-                       }
-               }
-
-               if (font->flags & BLF_USER_KERNING) {
-                       old_pen_x= pen_x;
-                       pen_x += font->kerning;
-
-                       if (font->flags & BLF_OVERLAP_CHAR) {
-                               if (pen_x < old_pen_x)
-                                       pen_x= old_pen_x;
                        }
                }
 
@@ -329,10 +297,9 @@ void blf_font_fill(FontBLF *font)
        font->clip_rec.xmax= 0.0f;
        font->clip_rec.ymin= 0.0f;
        font->clip_rec.ymax= 0.0f;
-       font->flags= BLF_USER_KERNING | BLF_FONT_KERNING;
+       font->flags= 0;
        font->dpi= 0;
        font->size= 0;
-       font->kerning= 0.0f;
        font->cache.first= NULL;
        font->cache.last= NULL;
        font->glyph_cache= NULL;
index a637774d7bf8dbd2173f26525ca0322d4f546098..d2767d6ffb18def4cf82345a005d99270a6ee5c7 100644 (file)
@@ -213,11 +213,7 @@ GlyphBLF *blf_glyph_texture_add(FontBLF *font, FT_UInt index, unsigned int c)
        else
                do_new= 1;
 
-       if (font->flags & BLF_FONT_KERNING)
-               err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_BITMAP);
-       else
-               err= FT_Load_Glyph(font->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);
 
@@ -332,11 +328,7 @@ GlyphBLF *blf_glyph_bitmap_add(FontBLF *font, FT_UInt index, unsigned int c)
        else
                do_new= 1;
 
-       if (font->flags & BLF_FONT_KERNING)
-               err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_BITMAP);
-       else
-               err= FT_Load_Glyph(font->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);
 
index 5382ac19aae2ba933a0f8b13faacbc4229087b98..64d959868675f3989de1f2ef41945673be4cf637 100644 (file)
@@ -177,9 +177,6 @@ typedef struct FontBLF {
        /* font size. */
        int size;
 
-       /* kerning space, user setting. */
-       float kerning;
-
        /* max texture size. */
        int max_tex_size;
 
index e8fba38f793f5f06a35068f4cac3a15cda337556..9ff1f2d6b2978144df696074256eb0be91580954 100644 (file)
@@ -91,8 +91,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name)
        
        style->paneltitle.uifont_id= UIFONT_DEFAULT;
        style->paneltitle.points= 13;
-       style->paneltitle.kerning= 0.0;
-       style->paneltitle.overlap= 0;
        style->paneltitle.shadow= 5;
        style->paneltitle.shadx= 2;
        style->paneltitle.shady= -2;
@@ -101,8 +99,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name)
        
        style->grouplabel.uifont_id= UIFONT_DEFAULT;
        style->grouplabel.points= 12;
-       style->grouplabel.kerning= 0.0;
-       style->grouplabel.overlap= 0;
        style->grouplabel.shadow= 3;
        style->grouplabel.shadx= 1;
        style->grouplabel.shady= -1;
@@ -110,8 +106,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name)
        
        style->widgetlabel.uifont_id= UIFONT_DEFAULT;
        style->widgetlabel.points= 11;
-       style->widgetlabel.kerning= 0.0;
-       style->widgetlabel.overlap= 0;
        style->widgetlabel.shadow= 3;
        style->widgetlabel.shadx= 1;
        style->widgetlabel.shady= -1;
@@ -120,7 +114,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name)
        
        style->widget.uifont_id= UIFONT_DEFAULT;
        style->widget.points= 11;
-       style->widget.kerning= 0.0;
        style->widget.shadowalpha= 0.25f;
 
        style->columnspace= 5;
@@ -174,15 +167,10 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str)
                BLF_shadow_offset(fs->shadx, fs->shady);
        }
 
-       if (fs->overlap)
-               BLF_enable(BLF_OVERLAP_CHAR);
-
        BLF_draw(str);
        BLF_disable(BLF_CLIPPING);
        if (fs->shadow)
                BLF_disable(BLF_SHADOW);
-       if (fs->overlap)
-               BLF_disable(BLF_OVERLAP_CHAR);
 }
 
 /* ************** helpers ************************ */
@@ -263,6 +251,5 @@ void uiStyleFontSet(uiFontStyle *fs)
        
        BLF_set(font->blf_id);
        BLF_size(fs->points, U.dpi);
-       BLF_kerning(fs->kerning);
 }
 
index 771a7e4379338046d5dbb8bed46764727bc240da..dec3fde8f5388df7e2dca29336aa12806b7cd097 100644 (file)
@@ -66,9 +66,6 @@ typedef struct uiFont {
 typedef struct uiFontStyle {
        short uifont_id;                /* saved in file, 0 is default */
        short points;                   /* actual size depends on 'global' dpi */
-       float kerning;                  /* kerning space between characters. */
-       short overlap;                  /* check overlaped characters. */
-       short pad;
        short italic, bold;             /* style hint */
        short shadow;                   /* value is amount of pixels blur */
        short shadx, shady;             /* shadow offset in pixels */
index 609082144e1c2497e7913602825ce6c8c2853b65..a2bc652ad1ae2e590752dbe6707469afa7333b28 100644 (file)
@@ -137,16 +137,6 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Points", "");
        RNA_def_property_update(prop, NC_WINDOW, NULL);
 
-       prop= RNA_def_property(srna, "kerning", PROP_FLOAT, PROP_NONE);
-       RNA_def_property_range(prop, -5.0, 5.0);
-       RNA_def_property_ui_text(prop, "Kerning", "User kerning value in pixels");
-       RNA_def_property_update(prop, NC_WINDOW, NULL);
-
-       prop= RNA_def_property(srna, "overlap", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "overlap", 1);
-       RNA_def_property_ui_text(prop, "Overlap", "Check for overlap characters");
-       RNA_def_property_update(prop, NC_WINDOW, NULL);
-
        prop= RNA_def_property(srna, "shadow", PROP_INT, PROP_NONE);
        RNA_def_property_range(prop, 0, 5);
        RNA_def_property_ui_text(prop, "Shadow Size", "Shadow size in pixels (0, 3 and 5 supported)");