Blender V5.3
blf.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12
13#include <cmath>
14#include <cstdio>
15#include <cstdlib>
16#include <cstring>
17
18#include <ft2build.h>
19
20#include FT_FREETYPE_H
21#include FT_GLYPH_H
22
23#include "BLI_fileops.hh"
25#include "BLI_path_utils.hh"
26#include "BLI_string.hh"
27
28#include "BLF_api.hh"
29
31
32#include "GPU_matrix.hh"
33#include "GPU_state.hh"
34
35#include "blf_internal.hh"
36#include "blf_internal_types.hh"
37
38namespace blender {
39
40#define BLF_RESULT_CHECK_INIT(r_info) \
41 if (r_info) { \
42 memset(r_info, 0, sizeof(*(r_info))); \
43 } \
44 ((void)0)
45
47
48/* XXX: should these be made into global_font_'s too? */
49
52
54
55static FontBLF *blf_get(int fontid)
56{
57 if (fontid >= 0 && fontid < BLF_MAX_FONT) {
58 return global_font[fontid];
59 }
60 return nullptr;
61}
62
64{
65 for (int i = 0; i < BLF_MAX_FONT; i++) {
66 global_font[i] = nullptr;
67 }
68
69 return blf_font_init();
70}
71
73{
74 for (int i = 0; i < BLF_MAX_FONT; i++) {
75 FontBLF *font = global_font[i];
76 if (font) {
77 blf_font_free(font);
78 global_font[i] = nullptr;
79 }
80 }
81
83}
84
86{
87 const int def_font = BLF_default();
88 for (int i = 0; i < BLF_MAX_FONT; i++) {
89 FontBLF *font = global_font[i];
90 if (font && !ELEM(i, def_font, blf_mono_font, blf_mono_font_render) &&
91 !(font->flags & BLF_DEFAULT))
92 {
93 /* Remove fonts that are not used in the UI or part of the stack. */
94 blf_font_free(font);
95 global_font[i] = nullptr;
96 }
97 }
98}
99
101{
102 for (int i = 0; i < BLF_MAX_FONT; i++) {
103 FontBLF *font = global_font[i];
104 if (font) {
106 }
107 }
108}
109
110static int blf_search_by_mem_name(const char *mem_name)
111{
112 std::lock_guard lock(g_blf_load_mutex);
113 for (int i = 0; i < BLF_MAX_FONT; i++) {
114 const FontBLF *font = global_font[i];
115 if ((font == nullptr) || (font->mem_name == nullptr)) {
116 continue;
117 }
118 if (STREQ(font->mem_name, mem_name)) {
119 return i;
120 }
121 }
122
123 return -1;
124}
125
126static int blf_search_by_filepath(const char *filepath)
127{
128 std::lock_guard lock(g_blf_load_mutex);
129 for (int i = 0; i < BLF_MAX_FONT; i++) {
130 const FontBLF *font = global_font[i];
131 if ((font == nullptr) || (font->filepath == nullptr)) {
132 continue;
133 }
134 if (BLI_path_cmp(font->filepath, filepath) == 0) {
135 return i;
136 }
137 }
138
139 return -1;
140}
141
143{
144 for (int i = 0; i < BLF_MAX_FONT; i++) {
145 if (!global_font[i]) {
146 return i;
147 }
148 }
149
150 return -1;
151}
152
153bool BLF_has_glyph(int fontid, uint unicode)
154{
155 FontBLF *font = blf_get(fontid);
156 if (font) {
157 return blf_get_char_index(font, unicode) != FT_Err_Ok;
158 }
159 return false;
160}
161
162bool BLF_is_loaded(const char *filepath)
163{
164 return blf_search_by_filepath(filepath) >= 0;
165}
166
167bool BLF_is_loaded_mem(const char *name)
168{
169 return blf_search_by_mem_name(name) >= 0;
170}
171
172bool BLF_is_loaded_id(int fontid)
173{
174 return blf_get(fontid) != nullptr;
175}
176
177int BLF_load(const char *filepath)
178{
179 /* check if we already load this font. */
180 int i = blf_search_by_filepath(filepath);
181 if (i >= 0) {
182 FontBLF *font = global_font[i];
183 font->reference_count++;
184 return i;
185 }
186
187 return BLF_load_unique(filepath);
188}
189
190int BLF_load_unique(const char *filepath)
191{
192 std::lock_guard lock(g_blf_load_mutex);
193 int i = blf_search_available();
194 if (i == -1) {
195 printf("Too many fonts!!!\n");
196 return -1;
197 }
198
199 /* This isn't essential, it will just cause confusing behavior to load a font
200 * that appears to succeed, then doesn't show up. */
201 if (!BLI_exists(filepath)) {
202 printf("Can't find font: %s\n", filepath);
203 return -1;
204 }
205
206 FontBLF *font = blf_font_new_from_filepath(filepath);
207
208 if (!font) {
209 printf("Can't load font: %s\n", filepath);
210 return -1;
211 }
212
213 font->reference_count = 1;
214 global_font[i] = font;
215 return i;
216}
217
218void BLF_metrics_attach(const int fontid, const uchar *mem, const int mem_size)
219{
220 FontBLF *font = blf_get(fontid);
221
222 if (font) {
223 blf_font_attach_from_mem(font, mem, mem_size);
224 }
225}
226
227int BLF_load_mem(const char *name, const uchar *mem, int mem_size)
228{
229 int i = blf_search_by_mem_name(name);
230 if (i >= 0) {
231 return i;
232 }
233 return BLF_load_mem_unique(name, mem, mem_size);
234}
235
236int BLF_load_mem_unique(const char *name, const uchar *mem, int mem_size)
237{
238 std::lock_guard lock(g_blf_load_mutex);
239 int i = blf_search_available();
240 if (i == -1) {
241 printf("Too many fonts!!!\n");
242 return -1;
243 }
244
245 if (!mem_size) {
246 printf("Can't load font: %s from memory!!\n", name);
247 return -1;
248 }
249
250 FontBLF *font = blf_font_new_from_mem(name, mem, mem_size);
251 if (!font) {
252 printf("Can't load font: %s from memory!!\n", name);
253 return -1;
254 }
255
256 font->reference_count = 1;
257 global_font[i] = font;
258 return i;
259}
260
261void BLF_unload(const char *filepath)
262{
263 std::lock_guard lock(g_blf_load_mutex);
264 for (int i = 0; i < BLF_MAX_FONT; i++) {
265 FontBLF *font = global_font[i];
266 if (font == nullptr || font->filepath == nullptr) {
267 continue;
268 }
269
270 if (BLI_path_cmp(font->filepath, filepath) == 0) {
271 BLI_assert(font->reference_count > 0);
272 font->reference_count--;
273
274 if (font->reference_count == 0) {
275 blf_font_free(font);
276 global_font[i] = nullptr;
277 }
278 }
279 }
280}
281
282bool BLF_unload_id(int fontid)
283{
284 std::lock_guard lock(g_blf_load_mutex);
285 FontBLF *font = blf_get(fontid);
286 if (font) {
287 BLI_assert(font->reference_count > 0);
288 font->reference_count--;
289
290 if (font->reference_count == 0) {
291 blf_font_free(font);
292 global_font[fontid] = nullptr;
293 return true;
294 }
295 }
296 return false;
297}
298
300{
301 for (int i = 0; i < BLF_MAX_FONT; i++) {
302 FontBLF *font = global_font[i];
303 if (font) {
304 blf_font_free(font);
305 global_font[i] = nullptr;
306 }
307 }
308 blf_mono_font = -1;
310 BLF_default_set(-1);
311}
312
313void BLF_addref_id(int fontid)
314{
315 std::lock_guard lock(g_blf_load_mutex);
316 FontBLF *font = blf_get(fontid);
317 if (font) {
318 font->reference_count++;
319 }
320}
321
322void BLF_enable(int fontid, FontFlags flag)
323{
324 FontBLF *font = blf_get(fontid);
325
326 if (font) {
327 font->flags |= flag;
328 }
329}
330
331void BLF_disable(int fontid, FontFlags flag)
332{
333 FontBLF *font = blf_get(fontid);
334
335 if (font) {
336 font->flags &= ~flag;
337 }
338}
339
340bool BLF_is_builtin(int fontid)
341{
342 FontBLF *font = blf_get(fontid);
343 if (font) {
344 return font->flags & BLF_DEFAULT;
345 }
346 return false;
347}
348
349void BLF_character_weight(int fontid, int weight)
350{
351 FontBLF *font = blf_get(fontid);
352 if (font) {
353 font->char_weight = weight;
354 }
355}
356
357int BLF_default_weight(int fontid)
358{
359 FontBLF *font = blf_get(fontid);
360 if (font) {
361 return font->metrics.weight;
362 }
363 return 400;
364}
365
367{
368 const FontBLF *font = blf_get(fontid);
369 if (font && font->variations) {
370 for (int i = 0; i < int(font->variations->num_axis); i++) {
371 if (font->variations->axis[i].tag == BLF_VARIATION_AXIS_WEIGHT) {
372 return true;
373 }
374 }
375 }
376 return false;
377}
378
379void BLF_aspect(int fontid, float x, float y, float z)
380{
381 FontBLF *font = blf_get(fontid);
382
383 if (font) {
384 font->aspect[0] = x;
385 font->aspect[1] = y;
386 font->aspect[2] = z;
387 }
388}
389
390void BLF_position(int fontid, float x, float y, float z)
391{
392 FontBLF *font = blf_get(fontid);
393
394 if (font) {
395 float xa, ya, za;
396 float remainder;
397
398 if (font->flags & BLF_ASPECT) {
399 xa = font->aspect[0];
400 ya = font->aspect[1];
401 za = font->aspect[2];
402 }
403 else {
404 xa = 1.0f;
405 ya = 1.0f;
406 za = 1.0f;
407 }
408
409 remainder = x - floorf(x);
410 if (remainder > 0.4f && remainder < 0.6f) {
411 if (remainder < 0.5f) {
412 x -= 0.1f * xa;
413 }
414 else {
415 x += 0.1f * xa;
416 }
417 }
418
419 remainder = y - floorf(y);
420 if (remainder > 0.4f && remainder < 0.6f) {
421 if (remainder < 0.5f) {
422 y -= 0.1f * ya;
423 }
424 else {
425 y += 0.1f * ya;
426 }
427 }
428
429 remainder = z - floorf(z);
430 if (remainder > 0.4f && remainder < 0.6f) {
431 if (remainder < 0.5f) {
432 z -= 0.1f * za;
433 }
434 else {
435 z += 0.1f * za;
436 }
437 }
438
439 font->pos[0] = round_fl_to_int(x);
440 font->pos[1] = round_fl_to_int(y);
441 font->pos[2] = round_fl_to_int(z);
442 }
443}
444
445void BLF_size(int fontid, float size)
446{
447 FontBLF *font = blf_get(fontid);
448
449 if (font) {
450 blf_font_size(font, size);
451 }
452}
453
454void BLF_color4ubv(int fontid, const uchar rgba[4])
455{
456 FontBLF *font = blf_get(fontid);
457
458 if (font) {
459 font->color[0] = rgba[0];
460 font->color[1] = rgba[1];
461 font->color[2] = rgba[2];
462 font->color[3] = rgba[3];
463 }
464}
465
466void BLF_color3ubv_alpha(int fontid, const uchar rgb[3], uchar alpha)
467{
468 FontBLF *font = blf_get(fontid);
469
470 if (font) {
471 font->color[0] = rgb[0];
472 font->color[1] = rgb[1];
473 font->color[2] = rgb[2];
474 font->color[3] = alpha;
475 }
476}
477
478void BLF_color3ubv(int fontid, const uchar rgb[3])
479{
480 BLF_color3ubv_alpha(fontid, rgb, 255);
481}
482
483void BLF_color4ub(int fontid, uchar r, uchar g, uchar b, uchar alpha)
484{
485 FontBLF *font = blf_get(fontid);
486
487 if (font) {
488 font->color[0] = r;
489 font->color[1] = g;
490 font->color[2] = b;
491 font->color[3] = alpha;
492 }
493}
494
495void BLF_color3ub(int fontid, uchar r, uchar g, uchar b)
496{
497 FontBLF *font = blf_get(fontid);
498
499 if (font) {
500 font->color[0] = r;
501 font->color[1] = g;
502 font->color[2] = b;
503 font->color[3] = 255;
504 }
505}
506
507void BLF_color4fv(int fontid, const float rgba[4])
508{
509 FontBLF *font = blf_get(fontid);
510
511 if (font) {
512 rgba_float_to_uchar(font->color, rgba);
513 }
514}
515
516void BLF_color4f(int fontid, float r, float g, float b, float a)
517{
518 const float rgba[4] = {r, g, b, a};
519 BLF_color4fv(fontid, rgba);
520}
521
522void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha)
523{
524 float rgba[4];
525 copy_v3_v3(rgba, rgb);
526 rgba[3] = alpha;
527 BLF_color4fv(fontid, rgba);
528}
529
530void BLF_color3f(int fontid, float r, float g, float b)
531{
532 const float rgba[4] = {r, g, b, 1.0f};
533 BLF_color4fv(fontid, rgba);
534}
535
537{
538 BLI_assert(g_batch.enabled == false);
539 g_batch.enabled = true;
540}
541
543{
544 if (g_batch.enabled) {
546 }
547}
548
550{
551 BLI_assert(g_batch.enabled == true);
552 blf_batch_draw(); /* Draw remaining glyphs */
553 g_batch.enabled = false;
554}
555
556static void blf_draw_gpu__start(const FontBLF *font)
557{
558 /*
559 * The pixmap alignment hack is handle
560 * in BLF_position (old ui_rasterpos_safe).
561 */
562
563 if ((font->flags & (BLF_ROTATION | BLF_ASPECT)) == 0) {
564 return; /* glyphs will be translated individually and batched. */
565 }
566
568
569 GPU_matrix_translate_3f(font->pos[0], font->pos[1], font->pos[2]);
570
571 if (font->flags & BLF_ASPECT) {
573 }
574
575 if (font->flags & BLF_ROTATION) {
577 }
578}
579
580static void blf_draw_gpu__end(const FontBLF *font)
581{
582 if ((font->flags & (BLF_ROTATION | BLF_ASPECT)) != 0) {
584 }
585}
586
587void BLF_draw(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
588{
589 BLF_RESULT_CHECK_INIT(r_info);
590
591 if (str_len == 0 || str[0] == '\0') {
592 return;
593 }
594
595 FontBLF *font = blf_get(fontid);
596
597 if (font) {
599 if (font->flags & BLF_WORD_WRAP) {
600 blf_font_draw__wrap(font, str, str_len, r_info);
601 }
602 else {
603 blf_font_draw(font, str, str_len, r_info);
604 }
605 blf_draw_gpu__end(font);
606 }
607}
608
610 int fontid, const char *str, const size_t str_len, int char_width, int tab_columns)
611{
612 if (str_len == 0 || str[0] == '\0') {
613 return 0;
614 }
615
616 FontBLF *font = blf_get(fontid);
617 int columns = 0;
618
619 if (font) {
621 columns = blf_font_draw_mono(font, str, str_len, char_width, tab_columns);
622 blf_draw_gpu__end(font);
623 }
624
625 return columns;
626}
627
629 float x,
630 float y,
631 float size,
632 const float color[4],
633 float outline_alpha,
634 bool multicolor,
635 FunctionRef<void(std::string &)> edit_source_cb)
636{
637#ifndef WITH_HEADLESS
638 FontBLF *font = global_font[0];
639 if (font) {
640 font->pos[0] = x;
641 font->pos[1] = y;
642 font->pos[2] = 0;
643
644 if (font->flags & (BLF_ROTATION | BLF_ASPECT)) {
646
647 const float center = (font->flags & BLF_ROTATION) ? size / 2.0f : 0.0f;
648 GPU_matrix_translate_3f(font->pos[0] + center, font->pos[1] + center, font->pos[2]);
649 if (font->flags & BLF_ASPECT) {
651 }
652
653 if (font->flags & BLF_ROTATION) {
655 GPU_matrix_translate_3f(-center, -center, 0);
656 }
657 }
658
659 blf_draw_svg_icon(font, icon_id, size, color, outline_alpha, multicolor, edit_source_cb);
660 blf_draw_gpu__end(font);
661 }
662#else
663 UNUSED_VARS(icon_id, x, y, size, color, outline_alpha, multicolor, edit_source_cb);
664#endif /* WITH_HEADLESS */
665}
666
668 float size,
669 int *r_width,
670 int *r_height,
671 bool multicolor,
672 FunctionRef<void(std::string &)> edit_source_cb)
673{
674#ifndef WITH_HEADLESS
675 FontBLF *font = global_font[0];
676 if (font) {
677 return blf_svg_icon_bitmap(font, icon_id, size, r_width, r_height, multicolor, edit_source_cb);
678 }
679#else
680 UNUSED_VARS(icon_id, size, r_width, r_height, multicolor, edit_source_cb);
681#endif /* WITH_HEADLESS */
682 return {};
683}
684
686 int fontid, const char *str, size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data)
687{
688 FontBLF *font = blf_get(fontid);
689
690 if (font) {
691 if (font->flags & BLF_WORD_WRAP) {
692 /* TODO: word-wrap support. */
693 BLI_assert(0);
694 }
695 else {
696 blf_font_boundbox_foreach_glyph(font, str, str_len, user_fn, user_data);
697 }
698 }
699}
700
702 int fontid,
703 const char *str,
704 size_t str_len,
705 FunctionRef<void(int index, size_t byte_offset, int byte_len, int advance_x)> callback)
706{
707 FontBLF *font = blf_get(fontid);
708 if (font != nullptr) {
709 blf_font_info_foreach_glyph(font, str, str_len, callback);
710 }
711}
712
714 const char *str,
715 size_t str_len,
716 int location_x)
717{
718 FontBLF *font = blf_get(fontid);
719 if (font) {
720 return blf_str_offset_from_cursor_position(font, str, str_len, location_x);
721 }
722 return 0;
723}
724
726 const char *str,
727 size_t str_offset,
728 rcti *r_glyph_bounds)
729{
730 FontBLF *font = blf_get(fontid);
731 if (font) {
732 blf_str_offset_to_glyph_bounds(font, str, str_offset, r_glyph_bounds);
733 return true;
734 }
735 return false;
736}
737
739 const char *str,
740 const size_t str_len,
741 const size_t str_offset,
742 const int cursor_width)
743{
744 FontBLF *font = blf_get(fontid);
745 if (font) {
746 return blf_str_offset_to_cursor(font, str, str_len, str_offset, cursor_width);
747 }
748 return 0;
749}
750
752 int fontid, const char *str, size_t str_len, size_t sel_start, size_t sel_length)
753{
754 FontBLF *font = blf_get(fontid);
755 if (font) {
756 return blf_str_selection_boxes(font, str, str_len, sel_start, sel_length);
757 }
758 return {};
759}
760
762 int fontid, const char *str, const size_t str_len, float width, float *r_width)
763{
764 FontBLF *font = blf_get(fontid);
765
766 if (font) {
767 const float xa = (font->flags & BLF_ASPECT) ? font->aspect[0] : 1.0f;
768 size_t ret;
769 int width_result;
770 ret = blf_font_width_to_strlen(font, str, str_len, width / xa, &width_result);
771 if (r_width) {
772 *r_width = float(width_result) * xa;
773 }
774 return ret;
775 }
776
777 if (r_width) {
778 *r_width = 0.0f;
779 }
780 return 0;
781}
782
784 int fontid, const char *str, const size_t str_len, float width, float *r_width)
785{
786 FontBLF *font = blf_get(fontid);
787
788 if (font) {
789 const float xa = (font->flags & BLF_ASPECT) ? font->aspect[0] : 1.0f;
790 size_t ret;
791 int width_result;
792 ret = blf_font_width_to_rstrlen(font, str, str_len, width / xa, &width_result);
793 if (r_width) {
794 *r_width = float(width_result) * xa;
795 }
796 return ret;
797 }
798
799 if (r_width) {
800 *r_width = 0.0f;
801 }
802 return 0;
803}
804
806 int fontid, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
807{
808 FontBLF *font = blf_get(fontid);
809
810 BLF_RESULT_CHECK_INIT(r_info);
811
812 if (font) {
813 if (font->flags & BLF_WORD_WRAP) {
814 blf_font_boundbox__wrap(font, str, str_len, r_box, r_info);
815 }
816 else {
817 blf_font_boundbox(font, str, str_len, r_box, r_info);
818 }
819 }
820}
821
823 int fontid, const char *str, const size_t str_len, float *r_width, float *r_height)
824{
825 FontBLF *font = blf_get(fontid);
826
827 if (font) {
828 blf_font_width_and_height(font, str, str_len, r_width, r_height, nullptr);
829 }
830 else {
831 *r_width = *r_height = 0.0f;
832 }
833}
834
835float BLF_width(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
836{
837 FontBLF *font = blf_get(fontid);
838
839 BLF_RESULT_CHECK_INIT(r_info);
840
841 if (font) {
842 return blf_font_width(font, str, str_len, r_info);
843 }
844
845 return 0.0f;
846}
847
848float BLF_fixed_width(int fontid)
849{
850 FontBLF *font = blf_get(fontid);
851
852 if (font) {
853 return blf_font_fixed_width(font);
854 }
855
856 return 0.0f;
857}
858
859int BLF_glyph_advance(int fontid, const char *str)
860{
861 FontBLF *font = blf_get(fontid);
862
863 if (font) {
864 return blf_font_glyph_advance(font, str);
865 }
866
867 return 0;
868}
869
870float BLF_height(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
871{
872 FontBLF *font = blf_get(fontid);
873
874 BLF_RESULT_CHECK_INIT(r_info);
875
876 if (font) {
877 return blf_font_height(font, str, str_len, r_info);
878 }
879
880 return 0.0f;
881}
882
883int BLF_height_max(int fontid)
884{
885 FontBLF *font = blf_get(fontid);
886
887 if (font) {
888 return blf_font_height_max(font);
889 }
890
891 return 0;
892}
893
894int BLF_width_max(int fontid)
895{
896 FontBLF *font = blf_get(fontid);
897
898 if (font) {
899 return blf_font_width_max(font);
900 }
901
902 return 0;
903}
904
905int BLF_descender(int fontid)
906{
907 FontBLF *font = blf_get(fontid);
908
909 if (font) {
910 return blf_font_descender(font);
911 }
912
913 return 0;
914}
915
916int BLF_ascender(int fontid)
917{
918 FontBLF *font = blf_get(fontid);
919
920 if (font) {
921 return blf_font_ascender(font);
922 }
923
924 return 0.0f;
925}
926
927bool BLF_bounds_max(int fontid, rctf *r_bounds)
928{
929 FontBLF *font = blf_get(fontid);
930 if (font) {
931 return blf_font_bounds_max(font, r_bounds);
932 }
933 return false;
934}
935
936void BLF_rotation(int fontid, float angle)
937{
938 FontBLF *font = blf_get(fontid);
939
940 if (font) {
941 font->angle = angle;
942 }
943}
944
945void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
946{
947 FontBLF *font = blf_get(fontid);
948
949 if (font) {
950 font->clip_rec.xmin = xmin;
951 font->clip_rec.ymin = ymin;
952 font->clip_rec.xmax = xmax;
953 font->clip_rec.ymax = ymax;
954 }
955}
956
957void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode)
958{
959 FontBLF *font = blf_get(fontid);
960
961 if (font) {
962 font->wrap_width = wrap_width;
963 font->wrap_mode = mode;
964 }
965}
966
967void BLF_shadow(int fontid, FontShadowType type, const float rgba[4])
968{
969 FontBLF *font = blf_get(fontid);
970
971 if (font) {
972 font->shadow = type;
973 if (rgba) {
975 }
976 }
977}
978
979void BLF_shadow_offset(int fontid, int x, int y)
980{
981 FontBLF *font = blf_get(fontid);
982
983 if (font) {
984 font->shadow_x = x;
985 font->shadow_y = y;
986 }
987}
988
989void BLF_buffer(int fontid,
990 float *fbuf,
991 uchar *cbuf,
992 int w,
993 int h,
994 int channel_count,
995 const ColorSpace *colorspace)
996{
997 BLI_assert(channel_count == 1 || channel_count == 4);
998
999 FontBLF *font = blf_get(fontid);
1000
1001 if (font) {
1002 font->buf_info.fbuf = fbuf;
1003 font->buf_info.cbuf = cbuf;
1004 font->buf_info.dims[0] = w;
1005 font->buf_info.dims[1] = h;
1006 font->buf_info.channel_count = channel_count;
1008 }
1009}
1010
1021
1023{
1024 FontBLF *font = blf_get(fontid);
1025 if (font) {
1026 BLFBufferState *buffer_state = MEM_new<BLFBufferState>(__func__);
1027 buffer_state->fontid = fontid;
1028 buffer_state->font = font;
1029 buffer_state->buf_info = font->buf_info;
1030 return buffer_state;
1031 }
1032 return nullptr;
1033}
1034
1036{
1037 FontBLF *font = blf_get(buffer_state->fontid);
1038 /* It's possible the font has been removed as this is called from Python. */
1039 if (font == buffer_state->font) {
1040 /* From the callers perspective, don't consider the color part of the buffer info.
1041 *
1042 * NOTE(@ideasman42) This is done because the color is not logically part of the image binding.
1043 * It looks like we can refactor color out of #FontBufInfoBLF::col_init,
1044 * and use #FontBLF::color instead. */
1045 copy_v4_v4(buffer_state->buf_info.col_init, font->buf_info.col_init);
1046
1047 font->buf_info = buffer_state->buf_info;
1048 }
1049 BLF_buffer_state_free(buffer_state);
1050}
1051
1053{
1054 MEM_delete(buffer_state);
1055}
1056
1057void BLF_buffer_col(int fontid, const float srgb_color[4])
1058{
1059 FontBLF *font = blf_get(fontid);
1060
1061 if (font) {
1062 copy_v4_v4(font->buf_info.col_init, srgb_color);
1063 }
1064}
1065
1067{
1068 FontBufInfoBLF *buf_info = &font->buf_info;
1069
1070 /* This will be written to scene linear image buffer, so convert to that. */
1072 buf_info->col_float[3] = buf_info->col_init[3];
1073
1074 /* Convert to the colorspace of the byte image buffer, assumed sRGB if not specified. */
1075 if (buf_info->colorspace) {
1076 float col_char[4];
1077 copy_v4_v4(col_char, buf_info->col_float);
1079 rgba_float_to_uchar(buf_info->col_char, col_char);
1080 }
1081 else {
1082 rgba_float_to_uchar(buf_info->col_char, buf_info->col_init);
1083 }
1084}
1086
1087void BLF_draw_buffer(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
1088{
1089 FontBLF *font = blf_get(fontid);
1090
1091 if (font && (font->buf_info.fbuf || font->buf_info.cbuf)) {
1093 if (font->flags & BLF_WORD_WRAP) {
1094 blf_font_draw_buffer__wrap(font, str, str_len, r_info);
1095 }
1096 else {
1097 blf_font_draw_buffer(font, str, str_len, r_info);
1098 }
1100 }
1101}
1102
1104 StringRef str,
1105 const int max_pixel_width,
1106 BLFWrapMode mode)
1107{
1108 FontBLF *font = blf_get(fontid);
1109 if (!font) {
1110 return {};
1111 }
1112 return blf_font_string_wrap(font, str, max_pixel_width, mode);
1113}
1114
1115char *BLF_display_name_from_file(const char *filepath)
1116{
1117 /* While listing font directories this function can be called simultaneously from a greater
1118 * number of threads than we want the FreeType cache to keep open at a time. Therefore open
1119 * with a separate FT_Library object and use FreeType calls directly to avoid any contention. */
1120 char *name = nullptr;
1121 FT_Library ft_library;
1122 if (FT_Init_FreeType(&ft_library) == FT_Err_Ok) {
1123 FT_Face face;
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);
1127 }
1128 FT_Done_Face(face);
1129 }
1130 FT_Done_FreeType(ft_library);
1131 }
1132 return name;
1133}
1134
1136{
1137 FontBLF *font = blf_get(fontid);
1138 if (!font) {
1139 return nullptr;
1140 }
1141
1142 return blf_display_name(font);
1143}
1144
1145bool BLF_get_vfont_metrics(int fontid, float *ascend_ratio, float *em_ratio, float *scale)
1146{
1147 FontBLF *font = blf_get(fontid);
1148 if (!font) {
1149 return false;
1150 }
1151
1152 if (!blf_ensure_face(font)) {
1153 return false;
1154 }
1155
1156 /* Copied without change from vfontdata_freetype.cc to ensure consistent sizing. */
1157
1158 /* Blender default BFont is not "complete". */
1159 const bool complete_font = (font->face->ascender != 0) && (font->face->descender != 0) &&
1160 (font->face->ascender != font->face->descender);
1161
1162 if (complete_font) {
1163 /* We can get descender as well, but we simple store descender in relation to the ascender.
1164 * Also note that descender is stored as a negative number. */
1165 *ascend_ratio = float(font->face->ascender) / (font->face->ascender - font->face->descender);
1166 }
1167 else {
1170 }
1171
1172 /* Adjust font size */
1173 if (font->face->bbox.yMax != font->face->bbox.yMin) {
1174 *scale = float(1.0 / double(font->face->bbox.yMax - font->face->bbox.yMin));
1175
1176 if (complete_font) {
1177 *em_ratio = float(font->face->ascender - font->face->descender) /
1178 (font->face->bbox.yMax - font->face->bbox.yMin);
1179 }
1180 }
1181 else {
1183 }
1184
1185 return true;
1186}
1187
1189 uint unicode,
1190 ListBaseT<Nurb> *nurbsbase,
1191 const float scale,
1192 bool use_fallback,
1193 float *r_advance,
1194 rctf *r_bounds)
1195{
1196 FontBLF *font = blf_get(fontid);
1197 if (!font) {
1198 return false;
1199 }
1201 font, unicode, nurbsbase, scale, use_fallback, r_advance, r_bounds);
1202}
1203
1204#ifndef NDEBUG
1205void BLF_state_print(int fontid)
1206{
1207 FontBLF *font = blf_get(fontid);
1208 if (font) {
1209 printf("fontid %d %p\n", fontid, static_cast<void *>(font));
1210 printf(" mem_name: '%s'\n", font->mem_name ? font->mem_name : "<none>");
1211 printf(" filepath: '%s'\n", font->filepath ? font->filepath : "<none>");
1212 printf(" size: %f\n", font->size);
1213 printf(" pos: %d %d %d\n", UNPACK3(font->pos));
1214 printf(" aspect: (%d) %.6f %.6f %.6f\n",
1215 (font->flags & BLF_ROTATION) != 0,
1216 UNPACK3(font->aspect));
1217 printf(" angle: (%d) %.6f\n", (font->flags & BLF_ASPECT) != 0, font->angle);
1218 printf(" flag: %d\n", font->flags);
1219 }
1220 else {
1221 printf("fontid %d (nullptr)\n", fontid);
1222 }
1223 fflush(stdout);
1224}
1225#endif
1226
1227} // namespace blender
#define BLF_VFONT_METRICS_EM_RATIO_DEFAULT
Definition BLF_api.hh:117
#define BLF_VFONT_METRICS_SCALE_DEFAULT
Definition BLF_api.hh:116
#define BLF_VFONT_METRICS_ASCEND_RATIO_DEFAULT
Definition BLF_api.hh:118
File and directory operations.
#define RAD2DEG(_rad)
#define BLI_path_cmp
volatile int lock
#define UNUSED_VARS(...)
#define UNPACK3(a)
#define ELEM(...)
#define STREQ(a, b)
#define BLF_RESULT_CHECK_INIT(r_info)
Definition blf.cc:40
#define BLF_MAX_FONT
#define BLF_VARIATION_AXIS_WEIGHT
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define str(s)
float3x3 scale(float3x3 mat, float2 scale)
BMesh Iterators.
int blf_font_height_max(FontBLF *font)
Definition blf_font.cc:1737
static int blf_search_available()
Definition blf.cc:142
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)
Definition blf.cc:805
bool BLF_is_loaded_id(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:172
int BLF_glyph_advance(int fontid, const char *str)
Definition blf.cc:859
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)
Definition blf_font.cc:1126
void BLF_color3ubv_alpha(int fontid, const unsigned char rgb[3], unsigned char alpha)
Definition blf.cc:466
void BLF_shadow_offset(int fontid, int x, int y)
Definition blf.cc:979
static FontBLF * blf_get(int fontid)
Definition blf.cc:55
void BLF_aspect(int fontid, float x, float y, float z)
Definition blf.cc:379
void BLF_position(int fontid, float x, float y, float z)
Definition blf.cc:390
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
Definition blf.cc:835
bool blf_ensure_face(FontBLF *font)
Definition blf_font.cc:2087
void BLF_batch_draw_flush()
Definition blf.cc:542
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
int BLF_width_max(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:894
int blf_mono_font_render
Definition blf.cc:51
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
Definition blf.cc:967
void blf_font_draw_buffer__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
Definition blf_font.cc:1678
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)
Definition blf.cc:628
void BLF_color3ub(int fontid, unsigned char r, unsigned char g, unsigned char b)
Definition blf.cc:495
void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode=BLFWrapMode::Minimal)
Definition blf.cc:957
uint blf_get_char_index(FontBLF *font, const uint charcode)
Definition blf_font.cc:155
void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int channel_count, const ColorSpace *colorspace)
Definition blf.cc:989
int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
Definition blf.cc:227
int blf_font_draw_mono(FontBLF *font, const char *str, const size_t str_len, const int char_width, const int tab_columns)
Definition blf_font.cc:632
bool BLF_get_vfont_metrics(int fontid, float *ascend_ratio, float *em_ratio, float *scale)
Definition blf.cc:1145
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)
Definition blf.cc:761
float blf_font_fixed_width(FontBLF *font)
Definition blf_font.cc:1197
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
void GPU_matrix_scale_3fv(const float vec[3])
void BLF_default_set(int fontid)
void BLF_batch_draw_begin()
Definition blf.cc:536
BatchBLF g_batch
Definition blf_font.cc:61
Vector< Bounds< int > > blf_str_selection_boxes(FontBLF *font, const char *str, size_t str_len, size_t sel_start, size_t sel_length)
Definition blf_font.cc:1415
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)
Definition blf_font.cc:2277
void BLF_reset_fonts()
Definition blf.cc:85
bool BLF_is_loaded_mem(const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition blf.cc:167
void blf_font_boundbox(FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
Definition blf_font.cc:1118
void blf_font_boundbox__wrap(FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
Definition blf_font.cc:1643
void GPU_matrix_rotate_2d(float deg)
int bool BLF_is_loaded(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition blf.cc:162
void BLF_character_weight(int fontid, int weight)
Definition blf.cc:349
void BLF_addref_id(int fontid)
Definition blf.cc:313
bool BLF_bounds_max(int fontid, rctf *r_bounds) ATTR_NONNULL(2)
Definition blf.cc:927
void BLF_disable(int fontid, FontFlags flag)
Definition blf.cc:331
void BLF_color4f(int fontid, float r, float g, float b, float a)
Definition blf.cc:516
float blf_font_height(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
Definition blf_font.cc:1176
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)
Definition blf_font.cc:1260
void blf_str_offset_to_glyph_bounds(FontBLF *font, const char *str, size_t str_offset, rcti *r_glyph_bounds)
Definition blf_font.cc:1357
Vector< StringRef > blf_font_string_wrap(FontBLF *font, StringRef str, int max_pixel_width, BLFWrapMode mode)
Definition blf_font.cc:1706
size_t blf_font_width_to_strlen(FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
Definition blf_font.cc:981
void BLF_metrics_attach(int fontid, const unsigned char *mem, int mem_size) ATTR_NONNULL(2)
Definition blf.cc:218
void blf_draw_buffer__end()
Definition blf.cc:1085
void blf_font_draw_buffer(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
Definition blf_font.cc:930
void BLF_size(int fontid, float size)
Definition blf.cc:445
FontBLF * blf_font_new_from_mem(const char *mem_name, const uchar *mem, const size_t mem_size)
Definition blf_font.cc:2260
int BLF_load(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition blf.cc:177
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
Definition blf.cc:725
unsigned char uchar
Definition BKE_text.h:58
int blf_font_descender(FontBLF *font)
Definition blf_font.cc:1755
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], const ColorSpace *colorspace)
bool blf_font_bounds_max(FontBLF *font, rctf *r_bounds)
Definition blf_font.cc:1769
int blf_font_glyph_advance(FontBLF *font, const char *str)
Definition blf_font.cc:1205
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 blf_font.cc:1370
void BLF_color3ubv(int fontid, const unsigned char rgb[3])
Definition blf.cc:478
int BLF_default()
float BLF_height(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
Definition blf.cc:870
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)
Definition blf_font.cc:2255
static void blf_draw_gpu__start(const FontBLF *font)
Definition blf.cc:556
void BLF_buffer_state_pop(BLFBufferState *buffer_state)
Definition blf.cc:1035
int BLF_default_weight(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:357
bool(*)(const char *str, size_t str_step_ofs, const rcti *bounds, void *user_dataconst) BLF_GlyphBoundsFn
Definition BLF_api.hh:211
void blf_font_draw__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
Definition blf_font.cc:1617
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)
Definition blf.cc:783
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
Definition blf.cc:945
static int blf_search_by_filepath(const char *filepath)
Definition blf.cc:126
Vector< StringRef > BLF_string_wrap(int fontid, StringRef str, const int max_pixel_width, BLFWrapMode mode=BLFWrapMode::Minimal)
Definition blf.cc:1103
float BLF_fixed_width(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:848
int void BLF_unload(const char *filepath) ATTR_NONNULL(1)
Definition blf.cc:261
void BLF_unload_all()
Definition blf.cc:299
bool BLF_has_variable_weight(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:366
bool BLF_has_glyph(int fontid, unsigned int unicode) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:153
int blf_font_init()
Definition blf_font.cc:1796
static int blf_search_by_mem_name(const char *mem_name)
Definition blf.cc:110
void BLF_batch_draw_end()
Definition blf.cc:549
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:587
int BLF_ascender(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:916
void blf_font_draw(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
Definition blf_font.cc:625
int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL(1
Definition blf.cc:236
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
Definition blf.cc:454
void blf_font_boundbox_foreach_glyph(FontBLF *font, const char *str, const size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data)
Definition blf_font.cc:1222
BLFBufferState * BLF_buffer_state_push(int fontid)
Definition blf.cc:1022
static void blf_draw_gpu__end(const FontBLF *font)
Definition blf.cc:580
void BLF_state_print(int fontid)
Definition blf.cc:1205
void BLF_buffer_col(int fontid, const float srgb_color[4]) ATTR_NONNULL(2)
Definition blf.cc:1057
size_t blf_str_offset_from_cursor_position(FontBLF *font, const char *str, size_t str_len, int location_x)
Definition blf_font.cc:1307
void BLF_color4ub(int fontid, unsigned char r, unsigned char g, unsigned char b, unsigned char alpha)
Definition blf.cc:483
int BLF_draw_mono(int fontid, const char *str, size_t str_len, int char_width, int tab_columns) ATTR_NONNULL(2)
Definition blf.cc:609
FontBLF * global_font[BLF_MAX_FONT]
Definition blf.cc:46
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)
Definition blf.cc:1188
int blf_font_width_max(FontBLF *font)
Definition blf_font.cc:1750
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:883
int BLF_init()
Definition blf.cc:63
void BLF_color3f(int fontid, float r, float g, float b)
Definition blf.cc:530
char * BLF_display_name_from_file(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition blf.cc:1115
void BLF_cache_clear()
Definition blf.cc:100
std::mutex Mutex
Definition BLI_mutex.hh:51
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:905
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)
Definition blf_font.cc:671
bool int BLF_str_offset_to_cursor(int fontid, const char *str, size_t str_len, size_t str_offset, int cursor_width)
Definition blf.cc:738
int BLF_load_unique(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition blf.cc:190
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)
Definition blf_font.cc:713
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)
Definition blf.cc:667
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)
Definition blf.cc:713
void BLF_boundbox_foreach_glyph(int fontid, const char *str, size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data) ATTR_NONNULL(2)
Definition blf.cc:685
void BLF_draw_buffer(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:1087
void BLF_buffer_state_free(BLFBufferState *buffer_state)
Definition blf.cc:1052
size_t blf_font_width_to_rstrlen(FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
Definition blf_font.cc:1010
int blf_mono_font
Definition blf.cc:50
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)
Definition blf.cc:701
void GPU_matrix_translate_3f(float x, float y, float z)
bool blf_font_size(FontBLF *font, float size)
Definition blf_font.cc:2332
bool BLF_is_builtin(int fontid)
Definition blf.cc:340
void blf_glyph_cache_clear(FontBLF *font)
Definition blf_glyph.cc:161
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
Definition blf.cc:822
void GPU_matrix_pop()
float blf_font_width(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info)
Definition blf_font.cc:1155
void blf_draw_buffer__start(FontBLF *font)
Definition blf.cc:1066
void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha)
Definition blf.cc:522
void BLF_rotation(int fontid, float angle)
Definition blf.cc:936
char * BLF_display_name_from_id(int fontid)
Definition blf.cc:1135
void blf_font_attach_from_mem(FontBLF *font, const uchar *mem, const size_t mem_size)
Definition blf_font.cc:2265
void blf_batch_draw()
Definition blf_font.cc:307
void BLF_enable(int fontid, FontFlags flag)
Definition blf.cc:322
@ BLF_DEFAULT
Definition BLF_enums.hh:53
@ BLF_ASPECT
Definition BLF_enums.hh:41
@ BLF_ROTATION
Definition BLF_enums.hh:36
@ BLF_WORD_WRAP
Definition BLF_enums.hh:42
void GPU_matrix_push()
void blf_font_exit()
Definition blf_font.cc:1817
void BLF_color4fv(int fontid, const float rgba[4])
Definition blf.cc:507
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
ocio::ColorSpace ColorSpace
Definition BLF_api.hh:42
Vector< Bounds< int > > BLF_str_selection_boxes(int fontid, const char *str, size_t str_len, size_t sel_start, size_t sel_length)
Definition blf.cc:751
int blf_font_ascender(FontBLF *font)
Definition blf_font.cc:1762
static Mutex g_blf_load_mutex
Definition blf.cc:53
bool BLF_unload_id(int fontid)
Definition blf.cc:282
char * blf_display_name(FontBLF *font)
Definition blf_font.cc:1782
void BLF_exit()
Definition blf.cc:72
#define floorf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const FontBLF * font
Definition blf.cc:1017
FontBufInfoBLF buf_info
Definition blf.cc:1019
unsigned char shadow_color[4]
FontBufInfoBLF buf_info
unsigned char color[4]
std::atomic< uint32_t > reference_count
const ColorSpace * colorspace