diff options
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 1 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 20 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 9 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 11 |
5 files changed, 37 insertions, 6 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 53f108f87eb..99934a80143 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -137,6 +137,7 @@ void BLF_dir_free(char **dirs, int count); #define BLF_ROTATION (1<<0) #define BLF_CLIPPING (1<<1) #define BLF_SHADOW (1<<2) +#define BLF_KERNING_DEFAULT (1<<3) /* 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 989746ca501..affc35ea11e 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -102,7 +102,7 @@ void blf_font_draw(FontBLF *font, char *str) FT_Vector delta; FT_UInt glyph_index, g_prev_index; int pen_x, pen_y; - int i, has_kerning; + int i, has_kerning, st; if (!font->glyph_cache) return; @@ -143,9 +143,13 @@ void blf_font_draw(FontBLF *font, char *str) delta.x= 0; delta.y= 0; - if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { + if (font->flags & BLF_KERNING_DEFAULT) + st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta); + else + st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); + + if (st == 0) pen_x += delta.x >> 6; - } } /* do not return this loop if clipped, we want every character tested */ @@ -165,7 +169,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) FT_UInt glyph_index, g_prev_index; rctf gbox; int pen_x, pen_y; - int i, has_kerning; + int i, has_kerning, st; if (!font->glyph_cache) return; @@ -211,9 +215,13 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) delta.x= 0; delta.y= 0; - if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { + if (font->flags & BLF_KERNING_DEFAULT) + st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta); + else + st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); + + if (st == 0) pen_x += delta.x >> 6; - } } gbox.xmin= g->box.xmin + pen_x; diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 83eb8a32701..57f35f71927 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -93,6 +93,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; 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; style->grouplabel.shadow= 3; style->grouplabel.shadx= 1; style->grouplabel.shady= -1; @@ -108,6 +110,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; style->widgetlabel.shadow= 3; style->widgetlabel.shadx= 1; style->widgetlabel.shady= -1; @@ -116,6 +119,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->widget.uifont_id= UIFONT_DEFAULT; style->widget.points= 11; + style->widget.kerning= 0; style->widget.shadowalpha= 0.25f; style->columnspace= 5; @@ -169,10 +173,15 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str) BLF_shadow_offset(fs->shadx, fs->shady); } + if (fs->kerning == 1) + BLF_enable(BLF_KERNING_DEFAULT); + BLF_draw(str); BLF_disable(BLF_CLIPPING); if (fs->shadow) BLF_disable(BLF_SHADOW); + if (fs->kerning == 1) + BLF_disable(BLF_KERNING_DEFAULT); } /* ************** helpers ************************ */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index fcb10a33fda..0709d2d58b0 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -66,6 +66,8 @@ typedef struct uiFont { typedef struct uiFontStyle { short uifont_id; /* saved in file, 0 is default */ short points; /* actual size depends on 'global' dpi */ + short kerning; /* unfitted or default kerning value. */ + char pad[6]; 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 03bd0c9cfe2..977c43e6b95 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -128,6 +128,11 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem font_kerning_style[] = { + {0, "UNFITTED", 0, "Unfitted", "Use scaled but un-grid-fitted kerning distances."}, + {1, "DEFAULT", 0, "Default", "Use scaled and grid-fitted kerning distances."}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "ThemeFontStyle", NULL); RNA_def_struct_sdna(srna, "uiFontStyle"); RNA_def_struct_ui_text(srna, "Font Style", "Theme settings for Font."); @@ -137,6 +142,12 @@ 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, "font_kerning_style", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "kerning"); + RNA_def_property_enum_items(prop, font_kerning_style); + RNA_def_property_ui_text(prop, "Kerning Style", "Which style to use for font kerning."); + 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)"); |