Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-06-13 20:23:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-06-13 20:32:38 +0400
commitb96172cb054ce22407f8cfeb16592ecc8e216d6e (patch)
tree35f498c03c0b2f1ee6f680bf2a10ffc2108a4683 /source
parent5861e528d64906325632a490b1682f696abd3ebc (diff)
UI: Add back ability to select a custom interface font
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenfont/BLF_api.h2
-rw-r--r--source/blender/blenfont/intern/blf.c17
-rw-r--r--source/blender/blenkernel/intern/blender.c7
-rw-r--r--source/blender/editors/interface/interface_style.c20
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c7
6 files changed, 52 insertions, 3 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index fd80e1293ee..206345582b2 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -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);
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 235d8ecbf46..cdccbe044bb 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -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);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 8b87f5b0cea..38a180f85bc 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -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);
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index fa31c20eb74..e04f13bd458 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -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) {
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 4f5670d16c1..987985f0ba7 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -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;
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 7c101fb19be..7fa7571c32d 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -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);