|
Blender V4.3
|
#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <ft2build.h>#include "MEM_guardedalloc.h"#include "DNA_vec_types.h"#include "BLI_listbase.h"#include "BLI_math_bits.h"#include "BLI_math_color_blend.h"#include "BLI_math_matrix.h"#include "BLI_path_utils.hh"#include "BLI_rect.h"#include "BLI_string.h"#include "BLI_string_cursor_utf8.h"#include "BLI_string_utf8.h"#include "BLI_threads.h"#include "BLI_vector.hh"#include "BLF_api.hh"#include "GPU_batch.hh"#include "GPU_matrix.hh"#include "blf_internal.hh"#include "blf_internal_types.hh"#include "BLI_strict_flags.h"Go to the source code of this file.
Classes | |
| struct | CursorPositionForeachGlyph_Data |
| struct | StrOffsetToGlyphBounds_Data |
| struct | FaceDetails |
Functions | |
Font Query: Attributes | |
| static ft_pix | blf_font_height_max_ft_pix (FontBLF *font) |
| static ft_pix | blf_font_width_max_ft_pix (FontBLF *font) |
| int | blf_font_height_max (FontBLF *font) |
| int | blf_font_width_max (FontBLF *font) |
| int | blf_font_descender (FontBLF *font) |
| int | blf_font_ascender (FontBLF *font) |
| char * | blf_display_name (FontBLF *font) |
FreeType Caching | |
| static bool | blf_setup_face (FontBLF *font) |
| static void | blf_face_finalizer (void *object) |
| static FT_Error | blf_cache_face_requester (FTC_FaceID faceID, FT_Library lib, FT_Pointer, FT_Face *face) |
| static void | blf_size_finalizer (void *object) |
FreeType Utilities (Internal) | |
| uint | blf_get_char_index (FontBLF *font, uint charcode) |
| static ft_pix | blf_unscaled_F26Dot6_to_pixels (FontBLF *font, FT_Pos value) |
Glyph Batching | |
| static void | blf_batch_draw_init () |
| static void | blf_batch_draw_exit () |
| void | blf_batch_draw_begin (FontBLF *font) |
| static GPUTexture * | blf_batch_cache_texture_load () |
| void | blf_batch_draw () |
| static void | blf_batch_draw_end () |
Glyph Stepping Utilities (Internal) | |
| BLI_INLINE ft_pix | blf_kerning (FontBLF *font, const GlyphBLF *g_prev, const GlyphBLF *g) |
| BLI_INLINE GlyphBLF * | blf_glyph_from_utf8_and_step (FontBLF *font, GlyphCacheBLF *gc, const GlyphBLF *g_prev, const char *str, size_t str_len, size_t *i_p, int32_t *pen_x) |
Text Drawing: GPU | |
| static void | blf_font_draw_ex (FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, ResultBLF *r_info, const ft_pix pen_y) |
| void | blf_font_draw (FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) |
| int | blf_font_draw_mono (FontBLF *font, const char *str, const size_t str_len, int cwidth, int tab_columns) |
| void | blf_draw_svg_icon (FontBLF *font, uint icon_id, float x, float y, float size, const float color[4], float outline_alpha, bool multicolor, blender::FunctionRef< void(std::string &)> edit_source_cb) |
| blender::Array< uchar > | blf_svg_icon_bitmap (FontBLF *font, uint icon_id, float size, int *r_width, int *r_height, bool multicolor, blender::FunctionRef< void(std::string &)> edit_source_cb) |
Text Drawing: Buffer | |
| static void | blf_glyph_draw_buffer (FontBufInfoBLF *buf_info, GlyphBLF *g, const ft_pix pen_x, const ft_pix pen_y_basis) |
| static void | blf_font_draw_buffer_ex (FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, ResultBLF *r_info, ft_pix pen_y) |
| void | blf_font_draw_buffer (FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) |
Text Evaluation: Width to String Length | |
Use to implement exported functions: | |
| static bool | blf_font_width_to_strlen_glyph_process (FontBLF *font, GlyphCacheBLF *gc, const GlyphBLF *g_prev, GlyphBLF *g, ft_pix *pen_x, const int width_i) |
| size_t | blf_font_width_to_strlen (FontBLF *font, const char *str, const size_t str_len, int width, int *r_width) |
| size_t | blf_font_width_to_rstrlen (FontBLF *font, const char *str, const size_t str_len, int width, int *r_width) |
Text Evaluation: Glyph Bound Box with Callback | |
| static void | blf_font_boundbox_ex (FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info, ft_pix pen_y) |
| void | blf_font_boundbox (FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info) |
| void | blf_font_width_and_height (FontBLF *font, const char *str, const size_t str_len, float *r_width, float *r_height, ResultBLF *r_info) |
| float | blf_font_width (FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) |
| float | blf_font_height (FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) |
| float | blf_font_fixed_width (FontBLF *font) |
| void | blf_font_boundbox_foreach_glyph (FontBLF *font, const char *str, const size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data) |
| static bool | blf_cursor_position_foreach_glyph (const char *, const size_t str_step_ofs, const rcti *bounds, void *user_data) |
| size_t | blf_str_offset_from_cursor_position (FontBLF *font, const char *str, size_t str_len, int location_x) |
| static bool | blf_str_offset_foreach_glyph (const char *, const size_t str_step_ofs, const rcti *bounds, void *user_data) |
| void | blf_str_offset_to_glyph_bounds (FontBLF *font, const char *str, size_t str_offset, rcti *r_glyph_bounds) |
| int | blf_str_offset_to_cursor (FontBLF *font, const char *str, const size_t str_len, const size_t str_offset, const int cursor_width) |
| blender::Vector< blender::Bounds< int > > | blf_str_selection_boxes (FontBLF *font, const char *str, size_t str_len, size_t sel_start, size_t sel_length) |
Text Evaluation: Word-Wrap with Callback | |
| static void | blf_font_wrap_apply (FontBLF *font, const char *str, const size_t str_len, const int max_pixel_width, ResultBLF *r_info, void(*callback)(FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, ft_pix pen_y, void *userdata), void *userdata) |
| static void | blf_font_draw__wrap_cb (FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, ft_pix pen_y, void *) |
| void | blf_font_draw__wrap (FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) |
| static void | blf_font_boundbox_wrap_cb (FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, ft_pix pen_y, void *userdata) |
| void | blf_font_boundbox__wrap (FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info) |
| static void | blf_font_draw_buffer__wrap_cb (FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, ft_pix pen_y, void *) |
| void | blf_font_draw_buffer__wrap (FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) |
| static void | blf_font_string_wrap_cb (FontBLF *, GlyphCacheBLF *, const char *str, const size_t str_len, ft_pix, void *str_list_ptr) |
| blender::Vector< blender::StringRef > | blf_font_string_wrap (FontBLF *font, blender::StringRef str, int max_pixel_width) |
Font Subsystem Init/Exit | |
| int | blf_font_init () |
| void | blf_font_exit () |
| void | BLF_cache_flush_set_fn (void(*cache_flush_fn)()) |
Font Configure | |
| void | blf_ensure_size (FontBLF *font) |
| bool | blf_font_size (FontBLF *font, float size) |
Variables | |
| BatchBLF | g_batch |
| static FT_Library | ft_lib = nullptr |
| static FTC_Manager | ftc_manager = nullptr |
| static FTC_CMapCache | ftc_charmap_cache = nullptr |
| static ThreadMutex | ft_lib_mutex |
| static void(* | blf_draw_cache_flush )() = nullptr |
Font New/Free | |
| static const FaceDetails | static_face_details [] |
| static void | blf_font_fill (FontBLF *font) |
| static void | blf_font_metrics (FT_Face face, FontMetrics *metrics) |
| bool | blf_ensure_face (FontBLF *font) |
| static FontBLF * | blf_font_new_impl (const char *filepath, const char *mem_name, const uchar *mem, const size_t mem_size, void *ft_library) |
| FontBLF * | blf_font_new_from_filepath (const char *filepath) |
| FontBLF * | blf_font_new_from_mem (const char *mem_name, const uchar *mem, const size_t mem_size) |
| void | blf_font_attach_from_mem (FontBLF *font, const uchar *mem, const size_t mem_size) |
| void | blf_font_free (FontBLF *font) |
Deals with drawing text to OpenGL or bitmap buffers.
Also low level functions for managing FontBLF.
Definition in file blf_font.cc.
|
static |
Definition at line 285 of file blf_font.cc.
References GlyphCacheBLF::bitmap_len, GlyphCacheBLF::bitmap_len_landed, GlyphCacheBLF::bitmap_result, BLI_assert, g_batch, BatchBLF::glyph_cache, GPU_DATA_UBYTE, GPU_texture_update_sub(), GPU_texture_width(), and GlyphCacheBLF::texture.
Referenced by blf_batch_draw().
| void blf_batch_draw | ( | ) |
Definition at line 325 of file blf_font.cc.
References BatchBLF::batch, bitscan_reverse_i(), blf_batch_cache_texture_load(), blf_draw_cache_flush, BLI_assert_msg, BatchBLF::col_loc, BatchBLF::col_step, g_batch, BatchBLF::glyph_flags_loc, BatchBLF::glyph_flags_step, BatchBLF::glyph_len, BatchBLF::glyph_size_loc, BatchBLF::glyph_size_step, GPU_batch_draw(), GPU_batch_program_set_builtin(), GPU_batch_texture_bind, GPU_batch_uniform_1i, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_SHADER_TEXT, GPU_texture_unbind(), GPU_texture_width(), GPU_vertbuf_attr_get_raw_data(), GPU_vertbuf_data_len_set(), GPU_vertbuf_use(), is_power_of_2_i(), BatchBLF::offset_loc, BatchBLF::offset_step, BatchBLF::pos_loc, BatchBLF::pos_step, 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().
| void blf_batch_draw_begin | ( | FontBLF * | font | ) |
Definition at line 225 of file blf_font.cc.
References BatchBLF::active, BatchBLF::batch, BLF_ASPECT, blf_batch_draw(), blf_batch_draw_init(), BLF_ROTATION, BatchBLF::enabled, equals_m4m4(), BatchBLF::font, g_batch, GPU_matrix_model_view_get, GPU_matrix_pop(), GPU_matrix_push(), GPU_matrix_set, BatchBLF::mat, BatchBLF::ofs, BatchBLF::simple_shader, and zero_v2_int().
Referenced by blf_draw_svg_icon(), blf_font_draw_ex(), and blf_font_draw_mono().
|
static |
Definition at line 365 of file blf_font.cc.
References BatchBLF::active, blf_batch_draw(), and g_batch.
Referenced by blf_draw_svg_icon(), blf_font_draw_ex(), and blf_font_draw_mono().
|
static |
Definition at line 220 of file blf_font.cc.
References BatchBLF::batch, g_batch, and GPU_BATCH_DISCARD_SAFE.
Referenced by blf_font_exit().
|
static |
Draw-calls are precious! make them count! Since most of the Text elements are not covered by other UI elements, we can group some strings together and render them in one draw-call. This behavior is on demand only, between BLF_batch_draw_begin() and BLF_batch_draw_end().
Definition at line 189 of file blf_font.cc.
References BatchBLF::batch, BLF_BATCH_DRAW_LEN_MAX, BatchBLF::col_loc, BatchBLF::col_step, g_batch, BatchBLF::glyph_flags_loc, BatchBLF::glyph_flags_step, BatchBLF::glyph_len, BatchBLF::glyph_size_loc, BatchBLF::glyph_size_step, GPU_batch_create_ex(), GPU_batch_instbuf_set(), GPU_BATCH_OWNS_VBO, GPU_COMP_F32, GPU_COMP_I32, GPU_COMP_U32, GPU_COMP_U8, GPU_FETCH_FLOAT, GPU_FETCH_INT, GPU_FETCH_INT_TO_FLOAT_UNIT, GPU_PRIM_TRI_STRIP, GPU_USAGE_STREAM, GPU_vertbuf_attr_get_raw_data(), GPU_vertbuf_create_with_format, GPU_vertbuf_create_with_format_ex(), GPU_vertbuf_data_alloc(), GPU_vertformat_attr_add(), BatchBLF::offset_loc, BatchBLF::offset_step, BatchBLF::pos_loc, BatchBLF::pos_step, and BatchBLF::verts.
Referenced by blf_batch_draw_begin().
|
static |
Called in response to #FTC_Manager_LookupFace. Now add a face to our font.
Definition at line 97 of file blf_font.cc.
References blf_face_finalizer(), blf_setup_face(), BLI_mutex_lock(), BLI_mutex_unlock(), ft_lib_mutex, and lib.
Referenced by blf_font_init().
| void BLF_cache_flush_set_fn | ( | void(* | cache_flush_fn )() | ) |
Optional cache flushing function, called before blf_batch_draw.
Definition at line 1523 of file blf_font.cc.
References blf_draw_cache_flush.
Referenced by uiStyleInit().
|
static |
Definition at line 1091 of file blf_font.cc.
References bounds(), and CursorPositionForeachGlyph_Data::r_offset.
Referenced by blf_str_offset_from_cursor_position().
| char * blf_display_name | ( | FontBLF * | font | ) |
Definition at line 1475 of file blf_font.cc.
References blf_ensure_face(), and BLI_sprintfN().
Referenced by BLF_display_name_from_id().
| void blf_draw_svg_icon | ( | FontBLF * | font, |
| uint | icon_id, | ||
| float | x, | ||
| float | y, | ||
| float | size, | ||
| const float | color[4], | ||
| float | outline_alpha, | ||
| bool | multicolor, | ||
| blender::FunctionRef< void(std::string &)> | edit_source_cb ) |
Definition at line 528 of file blf_font.cc.
References blf_batch_draw_begin(), blf_batch_draw_end(), blf_font_size(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), blf_glyph_draw(), blf_glyph_ensure_icon(), BLF_SHADOW, int, Outline, and rgba_float_to_uchar().
Referenced by BLF_draw_svg_icon().
| bool blf_ensure_face | ( | FontBLF * | font | ) |
Create an FT_Face for this font if not already existing.
Definition at line 1781 of file blf_font.cc.
References BLF_BAD_FONT, BLF_CACHED, blf_dir_metrics_search(), blf_setup_face(), BLI_mutex_lock(), BLI_mutex_unlock(), ELEM, ft_lib_mutex, ftc_manager, MEM_freeN(), and printf.
Referenced by blf_display_name(), blf_font_attach_from_mem(), blf_font_new_impl(), blf_font_size(), blf_get_char_index(), BLF_get_vfont_metrics(), blf_glyph_ensure(), and blf_glyphslot_ensure_outline().
| void blf_ensure_size | ( | FontBLF * | font | ) |
Definition at line 2046 of file blf_font.cc.
References BLF_CACHED, BLF_DPI, blf_size_finalizer(), BLI_assert_unreachable, ftc_manager, and round_fl_to_uint().
Referenced by blf_font_ascender(), blf_font_descender(), blf_font_height_max_ft_pix(), blf_font_width_max_ft_pix(), blf_glyph_cache_new(), blf_glyph_render(), and blf_unscaled_F26Dot6_to_pixels().
|
static |
Called when a face is removed by the cache. FreeType will call #FT_Done_Face.
Definition at line 85 of file blf_font.cc.
Referenced by blf_cache_face_requester().
Definition at line 1469 of file blf_font.cc.
References blf_ensure_size(), and ft_pix_to_int().
Referenced by BLF_ascender().
Definition at line 1995 of file blf_font.cc.
References blf_ensure_face().
Referenced by BLF_metrics_attach().
| void blf_font_boundbox | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| rcti * | r_box, | ||
| ResultBLF * | r_info ) |
Definition at line 957 of file blf_font.cc.
References blf_font_boundbox_ex(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), and str.
Referenced by BLF_boundbox(), blf_font_height(), blf_font_width(), and blf_font_width_and_height().
| void blf_font_boundbox__wrap | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| rcti * | r_box, | ||
| ResultBLF * | r_info ) |
Definition at line 1373 of file blf_font.cc.
References blf_font_boundbox_wrap_cb(), blf_font_wrap_apply(), str, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by BLF_boundbox(), blf_font_height(), blf_font_width(), and blf_font_width_and_height().
|
static |
Definition at line 893 of file blf_font.cc.
References GlyphBLF::advance_x, blf_glyph_from_utf8_and_step(), GlyphBLF::box_xmax, GlyphBLF::box_xmin, GlyphBLF::box_ymax, GlyphBLF::box_ymin, ft_pix_from_int(), ft_pix_to_int(), ft_pix_to_int_ceil(), ft_pix_to_int_floor(), ResultBLF::lines, str, UNLIKELY, ResultBLF::width, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by blf_font_boundbox(), and blf_font_boundbox_wrap_cb().
| void blf_font_boundbox_foreach_glyph | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| BLF_GlyphBoundsFn | user_fn, | ||
| void * | user_data ) |
Definition at line 1044 of file blf_font.cc.
References GlyphBLF::advance_x, blf_glyph_cache_acquire(), blf_glyph_cache_release(), blf_glyph_from_utf8_and_step(), bounds(), GlyphBLF::box_xmax, GlyphBLF::box_xmin, GlyphBLF::box_ymax, GlyphBLF::box_ymin, ft_pix_to_int_ceil(), ft_pix_to_int_floor(), str, and UNLIKELY.
Referenced by BLF_boundbox_foreach_glyph(), blf_str_offset_from_cursor_position(), and blf_str_offset_to_glyph_bounds().
|
static |
Utility for blf_font_boundbox__wrap.
Definition at line 1360 of file blf_font.cc.
References blf_font_boundbox_ex(), BLI_rcti_union(), and str.
Referenced by blf_font_boundbox__wrap().
Definition at line 1463 of file blf_font.cc.
References blf_ensure_size(), and ft_pix_to_int().
Referenced by BLF_descender().
Definition at line 485 of file blf_font.cc.
References blf_font_draw_ex(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), and str.
Referenced by BLF_draw().
| void blf_font_draw__wrap | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| ResultBLF * | r_info ) |
Definition at line 1353 of file blf_font.cc.
References blf_font_draw__wrap_cb(), blf_font_wrap_apply(), and str.
Referenced by BLF_draw().
|
static |
Utility for blf_font_draw__wrap.
Definition at line 1344 of file blf_font.cc.
References blf_font_draw_ex(), and str.
Referenced by blf_font_draw__wrap().
| void blf_font_draw_buffer | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| ResultBLF * | r_info ) |
Definition at line 766 of file blf_font.cc.
References blf_font_draw_buffer_ex(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), and str.
Referenced by BLF_draw_buffer().
| void blf_font_draw_buffer__wrap | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| ResultBLF * | r_info ) |
Definition at line 1395 of file blf_font.cc.
References blf_font_draw_buffer__wrap_cb(), blf_font_wrap_apply(), and str.
Referenced by BLF_draw_buffer().
|
static |
Utility for blf_font_draw_buffer__wrap.
Definition at line 1386 of file blf_font.cc.
References blf_font_draw_buffer_ex(), and str.
Referenced by blf_font_draw_buffer__wrap().
|
static |
Definition at line 733 of file blf_font.cc.
References GlyphBLF::advance_x, blf_glyph_draw_buffer(), blf_glyph_from_utf8_and_step(), ft_pix_from_int(), ft_pix_to_int(), ResultBLF::lines, str, UNLIKELY, and ResultBLF::width.
Referenced by blf_font_draw_buffer(), and blf_font_draw_buffer__wrap_cb().
|
static |
Definition at line 450 of file blf_font.cc.
References GlyphBLF::advance_x, blf_batch_draw_begin(), blf_batch_draw_end(), blf_glyph_draw(), blf_glyph_from_utf8_and_step(), ft_pix_to_int(), ft_pix_to_int_floor(), ResultBLF::lines, str, UNLIKELY, and ResultBLF::width.
Referenced by blf_font_draw(), and blf_font_draw__wrap_cb().
| int blf_font_draw_mono | ( | FontBLF * | font, |
| const char * | str, | ||
| size_t | str_len, | ||
| int | cwidth, | ||
| int | tab_columns ) |
Use fixed column width, but an utf8 character may occupy multiple columns.
Definition at line 492 of file blf_font.cc.
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_safe(), GlyphBLF::c, col, ft_pix_from_int(), ft_pix_to_int_floor(), str, and UNLIKELY.
Referenced by BLF_draw_mono().
| void blf_font_exit | ( | ) |
Definition at line 1511 of file blf_font.cc.
References blf_batch_draw_exit(), BLI_mutex_end(), ft_lib, ft_lib_mutex, and ftc_manager.
Referenced by BLF_exit().
|
static |
Definition at line 1534 of file blf_font.cc.
Referenced by blf_font_new_impl().
Definition at line 1036 of file blf_font.cc.
References blf_glyph_cache_acquire(), blf_glyph_cache_release(), and GlyphCacheBLF::fixed_width.
Referenced by BLF_fixed_width().
| void blf_font_free | ( | FontBLF * | font | ) |
Definition at line 2007 of file blf_font.cc.
References BLF_CACHED, blf_glyph_cache_clear(), BLI_mutex_lock(), BLI_mutex_unlock(), ft_lib_mutex, ftc_manager, and MEM_freeN().
Referenced by BLF_exit(), blf_font_new_impl(), BLF_reset_fonts(), BLF_unload(), BLF_unload_all(), and BLF_unload_id().
| float blf_font_height | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| ResultBLF * | r_info ) |
Definition at line 1015 of file blf_font.cc.
References BLF_ASPECT, blf_font_boundbox(), blf_font_boundbox__wrap(), BLF_WORD_WRAP, BLI_rcti_size_y(), float, and str.
Referenced by BLF_height().
Definition at line 1446 of file blf_font.cc.
References blf_font_height_max_ft_pix(), and ft_pix_to_int().
Referenced by BLF_height_max().
Definition at line 1439 of file blf_font.cc.
References blf_ensure_size(), and ft_pix_from_int().
Referenced by blf_font_height_max(), and blf_font_wrap_apply().
| int blf_font_init | ( | ) |
Definition at line 1489 of file blf_font.cc.
References BLF_CACHE_BYTES, blf_cache_face_requester(), BLF_CACHE_MAX_FACES, BLF_CACHE_MAX_SIZES, BLI_mutex_init(), ft_lib, ft_lib_mutex, ftc_charmap_cache, ftc_manager, and g_batch.
Referenced by BLF_init().
|
static |
NOTE(@Harley): that the data the following function creates is not yet used. But do not remove it as it will be used in the near future.
Definition at line 1578 of file blf_font.cc.
References FontMetrics::ascender, FontMetrics::cap_height, FontMetrics::descender, FontMetrics::family_class, FontMetrics::first_charindex, float, int, FontMetrics::last_charindex, FontMetrics::line_height, FontMetrics::max_advance_height, FontMetrics::max_advance_width, FontMetrics::num_glyphs, FontMetrics::o_proportion, FontMetrics::selection_flags, FontMetrics::slant, FontMetrics::strikeout_position, FontMetrics::strikeout_thickness, FontMetrics::subscript_size, FontMetrics::subscript_xoffset, FontMetrics::subscript_yoffset, FontMetrics::superscript_size, FontMetrics::superscript_xoffset, FontMetrics::superscript_yoffset, FontMetrics::underline_position, FontMetrics::underline_thickness, FontMetrics::units_per_EM, FontMetrics::valid, FontMetrics::weight, FontMetrics::width, and FontMetrics::x_height.
Referenced by blf_setup_face().
| FontBLF * blf_font_new_from_filepath | ( | const char * | filepath | ) |
Definition at line 1985 of file blf_font.cc.
References blf_font_new_impl().
Referenced by BLF_load_unique().
Definition at line 1990 of file blf_font.cc.
References blf_font_new_impl().
Referenced by BLF_load_mem_unique().
|
static |
Create a new font from filename OR memory pointer. For normal operation pass nullptr as FT_Library object. Pass a custom FT_Library if you want to use the font without its lifetime being managed by the FreeType cache subsystem.
Definition at line 1916 of file blf_font.cc.
References ARRAY_SIZE, BLF_CACHED, blf_ensure_face(), blf_font_fill(), blf_font_free(), BLF_LAST_RESORT, BLI_path_basename(), BLI_path_cmp, BLI_strdup(), FaceDetails::coverage1, FaceDetails::coverage2, FaceDetails::coverage3, FaceDetails::coverage4, ft_lib, int, and static_face_details.
Referenced by blf_font_new_from_filepath(), and blf_font_new_from_mem().
Change font's output size. Returns true if successful in changing the size.
Definition at line 2068 of file blf_font.cc.
References BLF_CACHED, BLF_DPI, blf_ensure_face(), blf_size_finalizer(), float, ftc_manager, round_fl_to_uint(), and size().
Referenced by blf_draw_svg_icon(), blf_glyph_render(), BLF_size(), and blf_svg_icon_bitmap().
| blender::Vector< blender::StringRef > blf_font_string_wrap | ( | FontBLF * | font, |
| blender::StringRef | str, | ||
| int | max_pixel_width ) |
Definition at line 1418 of file blf_font.cc.
References blf_font_string_wrap_cb(), blf_font_wrap_apply(), and str.
Referenced by BLF_string_wrap().
|
static |
Wrap a blender::StringRef.
Definition at line 1405 of file blf_font.cc.
References str.
Referenced by blf_font_string_wrap().
Definition at line 994 of file blf_font.cc.
References BLF_ASPECT, blf_font_boundbox(), blf_font_boundbox__wrap(), BLF_WORD_WRAP, BLI_rcti_size_x(), float, and str.
Referenced by blf_str_offset_to_cursor(), and BLF_width().
| void blf_font_width_and_height | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| float * | r_width, | ||
| float * | r_height, | ||
| ResultBLF * | r_info ) |
Definition at line 965 of file blf_font.cc.
References BLF_ASPECT, blf_font_boundbox(), blf_font_boundbox__wrap(), BLF_WORD_WRAP, BLI_rcti_size_x(), BLI_rcti_size_y(), float, and str.
Referenced by BLF_width_and_height().
Definition at line 1458 of file blf_font.cc.
References blf_font_width_max_ft_pix(), and ft_pix_to_int().
Referenced by BLF_width_max().
Definition at line 1451 of file blf_font.cc.
References blf_ensure_size(), and ft_pix_from_int().
Referenced by blf_font_width_max().
| size_t blf_font_width_to_rstrlen | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| int | width, | ||
| int * | r_width ) |
Definition at line 846 of file blf_font.cc.
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(), and str.
Referenced by BLF_width_to_rstrlen().
| size_t blf_font_width_to_strlen | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| int | width, | ||
| int * | r_width ) |
Definition at line 817 of file blf_font.cc.
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(), int, and str.
Referenced by BLF_width_to_strlen().
|
static |
Definition at line 783 of file blf_font.cc.
References GlyphBLF::advance_x, blf_glyph_ensure_subpixel(), blf_kerning(), BLF_MONOSPACED, BLF_RENDER_SUBPIXELAA, FT_PIX_ROUND, ft_pix_to_int(), and UNLIKELY.
Referenced by blf_font_width_to_rstrlen(), and blf_font_width_to_strlen().
|
static |
Generic function to add word-wrap support for other existing functions.
Wraps on spaces and respects newlines. Intentionally ignores non-unix newlines, tabs and more advanced text formatting.
Implementation Detail (utf8).
Take care with single byte offsets here, since this is utf8 we can't be sure a single byte is a single character.
This is only done when we know for sure the character is ascii (newline or a space).
Definition at line 1238 of file blf_font.cc.
References GlyphBLF::advance_x, blf_font_height_max_ft_pix(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), blf_glyph_from_utf8_and_step(), GlyphBLF::c, callback, ft_pix_from_int(), ft_pix_to_int(), ResultBLF::lines, printf, str, UNLIKELY, ResultBLF::width, and wrap().
Referenced by blf_font_boundbox__wrap(), blf_font_draw__wrap(), blf_font_draw_buffer__wrap(), and blf_font_string_wrap().
Return glyph id from char-code.
Definition at line 149 of file blf_font.cc.
References BLF_CACHED, blf_ensure_face(), and ftc_charmap_cache.
Referenced by blf_glyph_cache_new(), blf_glyph_index_from_charcode(), and BLF_has_glyph().
|
static |
Draw glyph g into buf_info pixels.
Definition at line 625 of file blf_font.cc.
References GlyphBLF::bitmap, blend_color_mix_byte(), blend_color_mix_float(), FontBufInfoBLF::cbuf, FontBufInfoBLF::col_char, FontBufInfoBLF::col_float, FontBufInfoBLF::dims, GlyphBLF::dims, FontBufInfoBLF::fbuf, ft_pix_from_int(), ft_pix_to_int(), GlyphBLF::pitch, GlyphBLF::pos, unit_float_to_uchar_clamp, and y.
Referenced by blf_font_draw_buffer_ex().
| BLI_INLINE GlyphBLF * blf_glyph_from_utf8_and_step | ( | FontBLF * | font, |
| GlyphCacheBLF * | gc, | ||
| const GlyphBLF * | g_prev, | ||
| const char * | str, | ||
| size_t | str_len, | ||
| size_t * | i_p, | ||
| int32_t * | pen_x ) |
Definition at line 413 of file blf_font.cc.
References blf_glyph_ensure(), blf_glyph_ensure_subpixel(), blf_kerning(), BLF_MONOSPACED, BLF_RENDER_SUBPIXELAA, BLI_assert, BLI_str_utf8_as_unicode_step_safe(), BLI_UTF8_ERR, FT_PIX_ROUND, and str.
Referenced by blf_font_boundbox_ex(), blf_font_boundbox_foreach_glyph(), blf_font_draw_buffer_ex(), blf_font_draw_ex(), blf_font_draw_mono(), blf_font_width_to_rstrlen(), blf_font_width_to_strlen(), and blf_font_wrap_apply().
| BLI_INLINE ft_pix blf_kerning | ( | FontBLF * | font, |
| const GlyphBLF * | g_prev, | ||
| const GlyphBLF * | g ) |
Definition at line 378 of file blf_font.cc.
References blf_unscaled_F26Dot6_to_pixels(), GlyphBLF::c, GlyphBLF::idx, int, KERNING_CACHE_TABLE_SIZE, KERNING_ENTRY_UNSET, GlyphBLF::lsb_delta, GlyphBLF::rsb_delta, and UNLIKELY.
Referenced by blf_font_width_to_strlen_glyph_process(), and blf_glyph_from_utf8_and_step().
|
static |
Extra FontBLF setup needed after it gets a Face. Called from both blf_ensure_face and from the blf_cache_face_requester callback.
Definition at line 1747 of file blf_font.cc.
References KerningCacheBLF::ascii_table, blf_font_metrics(), BLF_MONOSPACED, KERNING_CACHE_TABLE_SIZE, KERNING_ENTRY_UNSET, and MEM_mallocN.
Referenced by blf_cache_face_requester(), and blf_ensure_face().
|
static |
Called when the FreeType cache is removing a font size.
Definition at line 136 of file blf_font.cc.
Referenced by blf_ensure_size(), and blf_font_size().
|
static |
Definition at line 1142 of file blf_font.cc.
References bounds(), and StrOffsetToGlyphBounds_Data::bounds.
Referenced by blf_str_offset_to_glyph_bounds().
| size_t blf_str_offset_from_cursor_position | ( | FontBLF * | font, |
| const char * | str, | ||
| size_t | str_len, | ||
| int | location_x ) |
Definition at line 1105 of file blf_font.cc.
References blf_cursor_position_foreach_glyph(), blf_font_boundbox_foreach_glyph(), BLI_str_cursor_step_prev_utf8(), BLI_str_utf8_char_width_or_error(), BLI_strnlen(), int, CursorPositionForeachGlyph_Data::location_x, and str.
Referenced by BLF_str_offset_from_cursor_position().
| int blf_str_offset_to_cursor | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| const size_t | str_offset, | ||
| const int | cursor_width ) |
Definition at line 1168 of file blf_font.cc.
References blf_font_width(), blf_str_offset_to_glyph_bounds(), int, next, and str.
Referenced by BLF_str_offset_to_cursor(), and blf_str_selection_boxes().
| void blf_str_offset_to_glyph_bounds | ( | FontBLF * | font, |
| const char * | str, | ||
| size_t | str_offset, | ||
| rcti * | r_glyph_bounds ) |
Definition at line 1155 of file blf_font.cc.
References blf_font_boundbox_foreach_glyph(), blf_str_offset_foreach_glyph(), str, and StrOffsetToGlyphBounds_Data::str_offset.
Referenced by blf_str_offset_to_cursor(), and BLF_str_offset_to_glyph_bounds().
| blender::Vector< blender::Bounds< int > > blf_str_selection_boxes | ( | FontBLF * | font, |
| const char * | str, | ||
| size_t | str_len, | ||
| size_t | sel_start, | ||
| size_t | sel_length ) |
Definition at line 1213 of file blf_font.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blf_str_offset_to_cursor(), and str.
Referenced by BLF_str_selection_boxes().
| blender::Array< uchar > blf_svg_icon_bitmap | ( | FontBLF * | font, |
| uint | icon_id, | ||
| float | size, | ||
| int * | r_width, | ||
| int * | r_height, | ||
| bool | multicolor, | ||
| blender::FunctionRef< void(std::string &)> | edit_source_cb ) |
Definition at line 574 of file blf_font.cc.
References GlyphBLF::bitmap, blf_font_size(), blf_glyph_cache_acquire(), blf_glyph_cache_release(), blf_glyph_ensure_icon(), blender::Array< T, InlineBufferCapacity, Allocator >::data(), GlyphBLF::dims, GlyphBLF::num_channels, GlyphBLF::pitch, and blender::Array< T, InlineBufferCapacity, Allocator >::size().
Referenced by BLF_svg_icon_bitmap().
Definition at line 160 of file blf_font.cc.
References blf_ensure_size(), and scaled().
Referenced by blf_kerning().
|
static |
Definition at line 70 of file blf_font.cc.
Referenced by blf_batch_draw(), and BLF_cache_flush_set_fn().
|
static |
Definition at line 62 of file blf_font.cc.
Referenced by blf_font_exit(), blf_font_init(), blf_font_new_impl(), and BLF_thumb_preview().
|
static |
Definition at line 67 of file blf_font.cc.
Referenced by blf_cache_face_requester(), blf_ensure_face(), blf_font_exit(), blf_font_free(), and blf_font_init().
|
static |
Definition at line 64 of file blf_font.cc.
Referenced by blf_font_init(), and blf_get_char_index().
|
static |
Definition at line 63 of file blf_font.cc.
Referenced by blf_ensure_face(), blf_ensure_size(), blf_font_exit(), blf_font_free(), blf_font_init(), and blf_font_size().
| BatchBLF g_batch |
Definition at line 59 of file blf_font.cc.
Referenced by blf_batch_cache_texture_load(), blf_batch_draw(), BLF_batch_draw_begin(), blf_batch_draw_begin(), BLF_batch_draw_end(), blf_batch_draw_end(), blf_batch_draw_exit(), BLF_batch_draw_flush(), blf_batch_draw_init(), blf_font_init(), blf_glyph_draw(), and blf_texture_draw().
|
static |
Definition at line 1875 of file blf_font.cc.
Referenced by blf_font_new_impl().