#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
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;
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 */
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;
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;
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;
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;
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;
style->widget.uifont_id= UIFONT_DEFAULT;
style->widget.points= 11;
+ style->widget.kerning= 0;
style->widget.shadowalpha= 0.25f;
style->columnspace= 5;
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 ************************ */
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 */
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.");
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)");