|
Blender V4.5
|
#include <algorithm>#include <cstdio>#include <cstdlib>#include <cstring>#include <ft2build.h>#include "MEM_guardedalloc.h"#include "DNA_vec_types.h"#include "BLI_math_bits.h"#include "BLI_math_color_blend.h"#include "BLI_math_matrix.h"#include "BLI_mutex.hh"#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_vector.hh"#include "BLF_api.hh"#include "GPU_batch.hh"#include "GPU_matrix.hh"#include "GPU_state.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) |
UTF8 Utilities (Internal) | |
| static int | blf_str_is_utf8_valid_lazy_init (const char *str, const size_t str_len, int &is_utf8_valid) |
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) |
| int | blf_font_glyph_advance (FontBLF *font, const char *str) |
| 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, BLFWrapMode mode, 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, BLFWrapMode mode) |
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 blender::Mutex | 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 284 of file blf_font.cc.
References GlyphCacheBLF::bitmap_len, GlyphCacheBLF::bitmap_len_landed, GlyphCacheBLF::bitmap_result, BLI_assert, g_batch, 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 324 of file blf_font.cc.
References bitscan_reverse_i(), blf_batch_cache_texture_load(), blf_draw_cache_flush, BLI_assert_msg, g_batch, 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(), and texture().
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 224 of file blf_font.cc.
References BLF_ASPECT, blf_batch_draw(), blf_batch_draw_init(), BLF_ROTATION, equals_m4m4(), FontBLF::flags, g_batch, GPU_matrix_model_view_get, GPU_matrix_pop(), GPU_matrix_push(), GPU_matrix_set, FontBLF::pos, and zero_v2_int().
Referenced by blf_draw_svg_icon(), blf_font_draw_ex(), and blf_font_draw_mono().
|
static |
Definition at line 364 of file blf_font.cc.
References 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 219 of file blf_font.cc.
References 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 188 of file blf_font.cc.
References BLF_BATCH_DRAW_LEN_MAX, g_batch, 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(), and GPU_vertformat_attr_add().
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(), FontBLF::face, FontBLF::filepath, ft_lib_mutex, lib, lock, FontBLF::mem, and FontBLF::mem_size.
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 1635 of file blf_font.cc.
References blf_draw_cache_flush.
Referenced by uiStyleInit().
|
static |
Definition at line 1127 of file blf_font.cc.
References bounds(), and data.
Referenced by blf_str_offset_from_cursor_position().
| char * blf_display_name | ( | FontBLF * | font | ) |
Definition at line 1589 of file blf_font.cc.
References blf_ensure_face(), BLI_sprintfN(), and FontBLF::face.
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 546 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, FontBLF::color, FontBLF::flags, Outline, FontBLF::pos, rgba_float_to_uchar(), FontBLF::shadow, FontBLF::shadow_color, FontBLF::shadow_x, FontBLF::shadow_y, size(), x, and y.
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 1892 of file blf_font.cc.
References BLF_BAD_FONT, BLF_CACHED, blf_dir_metrics_search(), blf_setup_face(), ELEM, FontBLF::face, FontBLF::filepath, FontBLF::flags, FontBLF::ft_lib, ft_lib_mutex, FontBLF::ft_size, ftc_manager, lock, FontBLF::mem, MEM_freeN(), FontBLF::mem_size, 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 2155 of file blf_font.cc.
References BLF_CACHED, BLF_DPI, blf_size_finalizer(), BLI_assert_unreachable, FontBLF::flags, FontBLF::ft_size, ftc_manager, round_fl_to_uint(), and FontBLF::size.
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.
References FontBLF::face.
Referenced by blf_cache_face_requester().
| int blf_font_ascender | ( | FontBLF * | font | ) |
Definition at line 1583 of file blf_font.cc.
References blf_ensure_size(), ft_pix_to_int(), and FontBLF::ft_size.
Referenced by BLF_ascender().
Definition at line 2105 of file blf_font.cc.
References blf_ensure_face(), and FontBLF::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 976 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 1473 of file blf_font.cc.
References blf_font_boundbox_wrap_cb(), blf_font_wrap_apply(), str, FontBLF::wrap_mode, FontBLF::wrap_width, 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 917 of file blf_font.cc.
References GlyphBLF::advance_x, blf_glyph_from_utf8_and_step(), BLF_MONOSPACED, GlyphBLF::box_xmax, GlyphBLF::box_xmin, GlyphBLF::box_ymax, GlyphBLF::box_ymin, FontBLF::flags, ft_pix_from_int(), ft_pix_to_int(), ft_pix_to_int_ceil(), ft_pix_to_int_floor(), i, 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 1080 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(), i, 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 1460 of file blf_font.cc.
References blf_font_boundbox_ex(), BLI_rcti_union(), and str.
Referenced by blf_font_boundbox__wrap().
| int blf_font_descender | ( | FontBLF * | font | ) |
Definition at line 1577 of file blf_font.cc.
References blf_ensure_size(), ft_pix_to_int(), and FontBLF::ft_size.
Referenced by BLF_descender().
Definition at line 503 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 1447 of file blf_font.cc.
References blf_font_draw__wrap_cb(), blf_font_wrap_apply(), str, FontBLF::wrap_mode, and FontBLF::wrap_width.
Referenced by BLF_draw().
|
static |
Utility for blf_font_draw__wrap.
Definition at line 1438 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 784 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 1501 of file blf_font.cc.
References blf_font_draw_buffer__wrap_cb(), blf_font_wrap_apply(), str, FontBLF::wrap_mode, and FontBLF::wrap_width.
Referenced by BLF_draw_buffer().
|
static |
Utility for blf_font_draw_buffer__wrap.
Definition at line 1492 of file blf_font.cc.
References blf_font_draw_buffer_ex(), and str.
Referenced by blf_font_draw_buffer__wrap().
|
static |
Definition at line 751 of file blf_font.cc.
References GlyphBLF::advance_x, blf_glyph_draw_buffer(), blf_glyph_from_utf8_and_step(), FontBLF::buf_info, ft_pix_from_int(), ft_pix_to_int(), i, ResultBLF::lines, FontBLF::pos, str, UNLIKELY, and ResultBLF::width.
Referenced by blf_font_draw_buffer(), and blf_font_draw_buffer__wrap_cb().
|
static |
Definition at line 468 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(), i, 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 510 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(), i, str, and UNLIKELY.
Referenced by BLF_draw_mono().
| void blf_font_exit | ( | ) |
Definition at line 1624 of file blf_font.cc.
References blf_batch_draw_exit(), ft_lib, and ftc_manager.
Referenced by BLF_exit().
|
static |
Definition at line 1646 of file blf_font.cc.
References FontBLF::angle, FontBLF::aspect, FontBLF::buf_info, FontBufInfoBLF::cbuf, FontBLF::char_slant, FontBLF::char_spacing, FontBLF::char_weight, FontBLF::char_width, FontBLF::clip_rec, FontBufInfoBLF::col_init, FontBLF::color, FontBufInfoBLF::dims, FontBufInfoBLF::fbuf, FontBLF::flags, FontBLF::kerning_cache, FontBLF::pos, FontBLF::size, FontBLF::tex_size_max, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by blf_font_new_impl().
| float blf_font_fixed_width | ( | FontBLF * | font | ) |
Definition at line 1055 of file blf_font.cc.
References blf_glyph_cache_acquire(), blf_glyph_cache_release(), GlyphCacheBLF::fixed_width, and FontBLF::size.
Referenced by BLF_fixed_width().
| void blf_font_free | ( | FontBLF * | font | ) |
Definition at line 2117 of file blf_font.cc.
References BLF_CACHED, blf_glyph_cache_clear(), FontBLF::face, FontBLF::filepath, FontBLF::flags, FontBLF::ft_lib, ft_lib_mutex, ftc_manager, FontBLF::kerning_cache, lock, MEM_freeN(), FontBLF::mem_name, and FontBLF::variations.
Referenced by BLF_exit(), blf_font_new_impl(), BLF_reset_fonts(), BLF_unload(), BLF_unload_all(), and BLF_unload_id().
| int blf_font_glyph_advance | ( | FontBLF * | font, |
| const char * | str ) |
Definition at line 1063 of file blf_font.cc.
References GlyphBLF::advance_x, blf_glyph_cache_acquire(), blf_glyph_cache_release(), blf_glyph_ensure(), BLI_str_utf8_as_unicode_safe(), ft_pix_to_int(), str, and UNLIKELY.
Referenced by BLF_glyph_advance().
| float blf_font_height | ( | FontBLF * | font, |
| const char * | str, | ||
| const size_t | str_len, | ||
| ResultBLF * | r_info ) |
Definition at line 1034 of file blf_font.cc.
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().
| int blf_font_height_max | ( | FontBLF * | font | ) |
Definition at line 1560 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 1553 of file blf_font.cc.
References blf_ensure_size(), ft_pix_from_int(), and FontBLF::ft_size.
Referenced by blf_font_height_max(), and blf_font_wrap_apply().
| int blf_font_init | ( | ) |
Definition at line 1603 of file blf_font.cc.
References BLF_CACHE_BYTES, blf_cache_face_requester(), BLF_CACHE_MAX_FACES, BLF_CACHE_MAX_SIZES, ft_lib, 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 1690 of file blf_font.cc.
References FontMetrics::ascender, FontMetrics::cap_height, FontMetrics::descender, FontMetrics::family_class, FontMetrics::first_charindex, 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 2095 of file blf_font.cc.
References blf_font_new_impl().
Referenced by BLF_load_unique().
Definition at line 2100 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 2026 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, FontBLF::face, FontBLF::filepath, FontBLF::flags, FontBLF::ft_lib, ft_lib, i, FontBLF::mem, FontBLF::mem_name, FontBLF::mem_size, static_face_details, and FontBLF::unicode_ranges.
Referenced by blf_font_new_from_filepath(), and blf_font_new_from_mem().
| bool blf_font_size | ( | FontBLF * | font, |
| float | size ) |
Change font's output size. Returns true if successful in changing the size.
Definition at line 2177 of file blf_font.cc.
References BLF_CACHED, BLF_DPI, blf_ensure_face(), blf_size_finalizer(), FontBLF::face, FontBLF::flags, FontBLF::ft_size, ftc_manager, round_fl_to_uint(), FontBLF::size, 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, | ||
| BLFWrapMode | mode ) |
Definition at line 1530 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 1517 of file blf_font.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), and str.
Referenced by blf_font_string_wrap().
Definition at line 1013 of file blf_font.cc.
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_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 984 of file blf_font.cc.
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, and str.
Referenced by BLF_width_and_height().
| int blf_font_width_max | ( | FontBLF * | font | ) |
Definition at line 1572 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 1565 of file blf_font.cc.
References blf_ensure_size(), ft_pix_from_int(), and FontBLF::ft_size.
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 864 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(), blf_str_is_utf8_valid_lazy_init(), BLI_assert, BLI_str_find_prev_char_utf8(), BLI_strnlen(), ft_pix_to_int(), i, 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 835 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(), i, and str.
Referenced by BLF_width_to_strlen().
|
static |
Definition at line 801 of file blf_font.cc.
References GlyphBLF::advance_x, blf_glyph_ensure_subpixel(), blf_kerning(), BLF_MONOSPACED, BLF_RENDER_SUBPIXELAA, FontBLF::flags, 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 1274 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(), BLI_str_utf32_char_is_breaking_space(), BLI_str_utf32_char_is_optional_break_after(), BLI_str_utf32_char_is_optional_break_before(), BLI_str_utf8_as_unicode_safe(), BLI_str_utf8_from_unicode_len(), GlyphBLF::c, ELEM, ft_pix_from_int(), ft_pix_to_int(), HardLimit, i, ResultBLF::lines, Minimal, Path, printf, SEP, str, Typographical, 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 148 of file blf_font.cc.
References BLF_CACHED, blf_ensure_face(), FontBLF::face, FontBLF::flags, and ftc_charmap_cache.
Referenced by blf_glyph_cache_new(), blf_glyph_index_from_charcode(), blf_glyphslot_ensure_outline(), and BLF_has_glyph().
|
static |
Draw glyph g into buf_info pixels.
Definition at line 643 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(), x, 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 412 of file blf_font.cc.
References blf_glyph_ensure(), blf_glyph_ensure_subpixel(), blf_kerning(), BLF_MONOSPACED, BLF_RENDER_SUBPIXELAA, BLI_assert, BLI_INLINE, BLI_str_utf8_as_unicode_step_safe(), BLI_UTF8_ERR, FontBLF::flags, 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 377 of file blf_font.cc.
References KerningCacheBLF::ascii_table, blf_unscaled_F26Dot6_to_pixels(), BLI_INLINE, GlyphBLF::c, FontBLF::face, GlyphBLF::idx, FontBLF::kerning_cache, 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 1859 of file blf_font.cc.
References KerningCacheBLF::ascii_table, blf_font_metrics(), BLF_MONOSPACED, FontBLF::char_slant, FontBLF::char_spacing, FontBLF::char_weight, FontBLF::char_width, FontBLF::face, FontBLF::face_flags, FontBLF::flags, i, FontBLF::kerning_cache, KERNING_CACHE_TABLE_SIZE, KERNING_ENTRY_UNSET, MEM_mallocN(), FontBLF::metrics, FontMetrics::slant, FontMetrics::spacing, FontMetrics::valid, FontBLF::variations, FontMetrics::weight, and FontMetrics::width.
Referenced by blf_cache_face_requester(), and blf_ensure_face().
|
static |
Called when the FreeType cache is removing a font size.
Definition at line 135 of file blf_font.cc.
References FontBLF::ft_size, and size().
Referenced by blf_ensure_size(), and blf_font_size().
|
static |
Only assert on invalid UTF8 handling if the strings are valid UTF8.
Definition at line 452 of file blf_font.cc.
References BLI_str_utf8_invalid_byte(), and str.
Referenced by blf_font_width_to_rstrlen().
|
static |
Definition at line 1178 of file blf_font.cc.
References bounds(), and data.
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 1141 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(), data, 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 1204 of file blf_font.cc.
References blf_font_width(), blf_str_offset_to_glyph_bounds(), 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 1191 of file blf_font.cc.
References blf_font_boundbox_foreach_glyph(), blf_str_offset_foreach_glyph(), data, and str.
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 1249 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 592 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, blender::Array< T, InlineBufferCapacity, Allocator >::size(), size(), x, and y.
Referenced by BLF_svg_icon_bitmap().
Definition at line 159 of file blf_font.cc.
References blf_ensure_size(), FontBLF::ft_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(), and blf_font_free().
|
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 1985 of file blf_font.cc.
Referenced by blf_font_new_impl().