38#define BLF_RESULT_CHECK_INIT(r_info) \
40 memset(r_info, 0, sizeof(*(r_info))); \
113 if ((font ==
nullptr) || (font->
mem_name ==
nullptr)) {
129 if ((font ==
nullptr) || (font->
filepath ==
nullptr)) {
172 return blf_get(fontid) !=
nullptr;
193 printf(
"Too many fonts!!!\n");
200 printf(
"Can't find font: %s\n", filepath);
207 printf(
"Can't load font: %s\n", filepath);
239 printf(
"Too many fonts!!!\n");
244 printf(
"Can't load font: %s from memory!!\n",
name);
250 printf(
"Can't load font: %s from memory!!\n",
name);
264 if (font ==
nullptr || font->
filepath ==
nullptr) {
408 if (remainder > 0.4f && remainder < 0.6f) {
409 if (remainder < 0.5f) {
418 if (remainder > 0.4f && remainder < 0.6f) {
419 if (remainder < 0.5f) {
428 if (remainder > 0.4f && remainder < 0.6f) {
429 if (remainder < 0.5f) {
457 font->
color[0] = rgba[0];
458 font->
color[1] = rgba[1];
459 font->
color[2] = rgba[2];
460 font->
color[3] = rgba[3];
469 font->
color[0] = rgb[0];
470 font->
color[1] = rgb[1];
471 font->
color[2] = rgb[2];
472 font->
color[3] = alpha;
489 font->
color[3] = alpha;
501 font->
color[3] = 255;
516 const float rgba[4] = {r, g,
b, a};
530 const float rgba[4] = {r, g,
b, 1.0f};
589 if (str_len == 0 ||
str[0] ==
'\0') {
607int BLF_draw_mono(
int fontid,
const char *
str,
const size_t str_len,
int cwidth,
int tab_columns)
609 if (str_len == 0 ||
str[0] ==
'\0') {
629 const float color[4],
642 UNUSED_VARS(icon_id,
x,
y,
size, color, outline_alpha, multicolor, edit_source_cb);
659 UNUSED_VARS(icon_id,
size, r_width, r_height, multicolor, edit_source_cb);
695 rcti *r_glyph_bounds)
707 const size_t str_len,
708 const size_t str_offset,
709 const int cursor_width)
719 int fontid,
const char *
str,
size_t str_len,
size_t sel_start,
size_t sel_length)
729 int fontid,
const char *
str,
const size_t str_len,
float width,
float *r_width)
739 *r_width =
float(width_result) * xa;
751 int fontid,
const char *
str,
const size_t str_len,
float width,
float *r_width)
761 *r_width =
float(width_result) * xa;
773 int fontid,
const char *
str,
const size_t str_len,
rcti *r_box,
ResultBLF *r_info)
790 int fontid,
const char *
str,
const size_t str_len,
float *r_width,
float *r_height)
798 *r_width = *r_height = 0.0f;
985 buffer_state->
fontid = fontid;
986 buffer_state->
font = font;
997 if (font == buffer_state->
font) {
1012 MEM_delete(buffer_state);
1063 const int max_pixel_width,
1078 char *
name =
nullptr;
1079 FT_Library ft_library;
1080 if (FT_Init_FreeType(&ft_library) == FT_Err_Ok) {
1082 if (FT_New_Face(ft_library, filepath, 0, &face) == FT_Err_Ok) {
1083 if (face->family_name) {
1088 FT_Done_FreeType(ft_library);
1117 const bool complete_font = (font->
face->ascender != 0) && (font->
face->descender != 0) &&
1118 (font->
face->ascender != font->
face->descender);
1120 if (complete_font) {
1123 *ascend_ratio =
float(font->
face->ascender) / (font->
face->ascender - font->
face->descender);
1131 if (font->
face->bbox.yMax != font->
face->bbox.yMin) {
1132 *scale =
float(1.0 /
double(font->
face->bbox.yMax - font->
face->bbox.yMin));
1134 if (complete_font) {
1135 *em_ratio =
float(font->
face->ascender - font->
face->descender) /
1136 (font->
face->bbox.yMax - font->
face->bbox.yMin);
1165 printf(
"fontid %d %p\n", fontid, (
void *)font);
1166 printf(
" mem_name: '%s'\n", font->mem_name ? font->mem_name :
"<none>");
1167 printf(
" filepath: '%s'\n", font->filepath ? font->filepath :
"<none>");
1168 printf(
" size: %f\n", font->size);
1170 printf(
" aspect: (%d) %.6f %.6f %.6f\n",
1173 printf(
" angle: (%d) %.6f\n", (font->flags &
BLF_ASPECT) != 0, font->angle);
1174 printf(
" flag: %d\n", font->flags);
1177 printf(
"fontid %d (nullptr)\n", fontid);
void BLF_default_set(int fontid)
#define BLF_VFONT_METRICS_EM_RATIO_DEFAULT
bool(*)(const char *str, size_t str_step_ofs, const rcti *bounds, void *user_dataconst) BLF_GlyphBoundsFn
#define BLF_VFONT_METRICS_SCALE_DEFAULT
blender::ocio::ColorSpace ColorSpace
#define BLF_VFONT_METRICS_ASCEND_RATIO_DEFAULT
File and directory operations.
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
MINLINE int round_fl_to_int(float a)
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
void GPU_matrix_scale_3fv(const float vec[3])
void GPU_matrix_rotate_2d(float deg)
void GPU_matrix_translate_3f(float x, float y, float z)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], const ColorSpace *colorspace)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
void BLF_color3ubv(int fontid, const uchar rgb[3])
size_t BLF_width_to_rstrlen(int fontid, const char *str, const size_t str_len, float width, float *r_width)
void BLF_state_print(int fontid)
static int blf_search_available()
void BLF_color4ub(int fontid, uchar r, uchar g, uchar b, uchar alpha)
void BLF_color4ubv(int fontid, const uchar rgba[4])
int BLF_load(const char *filepath)
void BLF_size(int fontid, float size)
void BLF_buffer_state_free(BLFBufferState *buffer_state)
void BLF_draw_svg_icon(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)
int BLF_draw_mono(int fontid, const char *str, const size_t str_len, int cwidth, int tab_columns)
void BLF_enable(int fontid, FontFlags flag)
void BLF_addref_id(int fontid)
void BLF_buffer_state_pop(BLFBufferState *buffer_state)
void BLF_aspect(int fontid, float x, float y, float z)
void blf_draw_buffer__start(FontBLF *font)
bool BLF_has_glyph(int fontid, uint unicode)
static FontBLF * blf_get(int fontid)
blender::Vector< blender::Bounds< int > > BLF_str_selection_boxes(int fontid, const char *str, size_t str_len, size_t sel_start, size_t sel_length)
float BLF_width(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
bool BLF_is_loaded(const char *filepath)
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
size_t BLF_width_to_strlen(int fontid, const char *str, const size_t str_len, float width, float *r_width)
void BLF_boundbox(int fontid, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
bool BLF_is_loaded_id(int fontid)
blender::Vector< blender::StringRef > BLF_string_wrap(int fontid, blender::StringRef str, const int max_pixel_width, BLFWrapMode mode)
void BLF_draw_buffer(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
void BLF_color3ub(int fontid, uchar r, uchar g, uchar b)
void BLF_unload(const char *filepath)
void BLF_color3ubv_alpha(int fontid, const uchar rgb[3], uchar alpha)
void BLF_color3f(int fontid, float r, float g, float b)
float BLF_fixed_width(int fontid)
char * BLF_display_name_from_id(int fontid)
void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha)
void BLF_color4fv(int fontid, const float rgba[4])
#define BLF_RESULT_CHECK_INIT(r_info)
static int blf_search_by_filepath(const char *filepath)
int BLF_str_offset_to_cursor(int fontid, const char *str, const size_t str_len, const size_t str_offset, const int cursor_width)
char * BLF_display_name_from_file(const char *filepath)
bool BLF_get_vfont_metrics(int fontid, float *ascend_ratio, float *em_ratio, float *scale)
void BLF_shadow_offset(int fontid, int x, int y)
static void blf_draw_gpu__end(const FontBLF *font)
int BLF_width_max(int fontid)
int BLF_ascender(int fontid)
void BLF_batch_draw_begin()
BLFBufferState * BLF_buffer_state_push(int fontid)
int BLF_load_mem_unique(const char *name, const uchar *mem, int mem_size)
bool BLF_bounds_max(int fontid, rctf *r_bounds)
void BLF_boundbox_foreach_glyph(int fontid, const char *str, size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data)
void BLF_rotation(int fontid, float angle)
void BLF_metrics_attach(const int fontid, const uchar *mem, const int mem_size)
void BLF_batch_draw_end()
static void blf_draw_gpu__start(const FontBLF *font)
int BLF_glyph_advance(int fontid, const char *str)
static int blf_search_by_mem_name(const char *mem_name)
size_t BLF_str_offset_from_cursor_position(int fontid, const char *str, size_t str_len, int location_x)
int BLF_descender(int fontid)
FontBLF * global_font[BLF_MAX_FONT]
int BLF_default_weight(int fontid)
void BLF_draw(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
void BLF_batch_draw_flush()
blender::Array< uchar > BLF_svg_icon_bitmap(uint icon_id, float size, int *r_width, int *r_height, bool multicolor, blender::FunctionRef< void(std::string &)> edit_source_cb)
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4])
void BLF_disable(int fontid, FontFlags flag)
void BLF_width_and_height(int fontid, const char *str, const size_t str_len, float *r_width, float *r_height)
bool BLF_unload_id(int fontid)
bool BLF_is_builtin(int fontid)
bool BLF_is_loaded_mem(const char *name)
bool BLF_str_offset_to_glyph_bounds(int fontid, const char *str, size_t str_offset, rcti *r_glyph_bounds)
void BLF_buffer(int fontid, float *fbuf, uchar *cbuf, int w, int h, const ColorSpace *colorspace)
int BLF_load_unique(const char *filepath)
bool BLF_character_to_curves(int fontid, uint unicode, ListBase *nurbsbase, const float scale, bool use_fallback, float *r_advance)
void BLF_color4f(int fontid, float r, float g, float b, float a)
static blender::Mutex g_blf_load_mutex
bool BLF_has_variable_weight(int fontid)
void blf_draw_buffer__end()
void BLF_buffer_col(int fontid, const float srgb_color[4])
void BLF_character_weight(int fontid, int weight)
int BLF_height_max(int fontid)
void BLF_position(int fontid, float x, float y, float z)
float BLF_height(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
int BLF_load_mem(const char *name, const uchar *mem, int mem_size)
void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode)
size_t blf_str_offset_from_cursor_position(FontBLF *font, const char *str, size_t str_len, int location_x)
void blf_str_offset_to_glyph_bounds(FontBLF *font, const char *str, size_t str_offset, rcti *r_glyph_bounds)
size_t blf_font_width_to_rstrlen(FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
int blf_font_ascender(FontBLF *font)
blender::Vector< blender::StringRef > blf_font_string_wrap(FontBLF *font, blender::StringRef str, int max_pixel_width, BLFWrapMode mode)
int blf_font_draw_mono(FontBLF *font, const char *str, const size_t str_len, const int cwidth, const int tab_columns)
float blf_font_width(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
bool blf_ensure_face(FontBLF *font)
bool blf_font_bounds_max(FontBLF *font, rctf *r_bounds)
void blf_font_draw_buffer(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
void blf_font_free(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)
bool blf_font_size(FontBLF *font, float size)
float blf_font_fixed_width(FontBLF *font)
float blf_font_height(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
uint blf_get_char_index(FontBLF *font, const uint charcode)
int blf_font_width_max(FontBLF *font)
blender::Array< uchar > blf_svg_icon_bitmap(FontBLF *font, const uint icon_id, const float size, int *r_width, int *r_height, const bool multicolor, blender::FunctionRef< void(std::string &)> edit_source_cb)
void blf_draw_svg_icon(FontBLF *font, const uint icon_id, const float x, const float y, const float size, const float color[4], const float outline_alpha, const bool multicolor, blender::FunctionRef< void(std::string &)> edit_source_cb)
void blf_font_boundbox__wrap(FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
void blf_font_boundbox(FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
int blf_font_glyph_advance(FontBLF *font, const char *str)
char * blf_display_name(FontBLF *font)
FontBLF * blf_font_new_from_mem(const char *mem_name, const uchar *mem, const size_t mem_size)
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)
void blf_font_attach_from_mem(FontBLF *font, const uchar *mem, const size_t mem_size)
size_t blf_font_width_to_strlen(FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
int blf_font_descender(FontBLF *font)
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)
void blf_font_draw(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
FontBLF * blf_font_new_from_filepath(const char *filepath)
void blf_font_draw_buffer__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
int blf_font_height_max(FontBLF *font)
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)
void blf_font_draw__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
bool blf_character_to_curves(FontBLF *font, uint unicode, ListBase *nurbsbase, const float scale, bool use_fallback, float *r_advance)
void blf_glyph_cache_clear(FontBLF *font)
#define BLF_VARIATION_AXIS_WEIGHT
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
std::atomic< uint32_t > reference_count
unsigned char shadow_color[4]
const ColorSpace * colorspace
unsigned char col_char[4]