40#define BLF_RESULT_CHECK_INIT(r_info) \
42 memset(r_info, 0, sizeof(*(r_info))); \
115 if ((font ==
nullptr) || (font->
mem_name ==
nullptr)) {
131 if ((font ==
nullptr) || (font->
filepath ==
nullptr)) {
174 return blf_get(fontid) !=
nullptr;
195 printf(
"Too many fonts!!!\n");
202 printf(
"Can't find font: %s\n", filepath);
209 printf(
"Can't load font: %s\n", filepath);
241 printf(
"Too many fonts!!!\n");
246 printf(
"Can't load font: %s from memory!!\n", name);
252 printf(
"Can't load font: %s from memory!!\n", name);
266 if (font ==
nullptr || font->
filepath ==
nullptr) {
336 font->
flags &= ~flag;
370 for (
int i = 0; i < int(font->
variations->num_axis); i++) {
410 if (remainder > 0.4f && remainder < 0.6f) {
411 if (remainder < 0.5f) {
420 if (remainder > 0.4f && remainder < 0.6f) {
421 if (remainder < 0.5f) {
430 if (remainder > 0.4f && remainder < 0.6f) {
431 if (remainder < 0.5f) {
459 font->
color[0] = rgba[0];
460 font->
color[1] = rgba[1];
461 font->
color[2] = rgba[2];
462 font->
color[3] = rgba[3];
471 font->
color[0] = rgb[0];
472 font->
color[1] = rgb[1];
473 font->
color[2] = rgb[2];
474 font->
color[3] = alpha;
491 font->
color[3] = alpha;
503 font->
color[3] = 255;
518 const float rgba[4] = {r, g,
b, a};
532 const float rgba[4] = {r, g,
b, 1.0f};
591 if (str_len == 0 ||
str[0] ==
'\0') {
610 int fontid,
const char *
str,
const size_t str_len,
int char_width,
int tab_columns)
612 if (str_len == 0 ||
str[0] ==
'\0') {
632 const float color[4],
677 return blf_svg_icon_bitmap(font, icon_id, size, r_width, r_height, multicolor, edit_source_cb);
680 UNUSED_VARS(icon_id, size, r_width, r_height, multicolor, edit_source_cb);
705 FunctionRef<
void(
int index,
size_t byte_offset,
int byte_len,
int advance_x)> callback)
708 if (font !=
nullptr) {
728 rcti *r_glyph_bounds)
740 const size_t str_len,
741 const size_t str_offset,
742 const int cursor_width)
752 int fontid,
const char *
str,
size_t str_len,
size_t sel_start,
size_t sel_length)
762 int fontid,
const char *
str,
const size_t str_len,
float width,
float *r_width)
772 *r_width =
float(width_result) * xa;
784 int fontid,
const char *
str,
const size_t str_len,
float width,
float *r_width)
794 *r_width =
float(width_result) * xa;
806 int fontid,
const char *
str,
const size_t str_len,
rcti *r_box,
ResultBLF *r_info)
823 int fontid,
const char *
str,
const size_t str_len,
float *r_width,
float *r_height)
831 *r_width = *r_height = 0.0f;
997 BLI_assert(channel_count == 1 || channel_count == 4);
1026 BLFBufferState *buffer_state = MEM_new<BLFBufferState>(__func__);
1027 buffer_state->
fontid = fontid;
1028 buffer_state->
font = font;
1030 return buffer_state;
1039 if (font == buffer_state->
font) {
1054 MEM_delete(buffer_state);
1105 const int max_pixel_width,
1120 char *name =
nullptr;
1121 FT_Library ft_library;
1122 if (FT_Init_FreeType(&ft_library) == FT_Err_Ok) {
1124 if (FT_New_Face(ft_library, filepath, 0, &face) == FT_Err_Ok) {
1125 if (face->family_name) {
1126 name =
BLI_sprintfN(
"%s %s", face->family_name, face->style_name);
1130 FT_Done_FreeType(ft_library);
1159 const bool complete_font = (font->
face->ascender != 0) && (font->
face->descender != 0) &&
1160 (font->
face->ascender != font->
face->descender);
1162 if (complete_font) {
1165 *ascend_ratio =
float(font->
face->ascender) / (font->
face->ascender - font->
face->descender);
1173 if (font->
face->bbox.yMax != font->
face->bbox.yMin) {
1176 if (complete_font) {
1177 *em_ratio =
float(font->
face->ascender - font->
face->descender) /
1178 (font->
face->bbox.yMax - font->
face->bbox.yMin);
1190 ListBaseT<Nurb> *nurbsbase,
1201 font, unicode, nurbsbase,
scale, use_fallback, r_advance, r_bounds);
1209 printf(
"fontid %d %p\n", fontid,
static_cast<void *
>(font));
1214 printf(
" aspect: (%d) %.6f %.6f %.6f\n",
1221 printf(
"fontid %d (nullptr)\n", fontid);
#define BLF_VFONT_METRICS_EM_RATIO_DEFAULT
#define BLF_VFONT_METRICS_SCALE_DEFAULT
#define BLF_VFONT_METRICS_ASCEND_RATIO_DEFAULT
File and directory operations.
#define BLF_RESULT_CHECK_INIT(r_info)
#define BLF_VARIATION_AXIS_WEIGHT
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
float3x3 scale(float3x3 mat, float2 scale)
int blf_font_height_max(FontBLF *font)
static int blf_search_available()
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BLF_boundbox(int fontid, const char *str, size_t str_len, rcti *r_box, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
bool BLF_is_loaded_id(int fontid) ATTR_WARN_UNUSED_RESULT
int BLF_glyph_advance(int fontid, const char *str)
bool blf_character_to_curves(FontBLF *font, uint unicode, ListBaseT< Nurb > *nurbsbase, const float scale, bool use_fallback, float *r_advance, rctf *r_bounds)
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_color3ubv_alpha(int fontid, const unsigned char rgb[3], unsigned char alpha)
void BLF_shadow_offset(int fontid, int x, int y)
static FontBLF * blf_get(int fontid)
void BLF_aspect(int fontid, float x, float y, float z)
void BLF_position(int fontid, float x, float y, float z)
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
bool blf_ensure_face(FontBLF *font)
void BLF_batch_draw_flush()
MINLINE void copy_v3_v3(float r[3], const float a[3])
int BLF_width_max(int fontid) ATTR_WARN_UNUSED_RESULT
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
void blf_font_draw_buffer__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
MINLINE int round_fl_to_int(float a)
void BLF_draw_svg_icon(uint icon_id, float x, float y, float size, const float color[4]=nullptr, float outline_alpha=1.0f, bool multicolor=false, FunctionRef< void(std::string &)> edit_source_cb=nullptr)
void BLF_color3ub(int fontid, unsigned char r, unsigned char g, unsigned char b)
void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode=BLFWrapMode::Minimal)
uint blf_get_char_index(FontBLF *font, const uint charcode)
void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int channel_count, const ColorSpace *colorspace)
int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
int blf_font_draw_mono(FontBLF *font, const char *str, const size_t str_len, const int char_width, const int tab_columns)
bool BLF_get_vfont_metrics(int fontid, float *ascend_ratio, float *em_ratio, float *scale)
size_t BLF_width_to_strlen(int fontid, const char *str, size_t str_len, float width, float *r_width) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
float blf_font_fixed_width(FontBLF *font)
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void GPU_matrix_scale_3fv(const float vec[3])
void BLF_default_set(int fontid)
void BLF_batch_draw_begin()
Vector< Bounds< int > > blf_str_selection_boxes(FontBLF *font, const char *str, size_t str_len, size_t sel_start, size_t sel_length)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
void blf_font_free(FontBLF *font)
bool BLF_is_loaded_mem(const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void blf_font_boundbox(FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
void blf_font_boundbox__wrap(FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
void GPU_matrix_rotate_2d(float deg)
int bool BLF_is_loaded(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLF_character_weight(int fontid, int weight)
void BLF_addref_id(int fontid)
bool BLF_bounds_max(int fontid, rctf *r_bounds) ATTR_NONNULL(2)
void BLF_disable(int fontid, FontFlags flag)
void BLF_color4f(int fontid, float r, float g, float b, float a)
float blf_font_height(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
void blf_font_info_foreach_glyph(FontBLF *font, const char *str, size_t str_len, FunctionRef< void(int index, size_t byte_offset, int byte_len, int advance_x)> callback)
void blf_str_offset_to_glyph_bounds(FontBLF *font, const char *str, size_t str_offset, rcti *r_glyph_bounds)
Vector< StringRef > blf_font_string_wrap(FontBLF *font, StringRef str, int max_pixel_width, BLFWrapMode mode)
size_t blf_font_width_to_strlen(FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
void BLF_metrics_attach(int fontid, const unsigned char *mem, int mem_size) ATTR_NONNULL(2)
void blf_draw_buffer__end()
void blf_font_draw_buffer(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
void BLF_size(int fontid, float size)
FontBLF * blf_font_new_from_mem(const char *mem_name, const uchar *mem, const size_t mem_size)
int BLF_load(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool BLF_str_offset_to_glyph_bounds(int fontid, const char *str, size_t str_offset, rcti *r_glyph_bounds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2
int blf_font_descender(FontBLF *font)
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], const ColorSpace *colorspace)
bool blf_font_bounds_max(FontBLF *font, rctf *r_bounds)
int blf_font_glyph_advance(FontBLF *font, const char *str)
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_color3ubv(int fontid, const unsigned char rgb[3])
float BLF_height(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
FontBLF * blf_font_new_from_filepath(const char *filepath)
static void blf_draw_gpu__start(const FontBLF *font)
void BLF_buffer_state_pop(BLFBufferState *buffer_state)
int BLF_default_weight(int fontid) ATTR_WARN_UNUSED_RESULT
bool(*)(const char *str, size_t str_step_ofs, const rcti *bounds, void *user_dataconst) BLF_GlyphBoundsFn
void blf_font_draw__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
size_t BLF_width_to_rstrlen(int fontid, const char *str, size_t str_len, float width, float *r_width) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
static int blf_search_by_filepath(const char *filepath)
Vector< StringRef > BLF_string_wrap(int fontid, StringRef str, const int max_pixel_width, BLFWrapMode mode=BLFWrapMode::Minimal)
float BLF_fixed_width(int fontid) ATTR_WARN_UNUSED_RESULT
int void BLF_unload(const char *filepath) ATTR_NONNULL(1)
bool BLF_has_variable_weight(int fontid) ATTR_WARN_UNUSED_RESULT
bool BLF_has_glyph(int fontid, unsigned int unicode) ATTR_WARN_UNUSED_RESULT
static int blf_search_by_mem_name(const char *mem_name)
void BLF_batch_draw_end()
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
int BLF_ascender(int fontid) ATTR_WARN_UNUSED_RESULT
void blf_font_draw(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL(1
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
void blf_font_boundbox_foreach_glyph(FontBLF *font, const char *str, const size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data)
BLFBufferState * BLF_buffer_state_push(int fontid)
static void blf_draw_gpu__end(const FontBLF *font)
void BLF_state_print(int fontid)
void BLF_buffer_col(int fontid, const float srgb_color[4]) ATTR_NONNULL(2)
size_t blf_str_offset_from_cursor_position(FontBLF *font, const char *str, size_t str_len, int location_x)
void BLF_color4ub(int fontid, unsigned char r, unsigned char g, unsigned char b, unsigned char alpha)
int BLF_draw_mono(int fontid, const char *str, size_t str_len, int char_width, int tab_columns) ATTR_NONNULL(2)
FontBLF * global_font[BLF_MAX_FONT]
bool BLF_character_to_curves(int fontid, unsigned int unicode, ListBaseT< Nurb > *nurbsbase, const float scale, bool use_fallback, float *r_advance, rctf *r_bounds)
int blf_font_width_max(FontBLF *font)
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
void BLF_color3f(int fontid, float r, float g, float b)
char * BLF_display_name_from_file(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
void blf_draw_svg_icon(FontBLF *font, const uint icon_id, const float size, const float color[4], const float outline_alpha, const bool multicolor, FunctionRef< void(std::string &)> edit_source_cb)
bool int BLF_str_offset_to_cursor(int fontid, const char *str, size_t str_len, size_t str_offset, int cursor_width)
int BLF_load_unique(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Array< uchar > blf_svg_icon_bitmap(FontBLF *font, const uint icon_id, const float size, int *r_width, int *r_height, const bool multicolor, FunctionRef< void(std::string &)> edit_source_cb)
Array< uchar > BLF_svg_icon_bitmap(uint icon_id, float size, int *r_width, int *r_height, bool multicolor=false, FunctionRef< void(std::string &)> edit_source_cb=nullptr)
size_t BLF_str_offset_from_cursor_position(int fontid, const char *str, size_t str_len, int location_x) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
void BLF_boundbox_foreach_glyph(int fontid, const char *str, size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data) ATTR_NONNULL(2)
void BLF_draw_buffer(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
void BLF_buffer_state_free(BLFBufferState *buffer_state)
size_t blf_font_width_to_rstrlen(FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
MINLINE void copy_v4_v4(float r[4], const float a[4])
void BLF_info_foreach_glyph(int fontid, const char *str, size_t str_len, FunctionRef< void(int index, size_t byte_offset, int byte_len, int advance_x)> callback)
void GPU_matrix_translate_3f(float x, float y, float z)
bool blf_font_size(FontBLF *font, float size)
bool BLF_is_builtin(int fontid)
void blf_glyph_cache_clear(FontBLF *font)
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
float blf_font_width(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
void blf_draw_buffer__start(FontBLF *font)
void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha)
void BLF_rotation(int fontid, float angle)
char * BLF_display_name_from_id(int fontid)
void blf_font_attach_from_mem(FontBLF *font, const uchar *mem, const size_t mem_size)
void BLF_enable(int fontid, FontFlags flag)
void BLF_color4fv(int fontid, const float rgba[4])
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
ocio::ColorSpace ColorSpace
Vector< Bounds< int > > BLF_str_selection_boxes(int fontid, const char *str, size_t str_len, size_t sel_start, size_t sel_length)
int blf_font_ascender(FontBLF *font)
static Mutex g_blf_load_mutex
bool BLF_unload_id(int fontid)
char * blf_display_name(FontBLF *font)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
unsigned char shadow_color[4]
std::atomic< uint32_t > reference_count
const ColorSpace * colorspace
unsigned char col_char[4]