Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_style.c
| Show First 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ************** init exit ************************ */ | /* ************** init exit ************************ */ | ||||
| /* called on each startup.blend read */ | /* called on each startup.blend read */ | ||||
| /* reading without uifont will create one */ | /* reading without uifont will create one */ | ||||
| void uiStyleInit(void) | void uiStyleInit(void) | ||||
| { | { | ||||
| uiFont *font; | |||||
| uiStyle *style = U.uistyles.first; | uiStyle *style = U.uistyles.first; | ||||
| /* recover from uninitialized dpi */ | /* recover from uninitialized dpi */ | ||||
| if (U.dpi == 0) { | if (U.dpi == 0) { | ||||
| U.dpi = 72; | U.dpi = 72; | ||||
| } | } | ||||
| CLAMP(U.dpi, 48, 144); | CLAMP(U.dpi, 48, 144); | ||||
| for (font = U.uifonts.first; font; font = font->next) { | LISTBASE_FOREACH (uiFont *, font, &U.uifonts) { | ||||
| BLF_unload_id(font->blf_id); | BLF_unload_id(font->blf_id); | ||||
| } | } | ||||
| if (blf_mono_font != -1) { | if (blf_mono_font != -1) { | ||||
| BLF_unload_id(blf_mono_font); | BLF_unload_id(blf_mono_font); | ||||
| blf_mono_font = -1; | blf_mono_font = -1; | ||||
| } | } | ||||
| if (blf_mono_font_render != -1) { | if (blf_mono_font_render != -1) { | ||||
| BLF_unload_id(blf_mono_font_render); | BLF_unload_id(blf_mono_font_render); | ||||
| blf_mono_font_render = -1; | blf_mono_font_render = -1; | ||||
| } | } | ||||
| font = U.uifonts.first; | uiFont *font_first = U.uifonts.first; | ||||
| /* default builtin */ | /* default builtin */ | ||||
| if (font == NULL) { | if (font_first == NULL) { | ||||
| font = MEM_callocN(sizeof(uiFont), "ui font"); | font_first = MEM_callocN(sizeof(uiFont), "ui font"); | ||||
| BLI_addtail(&U.uifonts, font); | BLI_addtail(&U.uifonts, font_first); | ||||
| } | } | ||||
| if (U.font_path_ui[0]) { | if (U.font_path_ui[0]) { | ||||
| BLI_strncpy(font->filename, U.font_path_ui, sizeof(font->filename)); | BLI_strncpy(font_first->filename, U.font_path_ui, sizeof(font_first->filename)); | ||||
| font->uifont_id = UIFONT_CUSTOM1; | font_first->uifont_id = UIFONT_CUSTOM1; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_strncpy(font->filename, "default", sizeof(font->filename)); | BLI_strncpy(font_first->filename, "default", sizeof(font_first->filename)); | ||||
| font->uifont_id = UIFONT_DEFAULT; | font_first->uifont_id = UIFONT_DEFAULT; | ||||
| } | } | ||||
| for (font = U.uifonts.first; font; font = font->next) { | LISTBASE_FOREACH (uiFont *, font, &U.uifonts) { | ||||
| const bool unique = false; | const bool unique = false; | ||||
| if (font->uifont_id == UIFONT_DEFAULT) { | if (font->uifont_id == UIFONT_DEFAULT) { | ||||
| font->blf_id = BLF_load_default(unique); | font->blf_id = BLF_load_default(unique); | ||||
| } | } | ||||
| else { | else { | ||||
| font->blf_id = BLF_load(font->filename); | font->blf_id = BLF_load(font->filename); | ||||
| if (font->blf_id == -1) { | if (font->blf_id == -1) { | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | /* Set default flags based on UI preferences (not render fonts) */ | ||||
| else if (U.text_render & USER_TEXT_HINTING_FULL) { | else if (U.text_render & USER_TEXT_HINTING_FULL) { | ||||
| flag_enable |= BLF_HINTING_FULL; | flag_enable |= BLF_HINTING_FULL; | ||||
| } | } | ||||
| if (U.text_render & USER_TEXT_DISABLE_AA) { | if (U.text_render & USER_TEXT_DISABLE_AA) { | ||||
| flag_enable |= BLF_MONOCHROME; | flag_enable |= BLF_MONOCHROME; | ||||
| } | } | ||||
| for (font = U.uifonts.first; font; font = font->next) { | LISTBASE_FOREACH (uiFont *, font, &U.uifonts) { | ||||
| if (font->blf_id != -1) { | if (font->blf_id != -1) { | ||||
| BLF_disable(font->blf_id, flag_disable); | BLF_disable(font->blf_id, flag_disable); | ||||
| BLF_enable(font->blf_id, flag_enable); | BLF_enable(font->blf_id, flag_enable); | ||||
| } | } | ||||
| } | } | ||||
| if (blf_mono_font != -1) { | if (blf_mono_font != -1) { | ||||
| BLF_disable(blf_mono_font, flag_disable); | BLF_disable(blf_mono_font, flag_disable); | ||||
| BLF_enable(blf_mono_font, flag_enable); | BLF_enable(blf_mono_font, flag_enable); | ||||
| Show All 23 Lines | |||||