Blender
V3.3
|
Go to the source code of this file.
Macros | |
#define | BLF_MAX_FONT 32 |
Functions | |
void | blf_batch_draw_begin (struct FontBLF *font) |
void | blf_batch_draw (void) |
unsigned int | blf_next_p2 (unsigned int x) |
unsigned int | blf_hash (unsigned int val) |
char * | blf_dir_search (const char *file) |
char * | blf_dir_metrics_search (const char *filepath) |
int | blf_font_init (void) |
void | blf_font_exit (void) |
bool | blf_font_id_is_valid (int fontid) |
void | blf_draw_buffer__start (struct FontBLF *font) |
void | blf_draw_buffer__end (void) |
struct FontBLF * | blf_font_new (const char *name, const char *filepath) |
struct FontBLF * | blf_font_new_from_mem (const char *name, const unsigned char *mem, int mem_size) |
void | blf_font_attach_from_mem (struct FontBLF *font, const unsigned char *mem, int mem_size) |
bool | blf_font_size (struct FontBLF *font, float size, unsigned int dpi) |
void | blf_font_draw (struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info) |
void | blf_font_draw__wrap (struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info) |
int | blf_font_draw_mono (struct FontBLF *font, const char *str, size_t str_len, int cwidth) |
void | blf_font_draw_buffer (struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info) |
void | blf_font_draw_buffer__wrap (struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info) |
size_t | blf_font_width_to_strlen (struct FontBLF *font, const char *str, size_t str_len, int width, int *r_width) |
size_t | blf_font_width_to_rstrlen (struct FontBLF *font, const char *str, size_t str_len, int width, int *r_width) |
void | blf_font_boundbox (struct FontBLF *font, const char *str, size_t str_len, struct rcti *r_box, struct ResultBLF *r_info) |
void | blf_font_boundbox__wrap (struct FontBLF *font, const char *str, size_t str_len, struct rcti *r_box, struct ResultBLF *r_info) |
void | blf_font_width_and_height (struct FontBLF *font, const char *str, size_t str_len, float *r_width, float *r_height, struct ResultBLF *r_info) |
float | blf_font_width (struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info) |
float | blf_font_height (struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info) |
float | blf_font_fixed_width (struct FontBLF *font) |
int | blf_font_height_max (struct FontBLF *font) |
int | blf_font_width_max (struct FontBLF *font) |
int | blf_font_descender (struct FontBLF *font) |
int | blf_font_ascender (struct FontBLF *font) |
char * | blf_display_name (struct FontBLF *font) |
void | blf_font_boundbox_foreach_glyph (struct FontBLF *font, const char *str, size_t str_len, bool(*user_fn)(const char *str, size_t str_step_ofs, const struct rcti *glyph_step_bounds, int glyph_advance_x, const struct rcti *glyph_bounds, const int glyph_bearing[2], void *user_data), void *user_data, struct ResultBLF *r_info) |
int | blf_font_count_missing_chars (struct FontBLF *font, const char *str, size_t str_len, int *r_tot_chars) |
void | blf_font_free (struct FontBLF *font) |
struct GlyphCacheBLF * | blf_glyph_cache_acquire (struct FontBLF *font) |
void | blf_glyph_cache_release (struct FontBLF *font) |
void | blf_glyph_cache_clear (struct FontBLF *font) |
struct GlyphBLF * | blf_glyph_ensure (struct FontBLF *font, struct GlyphCacheBLF *gc, uint charcode) |
void | blf_glyph_free (struct GlyphBLF *g) |
void | blf_glyph_draw (struct FontBLF *font, struct GlyphCacheBLF *gc, struct GlyphBLF *g, int x, int y) |
Variables | |
struct FontBLF * | global_font [BLF_MAX_FONT] |
#define BLF_MAX_FONT 32 |
Definition at line 19 of file blf_internal.h.
Definition at line 229 of file blf_font.c.
References BatchBLF::batch, blf_batch_cache_texture_load(), blf_draw_cache_flush, BatchBLF::col_loc, g_batch, BatchBLF::glyph_len, BatchBLF::glyph_size_loc, BatchBLF::glyph_size_step, GPU_batch_draw(), GPU_batch_program_set_builtin(), GPU_batch_texture_bind, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_SHADER_TEXT, GPU_texture_unbind(), GPU_vertbuf_attr_get_raw_data(), GPU_vertbuf_data_len_set(), GPU_vertbuf_use(), NULL, BatchBLF::offset_loc, BatchBLF::pos_loc, and BatchBLF::verts.
Referenced by blf_batch_draw_begin(), BLF_batch_draw_end(), blf_batch_draw_end(), BLF_batch_draw_flush(), blf_glyph_draw(), and blf_texture_draw().
Definition at line 129 of file blf_font.c.
References BatchBLF::active, BatchBLF::batch, BLF_ASPECT, blf_batch_draw(), blf_batch_draw_init(), BLF_MATRIX, BLF_ROTATION, BatchBLF::enabled, FontBLF::flags, BatchBLF::font, g_batch, GPU_matrix_model_view_get, GPU_matrix_pop(), GPU_matrix_push(), GPU_matrix_set, BatchBLF::mat, NULL, BatchBLF::ofs, FontBLF::pos, BatchBLF::simple_shader, and zero_v2_int().
Referenced by blf_font_draw_ex(), and blf_font_draw_mono().
char* blf_dir_metrics_search | ( | const char * | filepath | ) |
Some font have additional file with metrics information, in general, the extension of the file is: .afm
or .pfm
Definition at line 135 of file blf_dir.c.
References BLI_exists(), BLI_strdup(), BLI_strnlen(), MEM_freeN, and NULL.
Referenced by blf_font_new().
char* blf_dir_search | ( | const char * | file | ) |
Definition at line 109 of file blf_dir.c.
References BLI_assert_msg, BLI_exists(), BLI_join_dirfile(), BLI_path_is_rel(), BLI_strdup(), file, FILE_MAX, ListBase::first, global_font_dir, DirBLF::next, NULL, and DirBLF::path.
Referenced by BLF_load_unique().
char* blf_display_name | ( | struct FontBLF * | font | ) |
Definition at line 1158 of file blf_font.c.
References BLI_sprintfN(), FontBLF::face, and NULL.
Referenced by BLF_display_name_from_file().
Definition at line 859 of file blf.c.
Referenced by BLF_draw_buffer_ex(), and BLF_thumb_preview().
Definition at line 845 of file blf.c.
References FontBLF::buf_info, FontBufInfoBLF::col_char, FontBufInfoBLF::col_float, FontBufInfoBLF::col_init, copy_v4_v4(), FontBufInfoBLF::display, IMB_colormanagement_display_to_scene_linear_v3(), rgba_float_to_uchar(), and srgb_to_linearrgb_v4().
Referenced by BLF_draw_buffer_ex(), and BLF_thumb_preview().
int blf_font_ascender | ( | struct FontBLF * | font | ) |
Definition at line 1153 of file blf_font.c.
References FontBLF::face, and ft_pix_to_int().
Referenced by BLF_ascender(), and BLF_thumb_preview().
Definition at line 1329 of file blf_font.c.
References FontBLF::face.
Referenced by BLF_metrics_attach().
void blf_font_boundbox | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
struct rcti * | r_box, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 732 of file blf_font.c.
References blf_font_boundbox_ex(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), and str.
Referenced by BLF_boundbox_ex(), blf_font_height(), blf_font_width(), and blf_font_width_and_height().
void blf_font_boundbox__wrap | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
struct rcti * | r_box, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 1039 of file blf_font.c.
References blf_font_boundbox_wrap_cb(), blf_font_wrap_apply(), str, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by BLF_boundbox_ex(), blf_font_height(), blf_font_width(), and blf_font_width_and_height().
void blf_font_boundbox_foreach_glyph | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
bool(*)(const char *str, size_t str_step_ofs, const struct rcti *glyph_step_bounds, int glyph_advance_x, const struct rcti *glyph_bounds, const int glyph_bearing[2], void *user_data) | user_fn, | ||
void * | user_data, | ||
struct ResultBLF * | r_info | ||
) |
int blf_font_count_missing_chars | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
int * | r_tot_chars | ||
) |
Definition at line 1074 of file blf_font.c.
References BLI_str_utf8_as_unicode_step(), Freestyle::c, GLYPH_ASCII_TABLE_SIZE, and str.
Referenced by BLF_thumb_preview().
int blf_font_descender | ( | struct FontBLF * | font | ) |
Definition at line 1148 of file blf_font.c.
References FontBLF::face, and ft_pix_to_int().
Referenced by BLF_descender().
void blf_font_draw | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 371 of file blf_font.c.
References blf_font_draw_ex(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), and str.
Referenced by BLF_draw_ex().
void blf_font_draw__wrap | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 1017 of file blf_font.c.
References blf_font_draw__wrap_cb(), blf_font_wrap_apply(), NULL, and str.
Referenced by BLF_draw_ex().
void blf_font_draw_buffer | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 557 of file blf_font.c.
References blf_font_draw_buffer_ex(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), and str.
Referenced by BLF_draw_buffer_ex(), and BLF_thumb_preview().
void blf_font_draw_buffer__wrap | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 1060 of file blf_font.c.
References blf_font_draw_buffer__wrap_cb(), blf_font_wrap_apply(), NULL, and str.
Referenced by BLF_draw_buffer_ex().
int blf_font_draw_mono | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
int | cwidth | ||
) |
Use fixed column width, but an utf8 character may occupy multiple columns.
Definition at line 378 of file blf_font.c.
References blf_batch_draw_begin(), blf_batch_draw_end(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), blf_glyph_draw(), blf_glyph_from_utf8_and_step(), BLI_wcwidth(), col, ft_pix_from_int(), ft_pix_to_int_floor(), usdtokens::g(), NULL, str, and UNLIKELY.
Referenced by BLF_draw_mono().
Definition at line 1180 of file blf_font.c.
References blf_batch_draw_exit(), blf_glyph_cache_mutex, BLI_spin_end(), ft_lib, and ft_lib_mutex.
Referenced by BLF_exit().
Definition at line 817 of file blf_font.c.
References blf_glyph_cache_acquire(), blf_glyph_cache_release(), GlyphCacheBLF::fixed_width, FontBLF::size, and width.
Referenced by BLF_fixed_width().
Definition at line 1380 of file blf_font.c.
References blf_glyph_cache_clear(), FontBLF::face, FontBLF::filepath, ft_lib, FontBLF::kerning_cache, MEM_freeN, FontBLF::name, and FontBLF::variations.
Referenced by BLF_display_name_from_file(), BLF_exit(), BLF_thumb_preview(), BLF_unload(), BLF_unload_all(), and BLF_unload_id().
float blf_font_height | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 793 of file blf_font.c.
References FontBLF::aspect, BLF_ASPECT, blf_font_boundbox(), blf_font_boundbox__wrap(), BLF_WORD_WRAP, BLI_rcti_size_y(), FontBLF::flags, and str.
Referenced by BLF_height_ex().
int blf_font_height_max | ( | struct FontBLF * | font | ) |
Definition at line 1122 of file blf_font.c.
References blf_font_height_max_ft_pix(), and ft_pix_to_int().
Referenced by BLF_height_max().
bool blf_font_id_is_valid | ( | int | fontid | ) |
Definition at line 93 of file blf.c.
References blf_get(), and NULL.
Referenced by BLF_default_set().
int blf_font_init | ( | void | ) |
Definition at line 1172 of file blf_font.c.
References blf_glyph_cache_mutex, BLI_spin_init(), ft_lib, ft_lib_mutex, and g_batch.
Referenced by BLF_init().
struct FontBLF* blf_font_new | ( | const char * | name, |
const char * | filepath | ||
) |
Definition at line 1247 of file blf_font.c.
References KerningCacheBLF::ascii_table, blf_dir_metrics_search(), blf_font_fill(), BLF_LAST_RESORT, BLF_MONOSPACED, BLI_strdup(), ELEM, err, FontBLF::face, FontBLF::filepath, FontBLF::flags, ft_lib, FontBLF::kerning_cache, KERNING_CACHE_TABLE_SIZE, KERNING_ENTRY_UNSET, MEM_callocN, MEM_freeN, MEM_mallocN, FontBLF::name, NULL, FontBLF::UnicodeRanges, and FontBLF::variations.
Referenced by BLF_display_name_from_file(), BLF_load_unique(), and BLF_thumb_preview().
struct FontBLF* blf_font_new_from_mem | ( | const char * | name, |
const unsigned char * | mem, | ||
int | mem_size | ||
) |
Definition at line 1339 of file blf_font.c.
References KerningCacheBLF::ascii_table, blf_font_fill(), BLI_strdup(), err, FontBLF::face, FontBLF::filepath, ft_lib, FontBLF::kerning_cache, KERNING_CACHE_TABLE_SIZE, KERNING_ENTRY_UNSET, MEM_callocN, MEM_freeN, MEM_mallocN, FontBLF::name, NULL, and FontBLF::variations.
Referenced by BLF_load_mem_unique().
Change font's output size. Returns true if successful in changing the size.
Definition at line 1408 of file blf_font.c.
References FontBLF::dpi, FontBLF::face, float(), size(), and FontBLF::size.
Referenced by BLF_size(), and BLF_thumb_preview().
float blf_font_width | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 769 of file blf_font.c.
References FontBLF::aspect, BLF_ASPECT, blf_font_boundbox(), blf_font_boundbox__wrap(), BLF_WORD_WRAP, BLI_rcti_size_x(), FontBLF::flags, and str.
Referenced by BLF_width_ex().
void blf_font_width_and_height | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
float * | r_width, | ||
float * | r_height, | ||
struct ResultBLF * | r_info | ||
) |
Definition at line 740 of file blf_font.c.
References FontBLF::aspect, BLF_ASPECT, blf_font_boundbox(), blf_font_boundbox__wrap(), BLF_WORD_WRAP, BLI_rcti_size_x(), BLI_rcti_size_y(), FontBLF::flags, float(), and str.
Referenced by BLF_width_and_height().
int blf_font_width_max | ( | struct FontBLF * | font | ) |
Definition at line 1143 of file blf_font.c.
References blf_font_width_max_ft_pix(), and ft_pix_to_int().
Referenced by BLF_width_max().
size_t blf_font_width_to_rstrlen | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
int | width, | ||
int * | r_width | ||
) |
Definition at line 618 of file blf_font.c.
References blf_font_width_to_strlen_glyph_process(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), blf_glyph_from_utf8_and_step(), BLI_assert, BLI_str_find_prev_char_utf8(), BLI_strnlen(), ft_pix_to_int(), usdtokens::g(), NULL, str, and width.
Referenced by BLF_width_to_rstrlen().
size_t blf_font_width_to_strlen | ( | struct FontBLF * | font, |
const char * | str, | ||
size_t | str_len, | ||
int | width, | ||
int * | r_width | ||
) |
Definition at line 590 of file blf_font.c.
References blf_font_width_to_strlen_glyph_process(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), blf_glyph_from_utf8_and_step(), ft_pix_to_int(), usdtokens::g(), NULL, str, and width.
Referenced by BLF_width_to_strlen().
struct GlyphCacheBLF* blf_glyph_cache_acquire | ( | struct FontBLF * | font | ) |
Definition at line 116 of file blf_glyph.c.
References blf_glyph_cache_find(), blf_glyph_cache_new(), BLI_spin_lock(), FontBLF::dpi, FontBLF::glyph_cache_mutex, and FontBLF::size.
Referenced by blf_font_boundbox(), blf_font_boundbox_foreach_glyph(), blf_font_draw(), blf_font_draw_buffer(), blf_font_draw_mono(), blf_font_fixed_width(), blf_font_width_to_rstrlen(), blf_font_width_to_strlen(), and blf_font_wrap_apply().
Definition at line 151 of file blf_glyph.c.
References blf_glyph_cache_free(), BLI_pophead(), BLI_spin_lock(), BLI_spin_unlock(), FontBLF::cache, and FontBLF::glyph_cache_mutex.
Referenced by BLF_cache_clear(), and blf_font_free().
Definition at line 129 of file blf_glyph.c.
References BLI_spin_unlock(), and FontBLF::glyph_cache_mutex.
Referenced by blf_font_boundbox(), blf_font_boundbox_foreach_glyph(), blf_font_draw(), blf_font_draw_buffer(), blf_font_draw_mono(), blf_font_fixed_width(), blf_font_width_to_rstrlen(), blf_font_width_to_strlen(), and blf_font_wrap_apply().
void blf_glyph_draw | ( | struct FontBLF * | font, |
struct GlyphCacheBLF * | gc, | ||
struct GlyphBLF * | g, | ||
int | x, | ||
int | y | ||
) |
Definition at line 1108 of file blf_glyph.c.
References GlyphCacheBLF::bitmap_len, GlyphCacheBLF::bitmap_len_alloc, GlyphCacheBLF::bitmap_len_landed, GlyphCacheBLF::bitmap_result, blf_batch_draw(), BLF_CLIPPING, blf_glyph_calc_rect(), blf_glyph_calc_rect_shadow(), blf_glyph_calc_rect_test(), BLF_SHADOW, blf_texture3_draw(), blf_texture5_draw(), blf_texture_draw(), BLI_rcti_inside_rcti(), BLI_rcti_translate(), FontBLF::clip_rec, FontBLF::color, FontBLF::flags, usdtokens::g(), g_batch, BatchBLF::glyph_cache, GPU_max_texture_size(), GPU_R8, GPU_texture_create_2d(), GPU_texture_free(), MEM_reallocN, NULL, FontBLF::pos, FontBLF::shadow, FontBLF::shadow_color, FontBLF::tex_size_max, GlyphCacheBLF::texture, w(), x, rcti::xmax, rcti::xmin, y, rcti::ymax, and rcti::ymin.
Referenced by blf_font_draw_ex(), and blf_font_draw_mono().
struct GlyphBLF* blf_glyph_ensure | ( | struct FontBLF * | font, |
struct GlyphCacheBLF * | gc, | ||
uint | charcode | ||
) |
Create (or load from cache) a fully-rendered bitmap glyph.
Definition at line 976 of file blf_glyph.c.
References blf_glyph_cache_add_glyph(), blf_glyph_cache_find_glyph(), blf_glyph_index_from_charcode(), blf_glyph_render(), BLI_spin_lock(), BLI_spin_unlock(), GlyphCacheBLF::fixed_width, FontBLF::ft_lib_mutex, usdtokens::g(), and glyph.
Referenced by blf_glyph_from_utf8_and_step().
Definition at line 1005 of file blf_glyph.c.
References usdtokens::g(), and MEM_freeN.
Referenced by blf_glyph_cache_free().
unsigned int blf_hash | ( | unsigned int | val | ) |
Definition at line 30 of file blf_util.c.
Referenced by blf_glyph_cache_add_glyph(), and blf_glyph_cache_find_glyph().
unsigned int blf_next_p2 | ( | unsigned int | x | ) |
Definition at line 18 of file blf_util.c.
References x.
|
extern |
Definition at line 44 of file blf.c.
Referenced by BLF_cache_clear(), BLF_exit(), blf_get(), blf_glyph_index_from_charcode(), BLF_init(), BLF_load(), BLF_load_mem_unique(), BLF_load_unique(), blf_search(), blf_search_available(), BLF_unload(), BLF_unload_all(), and BLF_unload_id().