|
Blender V4.3
|
#include <algorithm>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <cwctype>#include <optional>#include "CLG_log.h"#include "MEM_guardedalloc.h"#include "BLI_ghash.h"#include "BLI_listbase.h"#include "BLI_math_base_safe.h"#include "BLI_math_matrix.h"#include "BLI_math_vector.h"#include "BLI_path_utils.hh"#include "BLI_rect.h"#include "BLI_string.h"#include "BLI_string_utf8.h"#include "BLI_threads.h"#include "BLI_utildefines.h"#include "BLT_translation.hh"#include "DNA_curve_types.h"#include "DNA_object_types.h"#include "DNA_packedFile_types.h"#include "DNA_vfont_types.h"#include "BKE_anim_path.h"#include "BKE_bpath.hh"#include "BKE_curve.hh"#include "BKE_global.hh"#include "BKE_idtype.hh"#include "BKE_lib_id.hh"#include "BKE_main.hh"#include "BKE_object_types.hh"#include "BKE_packedFile.hh"#include "BKE_vfont.hh"#include "BKE_vfontdata.hh"#include "BLO_read_write.hh"Go to the source code of this file.
Classes | |
| struct | TempLineInfo |
| struct | VFontToCurveIter |
| struct | VFontCursor_Params |
| struct | TextBoxBounds_ForCursor |
Macros | |
| #define | MARGIN_X_MIN (xof_scale + tb_scale.x) |
| #define | MARGIN_Y_MIN (yof_scale + tb_scale.y) |
Functions | |
| static PackedFile * | get_builtin_packedfile (void) |
| static void | vfont_init_data (ID *id) |
| static void | vfont_copy_data (Main *, std::optional< Library * >, ID *id_dst, const ID *, const int flag) |
| static void | vfont_free_data (ID *id) |
| static void | vfont_foreach_path (ID *id, BPathForeachPathData *bpath_data) |
| static void | vfont_blend_write (BlendWriter *writer, ID *id, const void *id_address) |
| static void | vfont_blend_read_data (BlendDataReader *reader, ID *id) |
| void | BKE_vfont_free_data (VFont *vfont) |
| bool | BKE_vfont_is_builtin (const VFont *vfont) |
| void | BKE_vfont_builtin_register (const void *mem, int size) |
| static VFontData * | vfont_get_data (VFont *vfont) |
| VFont * | BKE_vfont_load (Main *bmain, const char *filepath) |
| VFont * | BKE_vfont_load_exists_ex (Main *bmain, const char *filepath, bool *r_exists) |
| VFont * | BKE_vfont_load_exists (Main *bmain, const char *filepath) |
| static VFont * | which_vfont (Curve *cu, const CharInfo *info) |
| VFont * | BKE_vfont_builtin_get () |
| static VChar * | find_vfont_char (const VFontData *vfd, uint character) |
| static void | build_underline (Curve *cu, ListBase *nubase, const rctf *rect, float yofs, float rot, int charidx, short mat_nr, const float font_size) |
| void | BKE_vfont_build_char (Curve *cu, ListBase *nubase, uint character, const CharInfo *info, float ofsx, float ofsy, float rot, int charidx, const float fsize) |
| int | BKE_vfont_select_get (Object *ob, int *r_start, int *r_end) |
| void | BKE_vfont_select_clamp (Object *ob) |
| static float | char_width (Curve *cu, VChar *che, const CharInfo *info) |
| static void | textbox_scale (TextBox *tb_dst, const TextBox *tb_src, float scale) |
| static float | vfont_ascent (const VFontData *vfd) |
| static float | vfont_descent (const VFontData *vfd) |
| static bool | vfont_to_curve (Object *ob, Curve *cu, const eEditFontMode mode, VFontToCurveIter *iter_data, VFontCursor_Params *cursor_params, ListBase *r_nubase, const char32_t **r_text, int *r_text_len, bool *r_text_free, CharTrans **r_chartransdata) |
| bool | BKE_vfont_to_curve_ex (Object *ob, Curve *cu, const eEditFontMode mode, ListBase *r_nubase, const char32_t **r_text, int *r_text_len, bool *r_text_free, CharTrans **r_chartransdata) |
| int | BKE_vfont_cursor_to_text_index (Object *ob, const float cursor_location[2]) |
| bool | BKE_vfont_to_curve_nubase (Object *ob, const eEditFontMode mode, ListBase *r_nubase) |
| bool | BKE_vfont_to_curve (Object *ob, const eEditFontMode mode) |
Variables | |
| static CLG_LogRef | LOG = {"bke.data_transfer"} |
| static ThreadRWMutex | vfont_rwlock = BLI_RWLOCK_INITIALIZER |
| const void * | builtin_font_data = nullptr |
| int | builtin_font_size = 0 |
| IDTypeInfo | IDType_ID_VF |
VFont Mouse Cursor to Text Offset | |
This is an optional argument to | |
| #define | FONT_TO_CURVE_SCALE_ITERATIONS 20 |
| #define | FONT_TO_CURVE_SCALE_THRESHOLD 0.0001f |
| enum | { VFONT_TO_CURVE_INIT = 0 , VFONT_TO_CURVE_BISECT , VFONT_TO_CURVE_SCALE_ONCE , VFONT_TO_CURVE_DONE } |
VFont Clipboard | ||
| struct { | ||
| char32_t * text_buffer | ||
| CharInfo * info_buffer | ||
| size_t len_utf32 | ||
| size_t len_utf8 | ||
| } | g_vfont_clipboard = {nullptr} | |
| void | BKE_vfont_clipboard_free () | |
| void | BKE_vfont_clipboard_set (const char32_t *text_buf, const CharInfo *info_buf, const size_t len) | |
| void | BKE_vfont_clipboard_get (char32_t **r_text_buf, CharInfo **r_info_buf, size_t *r_len_utf8, size_t *r_len_utf32) | |
| #define FONT_TO_CURVE_SCALE_ITERATIONS 20 |
Definition at line 768 of file vfont.cc.
Referenced by BKE_vfont_cursor_to_text_index(), and BKE_vfont_to_curve_ex().
| #define FONT_TO_CURVE_SCALE_THRESHOLD 0.0001f |
Definition at line 769 of file vfont.cc.
Referenced by vfont_to_curve().
| #define MARGIN_X_MIN (xof_scale + tb_scale.x) |
Referenced by vfont_to_curve().
| #define MARGIN_Y_MIN (yof_scale + tb_scale.y) |
Referenced by vfont_to_curve().
| anonymous enum |
| void BKE_vfont_build_char | ( | Curve * | cu, |
| ListBase * | nubase, | ||
| uint | character, | ||
| const CharInfo * | info, | ||
| float | ofsx, | ||
| float | ofsy, | ||
| float | rot, | ||
| int | charidx, | ||
| const float | fsize ) |
Definition at line 507 of file vfont.cc.
References Nurb::bezt, BLI_addtail(), Nurb::bp, Nurb::charidx, cosf, CU_CHINFO_SMALLCAPS_CHECK, CU_SMOOTH, find_vfont_char(), ListBase::first, CharInfo::flag, Nurb::flag, Nurb::knotsu, Nurb::knotsv, CharInfo::mat_nr, Nurb::mat_nr, MEM_freeN(), MEM_malloc_arrayN, MEM_mallocN, Nurb::next, VChar::nurbsbase, Nurb::pntsu, Curve::resolu, Nurb::resolu, rot, Curve::shear, sinf, Curve::smallcaps_scale, BezTriple::vec, vfont_get_data(), and which_vfont().
Referenced by blender::nodes::node_geo_string_to_curves_cc::create_curve_instances(), and vfont_to_curve().
| VFont * BKE_vfont_builtin_get | ( | ) |
Return the built-in VFont, without adding a user (the user-count may be zero). The caller is responsible for adding a user.
Definition at line 422 of file vfont.cc.
References BKE_vfont_is_builtin(), BKE_vfont_load(), BLI_assert, FO_BUILTIN_NAME, G_MAIN, VFont::id, id_us_min(), LISTBASE_FOREACH, and ID::us.
Referenced by BKE_curve_init(), font_unlink_exec(), blender::nodes::node_geo_string_to_curves_cc::node_init(), and txt_add_object().
| void BKE_vfont_builtin_register | ( | const void * | mem, |
| int | size ) |
Definition at line 237 of file vfont.cc.
References builtin_font_data, builtin_font_size, and size().
Referenced by main(), and BlendfileLoadingBaseTest::SetUpTestCase().
| void BKE_vfont_clipboard_free | ( | ) |
Definition at line 2063 of file vfont.cc.
References g_vfont_clipboard, and MEM_SAFE_FREE.
Referenced by BKE_vfont_clipboard_set(), paste_text_exec(), and WM_exit_ex().
| void BKE_vfont_clipboard_get | ( | char32_t ** | r_text_buf, |
| CharInfo ** | r_info_buf, | ||
| size_t * | r_len_utf8, | ||
| size_t * | r_len_utf32 ) |
Definition at line 2101 of file vfont.cc.
References g_vfont_clipboard.
Referenced by copy_selection(), paste_selection(), and paste_text_exec().
| void BKE_vfont_clipboard_set | ( | const char32_t * | text_buf, |
| const CharInfo * | info_buf, | ||
| const size_t | len ) |
Definition at line 2071 of file vfont.cc.
References BKE_vfont_clipboard_free(), BLI_str_utf32_as_utf8_len(), g_vfont_clipboard, len, MEM_freeN(), and MEM_malloc_arrayN.
Referenced by copy_selection().
Definition at line 2007 of file vfont.cc.
References VFontCursor_Params::cursor_location, Object::data, ELEM, FO_CURS, FONT_TO_CURVE_SCALE_ITERATIONS, VFontToCurveIter::iteraction, Curve::nurb, VFontCursor_Params::r_string_offset, Curve::totbox, vfont_to_curve(), VFONT_TO_CURVE_BISECT, VFONT_TO_CURVE_INIT, and VFONT_TO_CURVE_SCALE_ONCE.
Referenced by font_cursor_text_index_from_event().
| void BKE_vfont_free_data | ( | VFont * | vfont | ) |
Definition at line 200 of file vfont.cc.
References Nurb::bezt, BKE_packedfile_free(), BLI_freelinkN(), BLI_ghash_free(), BLI_ghashIterator_getValue(), VFontData::characters, VFont::data, ListBase::first, GHASH_ITER, MEM_freeN(), VChar::nurbsbase, and VFont::temp_pf.
Referenced by vfont_free_data().
| bool BKE_vfont_is_builtin | ( | const VFont * | vfont | ) |
Definition at line 232 of file vfont.cc.
References VFont::filepath, FO_BUILTIN_NAME, and STREQ.
Referenced by BKE_packedfile_pack_all(), BKE_vfont_builtin_get(), BKE_vfontdata_char_from_freetypefont(), open_invoke(), vfont_foreach_path(), and vfont_get_data().
Definition at line 325 of file vfont.cc.
References BKE_libblock_alloc(), BKE_main_blendfile_path(), BKE_packedfile_free(), BKE_packedfile_new(), BKE_vfontdata_from_freetypefont(), BLI_path_split_file_part(), VFont::data, FILE_MAXFILE, VFont::filepath, FO_BUILTIN_NAME, G, G_FILE_AUTOPACK, get_builtin_packedfile(), ID_VF, VFontData::name, VFont::packedfile, pf, STREQ, STRNCPY, and VFont::temp_pf.
Referenced by BKE_vfont_builtin_get(), BKE_vfont_load_exists_ex(), and font_open_exec().
Definition at line 403 of file vfont.cc.
References BKE_vfont_load_exists_ex().
Definition at line 376 of file vfont.cc.
References BKE_main_blendfile_path(), BKE_vfont_load(), BLI_path_abs(), BLI_path_cmp, FILE_MAX, Main::fonts, ID_BLEND_PATH, id_us_plus(), LISTBASE_FOREACH, and STRNCPY.
Referenced by BKE_vfont_load_exists().
| void BKE_vfont_select_clamp | ( | Object * | ob | ) |
Definition at line 670 of file vfont.cc.
References BLI_assert, CLAMP_MAX, Object::data, Curve::editfont, EditFont::len, OB_FONT, EditFont::pos, EditFont::selend, EditFont::selstart, and Object::type.
Referenced by delete_exec(), and ED_curve_editfont_make().
Definition at line 630 of file vfont.cc.
References BLI_assert, Object::data, Curve::editfont, EditFont::len, OB_FONT, EditFont::pos, EditFont::selend, EditFont::selstart, and Object::type.
Referenced by change_spacing_exec(), copy_selection(), cut_text_exec(), delete_exec(), font_paste_wchar(), font_select_to_buffer(), kill_selection(), material_slot_assign_exec(), set_case(), set_style(), toggle_style_exec(), and vfont_to_curve().
| bool BKE_vfont_to_curve | ( | Object * | ob, |
| eEditFontMode | mode ) |
Definition at line 2044 of file vfont.cc.
References BKE_vfont_to_curve_ex(), Object::data, and Curve::nurb.
Referenced by move_cursor(), and text_update_edited().
| bool BKE_vfont_to_curve_ex | ( | Object * | ob, |
| Curve * | cu, | ||
| const eEditFontMode | mode, | ||
| ListBase * | r_nubase, | ||
| const char32_t ** | r_text, | ||
| int * | r_text_len, | ||
| bool * | r_text_free, | ||
| CharTrans ** | r_chartransdata ) |
Definition at line 1983 of file vfont.cc.
References ELEM, FONT_TO_CURVE_SCALE_ITERATIONS, VFontToCurveIter::iteraction, Curve::totbox, vfont_to_curve(), VFONT_TO_CURVE_BISECT, VFONT_TO_CURVE_INIT, and VFONT_TO_CURVE_SCALE_ONCE.
Referenced by BKE_curve_minmax(), BKE_vfont_to_curve(), BKE_vfont_to_curve_nubase(), blender::nodes::node_geo_string_to_curves_cc::get_text_layout(), make_duplis_font(), and blender::ed::object::object_convert_exec().
| bool BKE_vfont_to_curve_nubase | ( | Object * | ob, |
| const eEditFontMode | mode, | ||
| ListBase * | r_nubase ) |
Definition at line 2036 of file vfont.cc.
References BKE_vfont_to_curve_ex(), BLI_assert, Object::data, OB_FONT, and Object::type.
Referenced by curve_from_font_object(), and evaluate_curve_type_object().
|
static |
Definition at line 443 of file vfont.cc.
References Nurb::bezt, BLI_addtail(), Nurb::bp, Nurb::charidx, copy_v4_fl4(), cosf, CU_NURB_CYCLIC, Nurb::flagu, Nurb::knotsu, Nurb::knotsv, Nurb::mat_nr, MEM_calloc_arrayN, MEM_callocN, mul_v2_fl(), Nurb::orderu, Nurb::orderv, Nurb::pntsu, Nurb::pntsv, BPoint::radius, Curve::resolu, Nurb::resolu, rot, sinf, BPoint::vec, rctf::xmax, rctf::xmin, y, rctf::ymax, and rctf::ymin.
Referenced by vfont_to_curve().
Definition at line 682 of file vfont.cc.
References CU_CHINFO_SMALLCAPS_CHECK, CharInfo::flag, Curve::smallcaps_scale, and VChar::width.
Referenced by vfont_to_curve().
Definition at line 438 of file vfont.cc.
References BLI_ghash_lookup(), VFontData::characters, and POINTER_FROM_UINT.
Referenced by BKE_vfont_build_char(), and vfont_to_curve().
|
static |
Definition at line 243 of file vfont.cc.
References BKE_packedfile_new_from_memory(), builtin_font_data, builtin_font_size, CLOG_ERROR, LOG, and MEM_mallocN.
Referenced by BKE_vfont_load(), vfont_get_data(), and vfont_init_data().
Definition at line 695 of file vfont.cc.
References TextBox::h, TextBox::w, TextBox::x, and TextBox::y.
Referenced by vfont_to_curve().
Font metric values explained:
Baseline: Line where the text "rests", used as the origin vertical position for the glyphs. Em height: Space most glyphs should fit within. Ascent: the recommended distance above the baseline to fit most characters. Descent: the recommended distance below the baseline to fit most characters.
We obtain ascent and descent from the font itself (FT_Face->ascender / face->height). And in some cases it is even the same value as FT_Face->bbox.yMax/yMin (font top and bottom respectively).
The em_height here is relative to FT_Face->bbox.
Definition at line 788 of file vfont.cc.
References VFontData::ascender, and VFontData::em_height.
Referenced by vfont_descent(), and vfont_to_curve().
|
static |
Definition at line 160 of file vfont.cc.
References BKE_packedfile_blend_read(), VFont::data, VFont::filepath, VFont::packedfile, and VFont::temp_pf.
|
static |
Definition at line 138 of file vfont.cc.
References BKE_id_blend_write(), BKE_packedfile_blend_write(), BLO_write_id_struct, BLO_write_is_undo(), VFont::data, VFont::id, ID_IS_OVERRIDE_LIBRARY, VFont::packedfile, and VFont::temp_pf.
|
static |
Definition at line 86 of file vfont.cc.
References BKE_packedfile_duplicate(), BKE_vfontdata_copy(), VFont::data, flag, LIB_ID_CREATE_NO_USER_REFCOUNT, VFont::packedfile, and VFont::temp_pf.
Definition at line 792 of file vfont.cc.
References VFontData::em_height, and vfont_ascent().
Referenced by vfont_to_curve().
|
static |
Definition at line 121 of file vfont.cc.
References BKE_bpath_foreach_path_fixed_process(), BKE_BPATH_FOREACH_PATH_SKIP_PACKED, BKE_vfont_is_builtin(), VFont::filepath, BPathForeachPathData::flag, and VFont::packedfile.
|
static |
Free (or release) any data used by this font (does not free the font itself).
Definition at line 110 of file vfont.cc.
References BKE_packedfile_free(), BKE_vfont_free_data(), and VFont::packedfile.
Definition at line 258 of file vfont.cc.
References BKE_packedfile_duplicate(), BKE_packedfile_free(), BKE_packedfile_new(), BKE_vfont_is_builtin(), BKE_vfontdata_from_freetypefont(), BLI_rw_mutex_lock(), BLI_rw_mutex_unlock(), CLOG_WARN, VFont::data, VFont::filepath, FO_BUILTIN_NAME, get_builtin_packedfile(), VFont::id, ID_BLEND_PATH_FROM_GLOBAL, LOG, VFont::packedfile, pf, STRNCPY, VFont::temp_pf, THREAD_LOCK_WRITE, and vfont_rwlock.
Referenced by BKE_vfont_build_char(), and vfont_to_curve().
|
static |
Definition at line 66 of file vfont.cc.
References BKE_packedfile_free(), BKE_vfontdata_from_freetypefont(), VFont::data, VFont::filepath, FO_BUILTIN_NAME, get_builtin_packedfile(), pf, and STRNCPY.
|
static |
Definition at line 813 of file vfont.cc.
References Curve::align_y, atan2f, VFontToCurveIter::bisect, BKE_anim_path_get_length(), BKE_nurbList_free(), BKE_vfont_build_char(), BKE_vfont_select_get(), BKE_vfontdata_char_from_freetypefont(), BKE_where_on_path(), BLI_assert, BLI_assert_msg, BLI_rctf_mul(), BLI_rw_mutex_lock(), BLI_rw_mutex_unlock(), BLI_str_utf8_as_utf32(), bounds(), TextBoxBounds_ForCursor::bounds, build_underline(), ceilf, TextBoxBounds_ForCursor::char_index_last, TempLineInfo::char_nr, char_width(), CLAMP, clamp_f(), CLAMP_MIN, compare_ff_relative(), copy_m3_m4(), cosf, CU_ALIGN_X_FLUSH, CU_ALIGN_X_JUSTIFY, CU_ALIGN_X_LEFT, CU_ALIGN_X_MIDDLE, CU_ALIGN_X_RIGHT, CU_ALIGN_Y_BOTTOM, CU_ALIGN_Y_BOTTOM_BASELINE, CU_ALIGN_Y_CENTER, CU_ALIGN_Y_TOP, CU_ALIGN_Y_TOP_BASELINE, CU_CHINFO_OVERFLOW, CU_CHINFO_SMALLCAPS, CU_CHINFO_SMALLCAPS_CHECK, CU_CHINFO_STYLE_ALL, CU_CHINFO_UNDERLINE, CU_CHINFO_WRAP, CU_OVERFLOW_NONE, CU_OVERFLOW_SCALE, CU_OVERFLOW_TRUNCATE, VFontCursor_Params::cursor_location, CharTrans::dobreak, Curve::editfont, ELEM, VFontData::em_height, find_vfont_char(), CharInfo::flag, flag, float, FLT_MAX, FO_CURS, FO_CURSDOWN, FO_CURSUP, FO_DUPLI, FO_EDIT, FO_PAGEDOWN, FO_PAGEUP, FO_SELCHANGE, FONT_TO_CURVE_SCALE_THRESHOLD, Curve::fsize, Curve::fsize_realtime, EditFontSelBox::h, TextBox::h, invert_m4_m4(), VFontToCurveIter::iteraction, CharInfo::kern, EditFont::len, Curve::len_char32, len_squared_v2v2(), Curve::linedist, CharTrans::linenr, Curve::lines, M_PI, MARGIN_X_MIN, MARGIN_Y_MIN, CharInfo::mat_nr, VFontToCurveIter::max, max_ff(), max_ii(), MAXTEXTBOX, MEM_calloc_arrayN, MEM_freeN(), MEM_malloc_arrayN, VFontToCurveIter::min, min_ff(), min_ii(), Object::mode, mul_m3_m3m3(), mul_v3_fl(), normalize_v3(), OB_CURVES_LEGACY, OB_FONT, OB_MODE_EDIT, Curve::overflow, EditFont::pos, VFontCursor_Params::r_string_offset, CharTrans::rot, EditFontSelBox::rot, rotate_v2_v2fl(), Object::runtime, safe_divide(), VFontToCurveIter::scale_to_fit, EditFont::selboxes, EditFont::selboxes_len, EditFont::select_char_info_flag, EditFont::selend, EditFont::selstart, sinf, Curve::spacemode, Curve::spacing, VFontToCurveIter::status, Curve::str, Curve::strinfo, Curve::tb, textbox_scale(), EditFont::textbuf, EditFont::textbufinfo, EditFont::textcurs, Curve::textoncurve, THREAD_LOCK_READ, THREAD_LOCK_WRITE, Curve::totbox, Object::totcol, Object::type, Curve::ulheight, Curve::ulpos, unit_m4(), UNLIKELY, Curve::vfont, vfont_ascent(), vfont_descent(), vfont_get_data(), vfont_rwlock, VFONT_TO_CURVE_BISECT, VFONT_TO_CURVE_DONE, VFONT_TO_CURVE_INIT, VFONT_TO_CURVE_SCALE_ONCE, EditFontSelBox::w, TextBox::w, which_vfont(), VFontToCurveIter::word_wrap, Curve::wordspace, TempLineInfo::wspace_nr, EditFontSelBox::x, TextBox::x, TempLineInfo::x_max, TempLineInfo::x_min, rctf::xmax, rctf::xmin, CharTrans::xof, Curve::xof, EditFontSelBox::y, TextBox::y, rctf::ymax, rctf::ymin, CharTrans::yof, and Curve::yof.
Referenced by BKE_vfont_cursor_to_text_index(), and BKE_vfont_to_curve_ex().
Definition at line 408 of file vfont.cc.
References CU_CHINFO_BOLD, CU_CHINFO_ITALIC, CharInfo::flag, Curve::vfont, Curve::vfontb, Curve::vfontbi, and Curve::vfonti.
Referenced by BKE_vfont_build_char(), and vfont_to_curve().
| const void* builtin_font_data = nullptr |
Definition at line 63 of file vfont.cc.
Referenced by BKE_vfont_builtin_register(), BKE_vfontdata_char_from_freetypefont(), and get_builtin_packedfile().
| int builtin_font_size = 0 |
Definition at line 64 of file vfont.cc.
Referenced by BKE_vfont_builtin_register(), BKE_vfontdata_char_from_freetypefont(), and get_builtin_packedfile().
| struct { ... } g_vfont_clipboard |
Referenced by BKE_vfont_clipboard_free(), BKE_vfont_clipboard_get(), and BKE_vfont_clipboard_set().
| IDTypeInfo IDType_ID_VF |
| size_t len_utf8 |
Definition at line 2060 of file vfont.cc.
Referenced by copy_selection(), font_select_to_buffer(), and paste_text_exec().
|
static |
Definition at line 54 of file vfont.cc.
Referenced by get_builtin_packedfile(), and vfont_get_data().
|
static |
Definition at line 55 of file vfont.cc.
Referenced by vfont_get_data(), and vfont_to_curve().