Blender V4.3
blf_internal.hh File Reference
#include "BLI_array.hh"
#include "BLI_bounds_types.hh"
#include "BLI_function_ref.hh"
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"

Go to the source code of this file.

Macros

#define BLF_MAX_FONT   64
 
#define BLF_SUBPIXEL_POSITION
 
#define BLF_SUBPIXEL_AA
 
#define BLF_CACHE_MAX_FACES   4
 
#define BLF_CACHE_MAX_SIZES   8
 
#define BLF_CACHE_BYTES   400000
 
#define BLF_ICON_OFFSET   0x100000L
 
#define BLF_DPI   72
 

Functions

void blf_batch_draw_begin (FontBLF *font)
 
void blf_batch_draw ()
 
char * blf_dir_metrics_search (const char *filepath)
 
int blf_font_init ()
 
void blf_font_exit ()
 
bool blf_font_id_is_valid (int fontid)
 
uint blf_get_char_index (FontBLF *font, uint charcode)
 
bool blf_ensure_face (FontBLF *font)
 
void blf_ensure_size (FontBLF *font)
 
void blf_draw_buffer__start (FontBLF *font)
 
void blf_draw_buffer__end ()
 
FontBLFblf_font_new_from_filepath (const char *filepath)
 
FontBLFblf_font_new_from_mem (const char *mem_name, const unsigned char *mem, size_t mem_size)
 
void blf_font_attach_from_mem (FontBLF *font, const unsigned char *mem, size_t mem_size)
 
bool blf_font_size (FontBLF *font, float size)
 
void blf_font_draw (FontBLF *font, const char *str, size_t str_len, ResultBLF *r_info)
 
void blf_font_draw__wrap (FontBLF *font, const char *str, size_t str_len, ResultBLF *r_info)
 
void blf_draw_svg_icon (FontBLF *font, uint icon_id, float x, float y, float size, const float color[4]=nullptr, float outline_alpha=1.0f, bool multicolor=false, blender::FunctionRef< void(std::string &)> edit_source_cb=nullptr)
 
blender::Array< ucharblf_svg_icon_bitmap (FontBLF *font, uint icon_id, float size, int *r_width, int *r_height, bool multicolor=false, blender::FunctionRef< void(std::string &)> edit_source_cb=nullptr)
 
blender::Vector< blender::StringRefblf_font_string_wrap (FontBLF *font, blender::StringRef str, int max_pixel_width)
 
int blf_font_draw_mono (FontBLF *font, const char *str, size_t str_len, int cwidth, int tab_columns)
 
void blf_font_draw_buffer (FontBLF *font, const char *str, size_t str_len, ResultBLF *r_info)
 
void blf_font_draw_buffer__wrap (FontBLF *font, const char *str, size_t str_len, ResultBLF *r_info)
 
size_t blf_font_width_to_strlen (FontBLF *font, const char *str, size_t str_len, int width, int *r_width)
 
size_t blf_font_width_to_rstrlen (FontBLF *font, const char *str, size_t str_len, int width, int *r_width)
 
void blf_font_boundbox (FontBLF *font, const char *str, size_t str_len, rcti *r_box, ResultBLF *r_info)
 
void blf_font_boundbox__wrap (FontBLF *font, const char *str, size_t str_len, rcti *r_box, ResultBLF *r_info)
 
void blf_font_width_and_height (FontBLF *font, const char *str, size_t str_len, float *r_width, float *r_height, ResultBLF *r_info)
 
float blf_font_width (FontBLF *font, const char *str, size_t str_len, ResultBLF *r_info)
 
float blf_font_height (FontBLF *font, const char *str, size_t str_len, ResultBLF *r_info)
 
float blf_font_fixed_width (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)
 
void blf_font_boundbox_foreach_glyph (FontBLF *font, const char *str, size_t str_len, bool(*user_fn)(const char *str, size_t str_step_ofs, const rcti *bounds, void *user_data), void *user_data)
 
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)
 
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)
 
int blf_str_offset_to_cursor (FontBLF *font, const char *str, size_t str_len, size_t str_offset, int cursor_width)
 
void blf_font_free (FontBLF *font)
 
GlyphCacheBLFblf_glyph_cache_acquire (FontBLF *font)
 
void blf_glyph_cache_release (FontBLF *font)
 
void blf_glyph_cache_clear (FontBLF *font)
 
GlyphBLFblf_glyph_ensure (FontBLF *font, GlyphCacheBLF *gc, uint charcode, uint8_t subpixel=0)
 
GlyphBLFblf_glyph_ensure_subpixel (FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int32_t pen_x)
 
GlyphBLFblf_glyph_ensure_icon (GlyphCacheBLF *gc, uint icon_id, bool color=false, blender::FunctionRef< void(std::string &)> edit_source_cb=nullptr)
 
float blf_character_to_curves (FontBLF *font, unsigned int unicode, ListBase *nurbsbase, const float scale)
 
void blf_glyph_draw (FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int x, int y)
 

