23#include FT_MULTIPLE_MASTERS_H
24#include FT_TRUETYPE_IDS_H
25#include FT_TRUETYPE_TABLES_H
56# define FT_New_Face FT_New_Face__win32_compat
94 FT_Face face =
static_cast<FT_Face
>(
object);
110 int err = FT_Err_Cannot_Open_Resource;
114 err = FT_New_Face(lib, font->
filepath, 0, face);
116 else if (font->
mem) {
117 err = FT_New_Memory_Face(
118 lib,
static_cast<const FT_Byte *
>(font->
mem), FT_Long(font->
mem_size), 0, face);
121 if (err == FT_Err_Ok) {
123 font->
face->generic.data = font;
128 err = FT_Err_Cannot_Open_Resource;
144 FT_Size size =
static_cast<FT_Size
>(
object);
167 FT_Long
scaled = FT_MulFix(value, font->
ft_size->metrics.x_scale);
171 if (font->
ft_size->metrics.x_ppem < 25) {
243 if (mat_changed || font_changed || shader_changed) {
277 int remain = gc->
bitmap_len - bitmap_len_landed;
278 int offset_x = bitmap_len_landed % tex_width;
279 int offset_y = bitmap_len_landed / tex_width;
283 int remain_row = tex_width - offset_x;
284 int width = remain > remain_row ? remain_row : remain;
295 bitmap_len_landed += width;
370 if (FT_HAS_KERNING(font) && g_prev) {
381 FT_Get_Kerning(font->
face, g_prev->
idx, g->
idx, FT_KERNING_UNSCALED, &delta);
402 const size_t str_len,
414#ifdef BLF_SUBPIXEL_POSITION
422#ifdef BLF_SUBPIXEL_AA
475 if (
step.g !=
nullptr) {
480 step.pen_x_right +=
step.g->advance_x;
483 step.base_ymax_accum =
step.g->box_ymax;
484 step.base_ymin_accum =
step.g->box_ymin;
501 step.pen_x_right = pen_x_prev;
505 const int mark_center_offset =
step.g->pos[0] +
step.g->dims[0] / 2;
510 if (
step.g_kerning) {
513 const ft_pix mark_height = mark_ymax - mark_ymin;
514 const ft_pix base_mid = (
step.g_kerning->box_ymin +
step.g_kerning->box_ymax) / 2;
515 const ft_pix mark_mid = (mark_ymin + mark_ymax) / 2;
519 if (mark_mid > base_mid) {
521 step.base_ymax_accum += y_gap;
522 step.offset_y =
step.base_ymax_accum - mark_ymin;
524 if ((y_gap > 0) != (
step.offset_y > 0)) {
526 step.base_ymax_accum += correction;
527 step.offset_y += correction;
529 step.base_ymax_accum += mark_height;
533 step.base_ymin_accum -= y_gap;
534 step.offset_y =
step.base_ymin_accum - mark_ymax;
536 if ((y_gap > 0) == (
step.offset_y > 0)) {
537 step.base_ymin_accum -=
step.offset_y;
540 step.base_ymin_accum -= mark_height;
556 step.g_kerning =
nullptr;
558 step.pen_x_right = 0;
561 step.base_ymax_accum = 0;
562 step.base_ymin_accum = 0;
575 const size_t str_len,
578 if (is_utf8_valid == -1) {
581 return is_utf8_valid;
593 const size_t str_len,
634 const size_t str_len,
635 const int char_width,
636 const int tab_columns)
640 ft_pix pen_x = 0, pen_y = 0;
649 while ((i < str_len) &&
str[i]) {
652 if (g ==
nullptr) [[unlikely]] {
658 const int col =
UNLIKELY(g->
c ==
'\t') ? (tab_columns - (columns % tab_columns)) :
661 pen_x += char_width_fpx * col;
674 const float color[4],
675 const float outline_alpha,
676 const bool multicolor,
682 if (
color !=
nullptr) {
686 if (outline_alpha > 0.0f) {
705 if (outline_alpha > 0) {
718 const bool multicolor,
732 *r_width = g->
dims[0];
733 *r_height = g->
dims[1];
775 const int chy = glyph_y + g->
dims[1];
779 if ((chx + g->
dims[0]) < 0 ||
780 chx >= buf_info->
dims[0] ||
789 int width_clip = g->
dims[0];
790 int height_clip = g->
dims[1];
791 int yb_start = g->
pitch < 0 ? 0 : g->
dims[1] - 1;
793 if (width_clip + chx > buf_info->
dims[0]) {
794 width_clip -= chx + width_clip - buf_info->
dims[0];
810 const float *b_col_float = buf_info->
col_float;
813 if (buf_info->
fbuf) {
815 for (
int y = ((chy >= 0) ? 0 : -chy);
y < height_clip;
y++) {
816 const int x_start = (chx >= 0) ? 0 : -chx;
820 float *fbuf = buf_info->
fbuf + buf_ofs;
822 for (
int x = x_start;
x < width_clip;
x++, a_ptr++, fbuf += 4) {
823 const char a_byte = *a_ptr;
825 const float a = (a_byte / 255.0f) * b_col_float[3];
828 font_pixel[0] = b_col_float[0] * a;
829 font_pixel[1] = b_col_float[1] * a;
830 font_pixel[2] = b_col_float[2] * a;
837 for (
int x = x_start;
x < width_clip;
x++, a_ptr++, fbuf++) {
838 const char a_byte = *a_ptr;
840 *fbuf = (a_byte / 255.0f) * b_col_float[0];
854 if (buf_info->
cbuf) {
856 for (
int y = ((chy >= 0) ? 0 : -chy);
y < height_clip;
y++) {
857 const int x_start = (chx >= 0) ? 0 : -chx;
863 for (
int x = x_start;
x < width_clip;
x++, a_ptr++, cbuf += 4) {
864 const char a_byte = *a_ptr;
867 const float a = (a_byte / 255.0f) * b_col_float[3];
870 font_pixel[0] = b_col_char[0];
871 font_pixel[1] = b_col_char[1];
872 font_pixel[2] = b_col_char[2];
879 for (
int x = x_start;
x < width_clip;
x++, a_ptr++, cbuf++) {
880 const char a_byte = *a_ptr;
882 const float a = (a_byte / 255.0f) * b_col_float[0];
902 const size_t str_len,
954 if (g ==
nullptr) [[unlikely]] {
962#ifdef BLF_SUBPIXEL_POSITION
970#ifdef BLF_SUBPIXEL_AA
982 FontBLF *font,
const char *
str,
const size_t str_len,
int width,
int *r_width)
989 const int width_i = width;
999 width_new =
step.pen_x_right;
1011 FontBLF *font,
const char *
str,
const size_t str_len,
int width,
int *r_width)
1015 size_t i, i_prev, i_tmp;
1016 std::optional<size_t> i_next = {};
1017 const char *s, *s_prev;
1021 int is_utf8_valid = -1;
1026 i = size_t(s -
str);
1028 i_prev = size_t(s_prev -
str);
1032 for (width_new = pen_x = 0; (s !=
nullptr && i > 0);
1033 i_next = i, i = i_prev, s = s_prev, g = g_prev, g_prev =
nullptr, width_new = pen_x)
1036 i_prev = size_t(s_prev -
str);
1057 return i_next ? *i_next : i;
1069 const size_t str_len,
1090 std::max(
step.pen_x_right,
step.pen_x +
step.g->box_xmax);
1091 const ft_pix gbox_ymin =
step.g->box_ymin + pen_y +
step.offset_y;
1092 const ft_pix gbox_ymax =
step.g->box_ymax + pen_y +
step.offset_y;
1094 box_xmin = std::min(gbox_xmin, box_xmin);
1095 box_ymin = std::min(gbox_ymin, box_ymin);
1097 box_xmax = std::max(gbox_xmax, box_xmax);
1098 box_ymax = std::max(gbox_ymax, box_ymax);
1101 if (box_xmin > box_xmax) {
1128 const size_t str_len,
1211 if (g ==
nullptr) [[unlikely]] {
1219 return glyph_advance;
1224 const size_t str_len,
1228 if (str_len == 0 ||
str[0] == 0) {
1238 const size_t i_curr =
step.i;
1252 if (user_fn(
str, i_curr, &
bounds, user_data) ==
false) {
1264 FunctionRef<
void(
int index,
size_t byte_offset,
int byte_len,
int advance_x)> callback)
1268 size_t byte_offset = 0;
1270 while (byte_offset <= str_len) {
1276 callback(
index, byte_offset, char_byte_len, advance_x);
1279 byte_offset += size_t(char_byte_len);
1280 str += char_byte_len;
1294 const size_t str_step_ofs,
1301 data->r_offset = str_step_ofs;
1315 if (!
str || !
str[0] || !str_len) {
1320 data.location_x = location_x;
1321 data.r_offset = size_t(-1);
1325 if (
data.r_offset ==
size_t(-1)) {
1331 int offset = int(
data.r_offset);
1333 data.r_offset = size_t(offset);
1336 return data.r_offset;
1345 const size_t str_step_ofs,
1350 if (
data->str_offset == str_step_ofs) {
1360 rcti *r_glyph_bounds)
1363 data.str_offset = str_offset;
1367 *r_glyph_bounds =
data.bounds;
1372 const size_t str_len,
1373 const size_t str_offset,
1374 const int cursor_width)
1382 if (str_offset > 0) {
1388 if (str_offset < strlen(
str)) {
1392 if ((prev.xmax == prev.xmin) && next.
xmax) {
1394 return next.
xmin - (cursor_width / 2);
1396 if ((prev.xmax != prev.xmin) && !next.
xmax) {
1398 return prev.xmax - (cursor_width / 2);
1400 if (prev.xmax && next.
xmax) {
1402 if (next.
xmin >= prev.xmax || next.
xmin == next.
xmax) {
1403 return ((prev.xmax + next.
xmin) - cursor_width) / 2;
1406 return ((next.
xmax + prev.xmin) - cursor_width) / 2;
1410 return 0 - cursor_width;
1416 FontBLF *font,
const char *
str,
size_t str_len,
size_t sel_start,
size_t sel_length)
1442 const size_t str_len,
1443 const int max_pixel_width,
1446 void (*callback)(
FontBLF *font,
1449 const size_t str_len,
1461 size_t clip_bytes = 0;
1467 struct WordWrapVars {
1469 size_t start, last[2];
1476 const size_t i_curr =
step.i;
1477 bool do_draw =
false;
1484 const uint codepoint_prev = g_prev ? g_prev->
c : 0;
1496 const bool overflows = (
step.g !=
nullptr) &&
step.pen_x_right >=
wrap.wrap_width &&
1499 if (overflows && (
wrap.start !=
wrap.last[0])) [[unlikely]] {
1505 wrap.last[0] = i_curr;
1506 wrap.last[1] = i_curr;
1510 else if (((
step.i < str_len) &&
str[
step.i]) == 0) [[unlikely]] {
1512 wrap.last[0] =
step.i + ((codepoint !=
'\n') ? 1 : 0);
1517 else if (codepoint ==
'\n') [[unlikely]] {
1518 wrap.last[0] = i_curr + 1;
1523 else if (codepoint !=
' ' && (g_prev ? g_prev->
c ==
' ' :
false)) [[unlikely]] {
1524 wrap.last[0] = i_curr;
1525 wrap.last[1] = i_curr;
1529 if (
ELEM(codepoint,
SEP,
' ',
'?',
'&',
'=')) {
1535 else if (
ELEM(codepoint,
'-',
'_',
'.',
'%')) {
1537 wrap.last[0] = i_curr;
1538 wrap.last[1] = i_curr;
1547 wrap.last[0] = i_curr;
1548 wrap.last[1] = i_curr;
1563 wrap.last[0] = i_curr;
1564 wrap.last[1] = i_curr;
1568 if (do_draw) [[unlikely]] {
1570 printf(
"(%03d..%03d) `%.*s`\n",
1580 std::min(
wrap.last[0] -
wrap.start - clip_bytes, str_len -
wrap.start),
1583 line_width =
step.pen_x_right;
1587 pen_y -= line_height;
1599 r_info->
lines = lines;
1611 const size_t str_len,
1633 const size_t str_len,
1637 rcti *box =
static_cast<rcti *
>(userdata);
1646 r_box->
xmin = 32000;
1647 r_box->
xmax = -32000;
1648 r_box->
ymin = 32000;
1649 r_box->
ymax = -32000;
1672 const size_t str_len,
1680 const size_t str_len,
1697 const size_t str_len,
1708 int max_pixel_width,
1799 int err = FT_Init_FreeType(&
ft_lib);
1800 if (err == FT_Err_Ok) {
1802 err = FTC_Manager_New(
ft_lib,
1809 if (err == FT_Err_Ok) {
1823 FT_Done_FreeType(
ft_lib);
1850 font->
color[0] = 255;
1851 font->
color[1] = 255;
1853 font->
color[3] = 255;
1888 metrics->
width = 1.0f;
1890 const TT_OS2 *os2_table =
static_cast<const TT_OS2 *
>(FT_Get_Sfnt_Table(face, FT_SFNT_OS2));
1893 if (os2_table->usWeightClass >= 1 && os2_table->usWeightClass <= 1000) {
1894 metrics->
weight = short(os2_table->usWeightClass);
1898 if (os2_table->usWidthClass >= 1 && os2_table->usWidthClass <= 9) {
1899 switch (os2_table->usWidthClass) {
1901 metrics->
width = 0.5f;
1904 metrics->
width = 0.625f;
1907 metrics->
width = 0.75f;
1910 metrics->
width = 0.875f;
1913 metrics->
width = 1.0f;
1916 metrics->
width = 1.125f;
1919 metrics->
width = 1.25f;
1922 metrics->
width = 1.5f;
1925 metrics->
width = 2.0f;
1938 metrics->
family_class = short(os2_table->sFamilyClass);
1942 if (os2_table->version > 1) {
1943 metrics->
cap_height = short(os2_table->sCapHeight);
1944 metrics->
x_height = short(os2_table->sxHeight);
1949 const TT_Postscript *post_table =
static_cast<const TT_Postscript *
>(
1950 FT_Get_Sfnt_Table(face, FT_SFNT_POST));
1952 if (post_table->italicAngle != 0) {
1953 metrics->
slant =
float(post_table->italicAngle) / -65536.0f;
1959 metrics->
ascender = short(face->ascender);
1960 metrics->
descender = short(face->descender);
1970 FT_UInt gi = FT_Get_Char_Index(face,
uint(
'H'));
1971 if (gi && FT_Load_Glyph(face, gi, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP) == FT_Err_Ok) {
1972 metrics->
cap_height = short(face->glyph->metrics.height);
1981 FT_UInt gi = FT_Get_Char_Index(face,
uint(
'x'));
1982 if (gi && FT_Load_Glyph(face, gi, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP) == FT_Err_Ok) {
1983 metrics->
x_height = short(face->glyph->metrics.height);
1990 FT_UInt gi = FT_Get_Char_Index(face,
uint(
'o'));
1991 if (gi && FT_Load_Glyph(face, gi, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP) == FT_Err_Ok) {
2005 if (metrics->
weight == 400 && face->style_flags & FT_STYLE_FLAG_BOLD) {
2010 if (metrics->
slant == 0.0f && face->style_flags & FT_STYLE_FLAG_ITALIC) {
2012 metrics->
slant = 8.0f;
2047 metrics->
valid =
true;
2058 if (FT_HAS_MULTIPLE_MASTERS(font) && !font->
variations) {
2070 if (FT_IS_FIXED_WIDTH(font)) {
2097 FT_Error err = FTC_Manager_LookupFace(
ftc_manager, font, &font->
face);
2100 if (
ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) {
2101 printf(
"Format of this font file is not supported\n");
2104 printf(
"Error encountered while opening font file\n");
2110 if (font->
face && !(font->
face->face_flags & FT_FACE_FLAG_SCALABLE)) {
2111 printf(
"Font is not scalable\n");
2115 err = FT_Select_Charmap(font->
face, FT_ENCODING_UNICODE);
2117 err = FT_Select_Charmap(font->
face, FT_ENCODING_APPLE_ROMAN);
2119 if (err && font->
face->num_charmaps > 0) {
2120 err = FT_Select_Charmap(font->
face, font->
face->charmaps[0]->encoding);
2123 printf(
"Can't set a character map!\n");
2131 err = FT_Attach_File(font->
face, mfile);
2134 "FT_Attach_File failed to load '%s' with error %d\n",
2156 {
"Noto Sans CJK Regular.woff2",
2158 TT_UCR_CJK_SYMBOLS | TT_UCR_HIRAGANA | TT_UCR_KATAKANA | TT_UCR_BOPOMOFO | TT_UCR_CJK_MISC |
2159 TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS | TT_UCR_CJK_COMPATIBILITY |
2160 TT_UCR_CJK_UNIFIED_IDEOGRAPHS | TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS |
2161 TT_UCR_HANGUL_COMPATIBILITY_JAMO | TT_UCR_HANGUL,
2162 TT_UCR_CJK_COMPATIBILITY_FORMS | TT_UCR_HALFWIDTH_FULLWIDTH_FORMS,
2164 {
"NotoEmoji-VariableFont_wght.woff2", 0x80000003L, 0x241E4ACL, 0x14000000L, 0x4000000L},
2165 {
"NotoSansArabic-VariableFont_wdth,wght.woff2",
2167 uint(TT_UCR_ARABIC_PRESENTATION_FORMS_A),
2168 TT_UCR_ARABIC_PRESENTATION_FORMS_B,
2170 {
"NotoSansArmenian-VariableFont_wdth,wght.woff2", TT_UCR_ARMENIAN, 0, 0, 0},
2171 {
"NotoSansBengali-VariableFont_wdth,wght.woff2", TT_UCR_BENGALI, 0, 0, 0},
2172 {
"NotoSansDevanagari-Regular.woff2", TT_UCR_DEVANAGARI, 0, 0, 0},
2173 {
"NotoSansEthiopic-Regular.woff2", 0, 0, TT_UCR_ETHIOPIC, 0},
2174 {
"NotoSansGeorgian-VariableFont_wdth,wght.woff2", TT_UCR_GEORGIAN, 0, 0, 0},
2175 {
"NotoSansGujarati-Regular.woff2", TT_UCR_GUJARATI, 0, 0, 0},
2176 {
"NotoSansGurmukhi-VariableFont_wdth,wght.woff2", TT_UCR_GURMUKHI, 0, 0, 0},
2177 {
"NotoSansHebrew-Regular.woff2", TT_UCR_HEBREW, 0, 0, 0},
2178 {
"NotoSansJavanese-Regular.woff2", 0x80000003L, 0x2000L, 0, 0},
2179 {
"NotoSansKannada-VariableFont_wdth,wght.woff2", TT_UCR_KANNADA, 0, 0, 0},
2180 {
"NotoSansKhmer-VariableFont_wdth,wght.woff2", 0, 0, TT_UCR_KHMER, 0},
2181 {
"NotoSansMalayalam-VariableFont_wdth,wght.woff2", TT_UCR_MALAYALAM, 0, 0, 0},
2182 {
"NotoSansMath-Regular.woff2", 0, TT_UCR_MATHEMATICAL_OPERATORS, 0, 0},
2183 {
"NotoSansMyanmar-Regular.woff2", 0, 0, TT_UCR_MYANMAR, 0},
2184 {
"NotoSansSymbols-VariableFont_wght.woff2", 0x3L, 0x200E4B4L, 0, 0},
2185 {
"NotoSansSymbols2-Regular.woff2", 0x80000003L, 0x200E3E4L, 0x40020L, 0x580A048L},
2186 {
"NotoSansTamil-VariableFont_wdth,wght.woff2", TT_UCR_TAMIL, 0, 0, 0},
2187 {
"NotoSansTelugu-VariableFont_wdth,wght.woff2", TT_UCR_TELUGU, 0, 0, 0},
2188 {
"NotoSansThai-VariableFont_wdth,wght.woff2", TT_UCR_THAI, 0, 0, 0},
2195 const char *mem_name,
2197 const size_t mem_size)
2199 FontBLF *font = MEM_new<FontBLF>(__func__);
2211 bool face_needed =
true;
2222 face_needed =
false;
2235 const TT_OS2 *os2_table =
static_cast<const TT_OS2 *
>(
2236 FT_Get_Sfnt_Table(font->
face, FT_SFNT_OS2));
2269 open.flags = FT_OPEN_MEMORY;
2270 open.memory_base =
static_cast<const FT_Byte *
>(mem);
2271 open.memory_size = FT_Long(mem_size);
2273 FT_Attach_Stream(font->
face, &open);
2292 font->
face =
nullptr;
2316 FTC_ScalerRec scaler = {
nullptr};
2317 scaler.face_id = font;
2324 font->
ft_size->generic.data =
static_cast<void *
>(font);
2341 size =
float(ft_size) / 64.0f;
2343 if (font->
size != size) {
2345 FTC_ScalerRec scaler = {
nullptr};
2346 scaler.face_id = font;
2348 scaler.height = ft_size;
2355 font->
ft_size->generic.data =
static_cast<void *
>(font);
#define GPU_batch_texture_bind(batch, name, tex)
#define GPU_BATCH_DISCARD_SAFE(batch)
#define GPU_batch_uniform_1i(batch, name, x)
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
#define BLF_CACHE_MAX_FACES
#define BLF_CACHE_MAX_SIZES
#define KERNING_CACHE_TABLE_SIZE
#define KERNING_ENTRY_UNSET
btMatrix3x3 scaled(const btVector3 &s) const
Create a scaled copy of the matrix.
void append(const T &value)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
std::string filename(const std::string_view &str, size_t pos)
BLI_INLINE Texture * wrap(MTLTexture *texture)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
int blf_font_height_max(FontBLF *font)
MINLINE unsigned int round_fl_to_uint(float a)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void GPU_storagebuf_update(gpu::StorageBuf *ssbo, const void *data)
static void blf_font_fill(FontBLF *font)
gpu::Batch * GPU_batch_create_procedural(GPUPrimType primitive_type, int32_t vertex_count)
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)
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
bool BLI_str_utf32_char_is_breaking_space(char32_t codepoint)
ptrdiff_t BLI_str_utf8_invalid_byte(const char *str, size_t str_len) ATTR_NONNULL(1)
static Mutex ft_face_load_mutex
bool blf_ensure_face(FontBLF *font)
ft_pix ft_pix_from_int(int v)
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
static gpu::Texture * blf_batch_cache_texture_load()
void blf_glyph_cache_release(FontBLF *font)
BLI_INLINE bool blf_glyph_is_combining(const GlyphBLF *g)
void blf_font_draw_buffer__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
char * blf_dir_metrics_search(const char *filepath)
gpu::StorageBuf * GPU_storagebuf_create_ex(size_t size, const void *data, GPUUsageType usage, const char *name)
unsigned int BLI_str_utf8_as_unicode_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
uint blf_get_char_index(FontBLF *font, const uint charcode)
static void blf_batch_draw_init()
int blf_font_draw_mono(FontBLF *font, const char *str, const size_t str_len, const int char_width, const int tab_columns)
float blf_font_fixed_width(FontBLF *font)
void blf_ensure_size(FontBLF *font)
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
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
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_free(FontBLF *font)
static bool blf_cursor_position_foreach_glyph(const char *, const size_t str_step_ofs, const rcti *bounds, void *user_data)
void GPU_storagebuf_usage_size_set(gpu::StorageBuf *ssbo, size_t size)
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)
void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, const int x, const int y)
void blf_font_boundbox(FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
static FTC_Manager ftc_manager
static bool blf_setup_face(FontBLF *font)
void blf_font_boundbox__wrap(FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
static FontBLF * blf_font_new_impl(const char *filepath, const char *mem_name, const uchar *mem, const size_t mem_size)
static void blf_font_metrics(FT_Face face, FontMetrics *metrics)
void BLF_cache_flush_set_fn(void(*cache_flush_fn)())
unsigned int BLI_str_utf8_as_unicode_step_safe(const char *__restrict p, size_t p_len, size_t *__restrict index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
static ft_pix blf_font_width_max_ft_pix(FontBLF *font)
static void blf_font_draw_buffer_ex(FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, const ft_pix pen_y, ResultBLF *r_info)
BLI_INLINE ft_pix blf_kerning(FontBLF *font, const GlyphBLF *g_prev, const GlyphBLF *g)
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)
static ft_pix blf_font_height_max_ft_pix(FontBLF *font)
size_t blf_font_width_to_strlen(FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
void GPU_texture_update_sub(gpu::Texture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth, uint unpack_row_length=0)
static bool blf_str_offset_foreach_glyph(const char *, const size_t str_step_ofs, const rcti *bounds, void *user_data)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
static FTC_CMapCache ftc_charmap_cache
void blf_font_draw_buffer(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
FontBLF * blf_font_new_from_mem(const char *mem_name, const uchar *mem, const size_t mem_size)
GlyphCacheBLF * blf_glyph_cache_acquire(FontBLF *font)
int blf_font_descender(FontBLF *font)
bool blf_font_bounds_max(FontBLF *font, rctf *r_bounds)
BMesh const char void * data
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)
bool BLI_str_utf32_char_is_optional_break_after(char32_t codepoint, char32_t codepoint_prev)
bool BLI_str_utf32_char_is_optional_break_before(char32_t codepoint, char32_t codepoint_prev)
BLI_INLINE GlyphBLF * blf_glyph_from_utf8_and_step(FontBLF *font, GlyphCacheBLF *gc, const GlyphBLF *g_prev, const char *str, const size_t str_len, size_t *i_p, int32_t *pen_x)
FontBLF * blf_font_new_from_filepath(const char *filepath)
BLI_INLINE bool blf_glyph_step(FontBLF *font, GlyphCacheBLF *gc, GlyphStepData &step, const char *str, const size_t str_len)
int BLI_str_utf8_char_width_or_error(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b)
int GPU_texture_width(const gpu::Texture *texture)
bool(*)(const char *str, size_t str_step_ofs, const rcti *bounds, void *user_dataconst) BLF_GlyphBoundsFn
static void blf_size_finalizer(void *object)
void blf_font_draw__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
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)
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool equals_m4m4(const float mat1[4][4], const float mat2[4][4])
bool BLI_str_cursor_step_prev_utf8(const char *str, int str_maxlen, int *pos)
static Mutex ft_cache_size_mutex
int BLI_str_utf8_size_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void GPU_storagebuf_bind(gpu::StorageBuf *ssbo, int slot)
GlyphBLF * blf_glyph_ensure(FontBLF *font, GlyphCacheBLF *gc, const uint charcode, uint8_t subpixel)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
GlyphBLF * blf_glyph_ensure_icon(GlyphCacheBLF *gc, const uint icon_id, bool color, FunctionRef< void(std::string &)> edit_source_cb)
void blf_font_draw(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
void GPU_batch_program_set_builtin(gpu::Batch *batch, GPUBuiltinShader shader_id)
void blf_font_boundbox_foreach_glyph(FontBLF *font, const char *str, const size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data)
static void blf_glyph_draw_buffer(FontBufInfoBLF *buf_info, GlyphBLF *g, const ft_pix pen_x, const ft_pix pen_y_basis)
int ft_pix_to_int_ceil(ft_pix v)
size_t blf_str_offset_from_cursor_position(FontBLF *font, const char *str, size_t str_len, int location_x)
ft_pix ft_pix_from_float(float v)
static void blf_font_draw_buffer__wrap_cb(FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, const ft_pix pen_y, void *)
int blf_font_width_max(FontBLF *font)
static ft_pix blf_unscaled_F26Dot6_to_pixels(FontBLF *font, const FT_Pos value)
static void blf_font_draw__wrap_cb(FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, ft_pix pen_y, void *)
const char * BLI_str_find_prev_char_utf8(const char *p, const char *str_start) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1
MINLINE void zero_v2_int(int r[2])
static void blf_font_string_wrap_cb(FontBLF *, GlyphCacheBLF *, const char *str, const size_t str_len, const ft_pix, void *str_list_ptr)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
static FT_Error blf_cache_face_requester(FTC_FaceID faceID, FT_Library lib, FT_Pointer, FT_Face *face)
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_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)
int BLI_wcwidth_safe(char32_t ucs) ATTR_WARN_UNUSED_RESULT
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)
unsigned int unsigned int size_t BLI_str_utf8_from_unicode_len(unsigned int c) ATTR_WARN_UNUSED_RESULT
size_t blf_font_width_to_rstrlen(FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
void GPU_batch_draw_advanced(gpu::Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
void GPU_texture_unbind(gpu::Texture *texture)
int ft_pix_to_int(ft_pix v)
void GPU_blend(GPUBlend blend)
void blf_batch_draw_begin(FontBLF *font)
bool blf_font_size(FontBLF *font, float size)
MINLINE int is_power_of_2_i(int n)
MINLINE int bitscan_reverse_i(int a)
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 GPU_storagebuf_free(gpu::StorageBuf *ssbo)
void blf_glyph_cache_clear(FontBLF *font)
static void blf_batch_draw_exit()
float blf_font_width(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
static void blf_face_finalizer(void *object)
void blf_font_attach_from_mem(FontBLF *font, const uchar *mem, const size_t mem_size)
void GPU_matrix_set(const float m[4][4])
static const FaceDetails static_face_details[]
int ft_pix_to_int_floor(ft_pix v)
GlyphBLF * blf_glyph_ensure_subpixel(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int32_t pen_x)
static void blf_batch_draw_end()
static int blf_str_is_utf8_valid_lazy_init(const char *str, const size_t str_len, int &is_utf8_valid)
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
static void(*) blf_draw_cache_flush()
BLI_INLINE void blf_glyph_step_reset_for_newline(GlyphStepData &step)
int blf_font_ascender(FontBLF *font)
char * blf_display_name(FontBLF *font)
const float(* GPU_matrix_model_view_get(float m[4][4]))[4]
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
GlyphCacheBLF * glyph_cache
GlyphQuad glyph_data[BLF_BATCH_DRAW_LEN_MAX]
gpu::StorageBuf * glyph_buf
unsigned char shadow_color[4]
KerningCacheBLF * kerning_cache
unsigned char col_char[4]
short underline_thickness
short superscript_yoffset
short strikeout_thickness
short superscript_xoffset
const GlyphBLF * g_kerning
int ascii_table[KERNING_CACHE_TABLE_SIZE][KERNING_CACHE_TABLE_SIZE]