diff options
author | Diego Borghetti <bdiego@gmail.com> | 2009-06-23 22:26:01 +0400 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2009-06-23 22:26:01 +0400 |
commit | 483e9479f73dca77fd3b6db7ede72849b1552859 (patch) | |
tree | cc16d905377eb8f036933a93a15ee17b88a38cfb | |
parent | 30d769e2cda8851cbd45ca5ebf074d90b7f9cbc1 (diff) |
New Style option: Overlap
If this option is enable, the blenfont check for overlap characters, like
one of my previous commit but now it's optional and disable by default.
(This fix the "Fi" or other case when the characters are too close)
Enable/disable from:
Outliner -> User Preferences -> Styles -> Panel Font -> Overlap
(also for other styles, Group Label, Widget, Widget Label)
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 1 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 36 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 7 |
6 files changed, 39 insertions, 18 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index cb64615d64c..2ee31a17fa6 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -135,6 +135,7 @@ void BLF_dir_free(char **dirs, int count); #define BLF_FONT_KERNING (1<<2) #define BLF_USER_KERNING (1<<3) #define BLF_SHADOW (1<<4) +#define BLF_OVERLAP_CHAR (1<<5) /* font->mode. */ #define BLF_MODE_TEXTURE 0 diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index ee4ba0ee71a..a3c5232cc76 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -146,20 +146,22 @@ void blf_font_draw(FontBLF *font, char *str) if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { pen_x += delta.x >> 6; -/* - if (pen_x < old_pen_x) - pen_x= old_pen_x; -*/ + + 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 (pen_x < old_pen_x) - pen_x= old_pen_x; -*/ + + 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 */ @@ -228,20 +230,22 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { pen_x += delta.x >> 6; -/* - if (pen_x < old_pen_x) - old_pen_x= pen_x; -*/ + + 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 (pen_x < old_pen_x) - old_pen_x= pen_x; -*/ + + if (font->flags & BLF_OVERLAP_CHAR) { + if (pen_x < old_pen_x) + pen_x= old_pen_x; + } } gbox.xmin= g->box.xmin + pen_x; diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 5e0868ea680..a637774d7bf 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -500,6 +500,8 @@ int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) float color[4]; gt= g->tex_data; + xo= 0.0f; + yo= 0.0f; if (font->flags & BLF_SHADOW) { xo= x; diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 0d30d8e69c0..e8fba38f793 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -92,6 +92,7 @@ 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,6 +102,7 @@ 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; @@ -109,6 +111,7 @@ 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; @@ -171,10 +174,15 @@ 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 ************************ */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 6be855a27da..db13acf12d5 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -67,7 +67,8 @@ 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. */ - float pad; + 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 */ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f3811938e28..97337af5cb0 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -139,7 +139,12 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) 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", ""); + 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); |