Variables

FontBLFglobal_font [BLF_MAX_FONT]
 

Macro Definition Documentation

◆ BLF_CACHE_BYTES

#define BLF_CACHE_BYTES   400000

Maximum number of bytes to use for cached data nodes. 0 is default of 200,000.

Definition at line 45 of file blf_internal.hh.

Referenced by blf_font_init().

◆ BLF_CACHE_MAX_FACES

#define BLF_CACHE_MAX_FACES   4

Maximum number of opened FT_Face objects managed by cache. 0 is default of 2.

Definition at line 41 of file blf_internal.hh.

Referenced by blf_font_init().

◆ BLF_CACHE_MAX_SIZES

#define BLF_CACHE_MAX_SIZES   8

Maximum number of opened FT_Size objects managed by cache. 0 is default of 4

Definition at line 43 of file blf_internal.hh.

Referenced by blf_font_init().

◆ BLF_DPI

#define BLF_DPI   72

We assume square pixels at a fixed DPI of 72, scaling only the size. Therefore font size = points = pixels, i.e. a size of 20 will result in a 20-pixel EM square. Although we could use the actual monitor DPI instead, we would then have to scale the size to cancel that out. Other libraries like Skia use this same fixed value.

Definition at line 59 of file blf_internal.hh.

Referenced by blf_ensure_size(), and blf_font_size().

◆ BLF_ICON_OFFSET

#define BLF_ICON_OFFSET   0x100000L

Offset from icon id to Unicode Supplementary Private Use Area-B, added with Unicode 2.0. 65,536 code-points at U+100000..U+10FFFF.

Definition at line 51 of file blf_internal.hh.

Referenced by blf_glyph_cache_add_svg(), and blf_glyph_ensure_icon().

◆ BLF_MAX_FONT

#define BLF_MAX_FONT   64

Max number of FontBLFs in memory. Take care that every font has a glyph cache per size/dpi, so we don't need load the same font with different size, just load one and call BLF_size.

Definition at line 28 of file blf_internal.hh.

Referenced by BLF_cache_clear(), BLF_exit(), blf_get(), blf_glyph_index_from_charcode(), BLF_init(), BLF_reset_fonts(), blf_search_available(), blf_search_by_filepath(), blf_search_by_mem_name(), BLF_unload(), and BLF_unload_all().

◆ BLF_SUBPIXEL_AA

#define BLF_SUBPIXEL_AA

If enabled, glyphs are rendered at multiple horizontal subpixel positions.

Definition at line 38 of file blf_internal.hh.

◆ BLF_SUBPIXEL_POSITION

#define BLF_SUBPIXEL_POSITION

If enabled, glyphs positions are on 64ths of a pixel. Disabled, they are on whole pixels.

Definition at line 33 of file blf_internal.hh.

Function Documentation

◆ blf_batch_draw()

◆ blf_batch_draw_begin()

◆ blf_character_to_curves()

float blf_character_to_curves ( FontBLF * font,
unsigned int unicode,
ListBase * nurbsbase,
const float scale )

Convert a character's outlines into curves.

Definition at line 1883 of file blf_glyph.cc.

References blf_glyph_to_curves(), blf_glyphslot_ensure_outline(), and float.

Referenced by BLF_character_to_curves().

◆ blf_dir_metrics_search()

char * blf_dir_metrics_search ( const char * filepath)

Some font have additional file with metrics information, in general, the extension of the file is: .afm or .pfm

Definition at line 30 of file blf_dir.cc.

References BLI_exists(), BLI_strdup(), BLI_strnlen(), and MEM_freeN().

Referenced by blf_ensure_face().

◆ blf_display_name()

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().

◆ blf_draw_buffer__end()

void blf_draw_buffer__end ( )

Definition at line 960 of file blf.cc.

Referenced by BLF_draw_buffer().

◆ blf_draw_buffer__start()

◆ blf_draw_svg_icon()

void blf_draw_svg_icon ( FontBLF * font,
uint icon_id,
float x,
float y,
float size,
const float color[4] = nullptr,
float outline_alpha = 1.0f,
bool multicolor = false,
blender::FunctionRef< void(std::string &)> edit_source_cb = nullptr )

◆ blf_ensure_face()

◆ blf_ensure_size()

◆ blf_font_ascender()

int blf_font_ascender ( FontBLF * font)

Definition at line 1469 of file blf_font.cc.

References blf_ensure_size(), and ft_pix_to_int().

Referenced by BLF_ascender().

◆ blf_font_attach_from_mem()

void blf_font_attach_from_mem ( FontBLF * font,
const unsigned char * mem,
size_t mem_size )

Definition at line 1995 of file blf_font.cc.

References blf_ensure_face().

Referenced by BLF_metrics_attach().

◆ blf_font_boundbox()

void blf_font_boundbox ( FontBLF * font,
const char * str,
size_t str_len,
rcti * r_box,
ResultBLF * r_info )

