forked from bartvdbraak/blender
UI: Add back ability to select a custom interface font
This commit is contained in:
parent
5861e528d6
commit
b96172cb05
@ -487,8 +487,10 @@ class USERPREF_PT_system(Panel):
|
||||
sub.active = system.use_weight_color_range
|
||||
sub.template_color_ramp(system, "weight_color_range", expand=True)
|
||||
|
||||
column.separator()
|
||||
column.prop(system, "font_path_ui")
|
||||
|
||||
if bpy.app.build_options.international:
|
||||
column.separator()
|
||||
column.prop(system, "use_international_fonts")
|
||||
if system.use_international_fonts:
|
||||
column.prop(system, "language")
|
||||
|
@ -40,6 +40,7 @@ struct ColorManagedDisplay;
|
||||
int BLF_init(int points, int dpi);
|
||||
void BLF_exit(void);
|
||||
void BLF_default_dpi(int dpi);
|
||||
void BLF_default_set(int fontid);
|
||||
|
||||
void BLF_cache_clear(void);
|
||||
|
||||
@ -50,6 +51,7 @@ int BLF_load_unique(const char *name) ATTR_NONNULL();
|
||||
int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL();
|
||||
|
||||
void BLF_unload(const char *name) ATTR_NONNULL();
|
||||
void BLF_unload_id(int fontid);
|
||||
|
||||
/* Attach a file with metrics information from memory. */
|
||||
void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size);
|
||||
|
@ -152,6 +152,14 @@ static int blf_search_available(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void BLF_default_set(int fontid)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
if (font || fontid == -1) {
|
||||
global_font_default = fontid;
|
||||
}
|
||||
}
|
||||
|
||||
static int blf_global_font_init(void)
|
||||
{
|
||||
if (global_font_default == -1) {
|
||||
@ -335,6 +343,15 @@ void BLF_unload(const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
void BLF_unload_id(int fontid)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
if (font) {
|
||||
blf_font_free(font);
|
||||
global_font[fontid] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void BLF_enable(int fontid, int option)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
@ -384,6 +384,7 @@ void BKE_userdef_free(void)
|
||||
wmKeyMapItem *kmi;
|
||||
wmKeyMapDiffItem *kmdi;
|
||||
bAddon *addon, *addon_next;
|
||||
uiFont *font;
|
||||
|
||||
for (km = U.user_keymaps.first; km; km = km->next) {
|
||||
for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
|
||||
@ -413,6 +414,12 @@ void BKE_userdef_free(void)
|
||||
MEM_freeN(addon);
|
||||
}
|
||||
|
||||
for (font = U.uifonts.first; font; font = font->next) {
|
||||
BLF_unload_id(font->blf_id);
|
||||
}
|
||||
|
||||
BLF_default_set(-1);
|
||||
|
||||
BLI_freelistN(&U.autoexec_paths);
|
||||
|
||||
BLI_freelistN(&U.uistyles);
|
||||
|
@ -340,11 +340,23 @@ void uiStyleInit(void)
|
||||
U.dpi = 72;
|
||||
CLAMP(U.dpi, 48, 144);
|
||||
|
||||
for (font = U.uifonts.first; font; font = font->next) {
|
||||
BLF_unload_id(font->blf_id);
|
||||
}
|
||||
|
||||
font = U.uifonts.first;
|
||||
|
||||
/* default builtin */
|
||||
if (font == NULL) {
|
||||
font = MEM_callocN(sizeof(uiFont), "ui font");
|
||||
BLI_addtail(&U.uifonts, font);
|
||||
|
||||
}
|
||||
|
||||
if (U.font_path_ui[0]) {
|
||||
BLI_strncpy(font->filename, U.font_path_ui, sizeof(font->filename));
|
||||
font->uifont_id = UIFONT_CUSTOM1;
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(font->filename, "default", sizeof(font->filename));
|
||||
font->uifont_id = UIFONT_DEFAULT;
|
||||
}
|
||||
@ -381,8 +393,12 @@ void uiStyleInit(void)
|
||||
}
|
||||
else {
|
||||
font->blf_id = BLF_load(font->filename);
|
||||
if (font->blf_id == -1)
|
||||
if (font->blf_id == -1) {
|
||||
font->blf_id = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
|
||||
}
|
||||
else {
|
||||
BLF_default_set(font->blf_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (font->blf_id == -1) {
|
||||
|
@ -521,6 +521,8 @@ typedef struct UserDef {
|
||||
|
||||
char author[80]; /* author name for file formats supporting it */
|
||||
|
||||
char font_path_ui[1024];
|
||||
|
||||
int compute_device_type;
|
||||
int compute_device_id;
|
||||
|
||||
|
@ -3707,7 +3707,12 @@ static void rna_def_userdef_system(BlenderRNA *brna)
|
||||
RNA_def_property_range(prop, 48, 144);
|
||||
RNA_def_property_ui_text(prop, "DPI", "Font size and resolution for display");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
|
||||
|
||||
|
||||
prop = RNA_def_property(srna, "font_path_ui", PROP_STRING, PROP_FILEPATH);
|
||||
RNA_def_property_string_sdna(prop, NULL, "font_path_ui");
|
||||
RNA_def_property_ui_text(prop, "Interface Font", "Path to interface font");
|
||||
RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_language_update");
|
||||
|
||||
prop = RNA_def_property(srna, "scrollback", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, NULL, "scrollback");
|
||||
RNA_def_property_range(prop, 32, 32768);
|
||||
|
Loading…
Reference in New Issue
Block a user