Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenfont/intern/blf.c
| Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
| #include "IMB_colormanagement.h" | #include "IMB_colormanagement.h" | ||||
| #ifndef BLF_STANDALONE | #ifndef BLF_STANDALONE | ||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #endif | #endif | ||||
| #include "CLG_log.h" | |||||
| #include "blf_internal_types.h" | #include "blf_internal_types.h" | ||||
| #include "blf_internal.h" | #include "blf_internal.h" | ||||
| /* Max number of font in memory. | /* Max number of font in memory. | ||||
| * Take care that now every font have a glyph cache per size/dpi, | * Take care that now every font have a glyph cache per size/dpi, | ||||
| * so we don't need load the same font with different size, just | * so we don't need load the same font with different size, just | ||||
| * load one and call BLF_size. | * load one and call BLF_size. | ||||
| */ | */ | ||||
| #define BLF_MAX_FONT 16 | #define BLF_MAX_FONT 16 | ||||
| /* call BLF_default_set first! */ | /* call BLF_default_set first! */ | ||||
| #define ASSERT_DEFAULT_SET BLI_assert(global_font_default != -1) | #define ASSERT_DEFAULT_SET BLI_assert(global_font_default != -1) | ||||
| #define BLF_RESULT_CHECK_INIT(r_info) \ | #define BLF_RESULT_CHECK_INIT(r_info) \ | ||||
| if (r_info) { \ | if (r_info) { \ | ||||
| memset(r_info, 0, sizeof(*(r_info))); \ | memset(r_info, 0, sizeof(*(r_info))); \ | ||||
| } ((void)0) | } ((void)0) | ||||
| static CLG_LogRef LOG = {"blf.main"}; | |||||
| /* Font array. */ | /* Font array. */ | ||||
| static FontBLF *global_font[BLF_MAX_FONT] = {NULL}; | static FontBLF *global_font[BLF_MAX_FONT] = {NULL}; | ||||
| /* Default size and dpi, for BLF_draw_default. */ | /* Default size and dpi, for BLF_draw_default. */ | ||||
| static int global_font_default = -1; | static int global_font_default = -1; | ||||
| static int global_font_points = 11; | static int global_font_points = 11; | ||||
| static int global_font_dpi = 72; | static int global_font_dpi = 72; | ||||
| ▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | int BLF_load_unique(const char *name) | ||||
| char *filename; | char *filename; | ||||
| int i; | int i; | ||||
| /* Don't search in the cache!! make a new | /* Don't search in the cache!! make a new | ||||
| * object font, this is for keep fonts threads safe. | * object font, this is for keep fonts threads safe. | ||||
| */ | */ | ||||
| i = blf_search_available(); | i = blf_search_available(); | ||||
| if (i == -1) { | if (i == -1) { | ||||
| printf("Too many fonts!!!\n"); | CLOG_ERROR(&LOG, "Too many fonts!"); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| filename = blf_dir_search(name); | filename = blf_dir_search(name); | ||||
| if (!filename) { | if (!filename) { | ||||
| printf("Can't find font: %s\n", name); | CLOG_ERROR(&LOG, "Can't find font: %s", name); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| font = blf_font_new(name, filename); | font = blf_font_new(name, filename); | ||||
| MEM_freeN(filename); | MEM_freeN(filename); | ||||
| if (!font) { | if (!font) { | ||||
| printf("Can't load font: %s\n", name); | CLOG_ERROR(&LOG, "Can't load font: %s", name); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| font->reference_count = 1; | font->reference_count = 1; | ||||
| global_font[i] = font; | global_font[i] = font; | ||||
| return i; | return i; | ||||
| } | } | ||||
| Show All 24 Lines | int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) | ||||
| int i; | int i; | ||||
| /* | /* | ||||
| * Don't search in the cache, make a new object font! | * Don't search in the cache, make a new object font! | ||||
| * this is to keep the font thread safe. | * this is to keep the font thread safe. | ||||
| */ | */ | ||||
| i = blf_search_available(); | i = blf_search_available(); | ||||
| if (i == -1) { | if (i == -1) { | ||||
| printf("Too many fonts!!!\n"); | CLOG_ERROR(&LOG, "Too many fonts!"); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| if (!mem_size) { | if (!mem_size) { | ||||
| printf("Can't load font: %s from memory!!\n", name); | CLOG_ERROR(&LOG, "Can't load font: %s from memory!", name); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| font = blf_font_new_from_mem(name, mem, mem_size); | font = blf_font_new_from_mem(name, mem, mem_size); | ||||
| if (!font) { | if (!font) { | ||||
| printf("Can't load font: %s from memory!!\n", name); | CLOG_ERROR(&LOG, "Can't load font: %s from memory!", name); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| font->reference_count = 1; | font->reference_count = 1; | ||||
| global_font[i] = font; | global_font[i] = font; | ||||
| return i; | return i; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 670 Lines • Show Last 20 Lines | |||||