◆ blf_font_boundbox__wrap()

void blf_font_boundbox__wrap ( FontBLF * font,
const char * str,
size_t str_len,
rcti * r_box,
ResultBLF * r_info )

◆ blf_font_boundbox_foreach_glyph()

void blf_font_boundbox_foreach_glyph ( FontBLF * font,
const char * str,
size_t str_len,
bool(* user_fn )(const char *str, size_t str_step_ofs, const rcti *bounds, void *user_data),
void * user_data )

◆ blf_font_descender()

int blf_font_descender ( FontBLF * font)

Definition at line 1463 of file blf_font.cc.

References blf_ensure_size(), and ft_pix_to_int().

Referenced by BLF_descender().

◆ blf_font_draw()

void blf_font_draw ( FontBLF * font,
const char * str,
size_t str_len,
ResultBLF * r_info )

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().

◆ blf_font_draw__wrap()

void blf_font_draw__wrap ( FontBLF * font,
const char * str,
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().

◆ blf_font_draw_buffer()

void blf_font_draw_buffer ( FontBLF * font,
const char * str,
size_t str_len,
ResultBLF * r_info )

◆ blf_font_draw_buffer__wrap()

void blf_font_draw_buffer__wrap ( FontBLF * font,
const char * str,
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().

◆ blf_font_draw_mono()

int blf_font_draw_mono ( FontBLF * font,
const char * str,
size_t str_len,
int cwidth,
int tab_columns )

◆ blf_font_exit()

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().

◆ blf_font_fixed_width()

float blf_font_fixed_width ( FontBLF * font)

◆ blf_font_free()

◆ blf_font_height()

float blf_font_height ( FontBLF * font,
const char * str,
size_t str_len,
ResultBLF * r_info )

◆ blf_font_height_max()

int blf_font_height_max ( FontBLF * font)

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().

◆ blf_font_id_is_valid()

bool blf_font_id_is_valid ( int fontid)

Definition at line 109 of file blf.cc.

References blf_get().

Referenced by BLF_default_set().

◆ blf_font_init()

◆ blf_font_new_from_filepath()

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().

◆ blf_font_new_from_mem()

FontBLF * blf_font_new_from_mem ( const char * mem_name,
const unsigned char * mem,
size_t mem_size )

Definition at line 1990 of file blf_font.cc.

References blf_font_new_impl().

Referenced by BLF_load_mem_unique().

◆ blf_font_size()

bool blf_font_size ( FontBLF * font,
float size )

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().

◆ blf_font_string_wrap()

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().

◆ blf_font_width()

float blf_font_width ( FontBLF * font,
const char * str,
size_t str_len,
ResultBLF * r_info )

◆ blf_font_width_and_height()

void blf_font_width_and_height ( FontBLF * font,
const char * str,
size_t str_len,
float * r_width,
float * r_height,
ResultBLF * r_info )

◆ blf_font_width_max()

int blf_font_width_max ( FontBLF * font)

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().

◆ blf_font_width_to_rstrlen()

size_t blf_font_width_to_rstrlen ( FontBLF * font,
const char * str,
size_t str_len,
int width,
int * r_width )

◆ blf_font_width_to_strlen()

size_t blf_font_width_to_strlen ( FontBLF * font,
const char * str,
size_t str_len,
int width,
int * r_width )

◆ blf_get_char_index()

uint blf_get_char_index ( FontBLF * font,
uint charcode )

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().

◆ blf_glyph_cache_acquire()

◆ blf_glyph_cache_clear()

void blf_glyph_cache_clear ( FontBLF * font)

Definition at line 164 of file blf_glyph.cc.

References lock.

Referenced by BLF_cache_clear(), and blf_font_free().

◆ blf_glyph_cache_release()

◆ blf_glyph_draw()

◆ blf_glyph_ensure()

GlyphBLF * blf_glyph_ensure ( FontBLF * font,
GlyphCacheBLF * gc,
uint charcode,
uint8_t subpixel = 0 )

◆ blf_glyph_ensure_icon()

GlyphBLF * blf_glyph_ensure_icon ( GlyphCacheBLF * gc,
uint icon_id,
bool color = false,
blender::FunctionRef< void(std::string &)> edit_source_cb = nullptr )

◆ blf_glyph_ensure_subpixel()

◆ blf_str_offset_from_cursor_position()

size_t blf_str_offset_from_cursor_position ( FontBLF * font,
const char * str,
size_t str_len,
int location_x )

◆ blf_str_offset_to_cursor()

int blf_str_offset_to_cursor ( FontBLF * font,
const char * str,
size_t str_len,
size_t str_offset,
int cursor_width )

◆ blf_str_offset_to_glyph_bounds()

void blf_str_offset_to_glyph_bounds ( FontBLF * font,
const char * str,
size_t str_offset,
rcti * r_glyph_bounds )

◆ blf_str_selection_boxes()

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 )

◆ blf_svg_icon_bitmap()

Variable Documentation

◆ global_font