Blender
V3.3
|
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wctype.h>
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_math_base_safe.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#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.h"
#include "BKE_curve.h"
#include "BKE_global.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_packedFile.h"
#include "BKE_vfont.h"
#include "BKE_vfontdata.h"
#include "BLO_read_write.h"
Go to the source code of this file.
Classes | |
struct | TempLineInfo |
struct | VFontToCurveIter |
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 *UNUSED(bmain), ID *id_dst, const ID *UNUSED(id_src), 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 (struct VFont *vfont) |
bool | BKE_vfont_is_builtin (const struct 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 (struct Main *bmain, const char *filepath, bool *r_exists) |
VFont * | BKE_vfont_load_exists (struct Main *bmain, const char *filepath) |
static VFont * | which_vfont (Curve *cu, CharInfo *info) |
VFont * | BKE_vfont_builtin_get (void) |
static VChar * | find_vfont_char (VFontData *vfd, unsigned int 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, unsigned int character, 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, 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, int mode, VFontToCurveIter *iter_data, ListBase *r_nubase, const char32_t **r_text, int *r_text_len, bool *r_text_free, struct CharTrans **r_chartransdata) |
bool | BKE_vfont_to_curve_ex (Object *ob, Curve *cu, int mode, ListBase *r_nubase, const char32_t **r_text, int *r_text_len, bool *r_text_free, struct CharTrans **r_chartransdata) |
bool | BKE_vfont_to_curve_nubase (Object *ob, int mode, ListBase *r_nubase) |
bool | BKE_vfont_to_curve (Object *ob, int mode) |
Variables | |
static CLG_LogRef | LOG = {"bke.data_transfer"} |
static ThreadRWMutex | vfont_rwlock = BLI_RWLOCK_INITIALIZER |
IDTypeInfo | IDType_ID_VF |
static const void * | builtin_font_data = NULL |
static int | builtin_font_size = 0 |
VFont Scale Overflow | |
Scale the font to fit inside TextBox bounds.
| |
#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 } |
typedef struct VFontToCurveIter | VFontToCurveIter |
VFont Clipboard | |
struct { | |
char32_t * text_buffer | |
CharInfo * info_buffer | |
size_t len_utf32 | |
size_t len_utf8 | |
} | g_vfont_clipboard = {NULL} |
void | BKE_vfont_clipboard_free (void) |
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 MARGIN_X_MIN (xof_scale + tb_scale.x) |
#define MARGIN_Y_MIN (yof_scale + tb_scale.y) |
typedef struct VFontToCurveIter VFontToCurveIter |
anonymous enum |
void BKE_vfont_build_char | ( | Curve * | cu, |
ListBase * | nubase, | ||
unsigned int | character, | ||
CharInfo * | info, | ||
float | ofsx, | ||
float | ofsy, | ||
float | rot, | ||
int | charidx, | ||
const float | fsize | ||
) |
Definition at line 495 of file vfont.c.
References Nurb::bezt, BLI_addtail(), Nurb::bp, Nurb::charidx, cosf, CU_CHINFO_SMALLCAPS_CHECK, CU_SMOOTH, find_vfont_char(), ListBase::first, Nurb::flag, CharInfo::flag, Nurb::knotsu, Nurb::knotsv, Nurb::mat_nr, CharInfo::mat_nr, MEM_freeN, MEM_malloc_arrayN, MEM_mallocN, Nurb::next, NULL, VChar::nurbsbase, Nurb::pntsu, Nurb::resolu, Curve::resolu, rot, Curve::shear, sinf, Curve::smallcaps_scale, BezTriple::vec, vfont_get_data(), which_vfont(), and x.
Referenced by blender::nodes::node_geo_string_to_curves_cc::create_curve_instances(), and vfont_to_curve().
Definition at line 413 of file vfont.c.
References BKE_vfont_is_builtin(), BKE_vfont_load(), FO_BUILTIN_NAME, G_MAIN, VFont::id, and ID::next.
Referenced by BKE_curve_init(), font_unlink_exec(), blender::nodes::node_geo_string_to_curves_cc::node_init(), and txt_add_object().
Definition at line 228 of file vfont.c.
References builtin_font_data, builtin_font_size, and size().
Referenced by main(), and BlendfileLoadingBaseTest::SetUpTestCase().
Definition at line 1762 of file vfont.c.
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 1800 of file vfont.c.
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 1770 of file vfont.c.
References BKE_vfont_clipboard_free(), BLI_str_utf32_as_utf8_len(), g_vfont_clipboard, len, MEM_freeN, MEM_malloc_arrayN, and NULL.
Definition at line 188 of file vfont.c.
References Nurb::bezt, BKE_packedfile_free(), BLI_freelinkN(), BLI_ghash_free(), BLI_ghashIterator_getValue(), VFontData::characters, VFont::data, ListBase::first, GHASH_ITER, MEM_freeN, NULL, VChar::nurbsbase, and VFont::temp_pf.
Referenced by vfont_free_data().
Definition at line 223 of file vfont.c.
References VFont::filepath, FO_BUILTIN_NAME, and STREQ.
Referenced by BKE_packedfile_pack_all(), BKE_vfont_builtin_get(), open_invoke(), vfont_foreach_path(), vfont_get_data(), and vfont_to_curve().
Definition at line 316 of file vfont.c.
References BKE_libblock_alloc(), BKE_main_blendfile_path(), BKE_packedfile_free(), BKE_packedfile_new(), BKE_vfontdata_from_freetypefont(), BLI_split_file_part(), BLI_strncpy(), VFont::data, FILE_MAXFILE, VFont::filepath, FO_BUILTIN_NAME, G, G_FILE_AUTOPACK, get_builtin_packedfile(), ID_VF, blender::bke::attribute_accessor_functions::is_builtin(), VFontData::name, NULL, VFont::packedfile, pf, STREQ, and VFont::temp_pf.
Referenced by BKE_vfont_builtin_get(), BKE_vfont_load_exists_ex(), and font_open_exec().
Definition at line 394 of file vfont.c.
References BKE_vfont_load_exists_ex(), and NULL.
Definition at line 366 of file vfont.c.
References BKE_main_blendfile_path(), BKE_vfont_load(), BLI_path_abs(), BLI_path_cmp, BLI_strncpy(), FILE_MAX, VFont::filepath, ListBase::first, Main::fonts, VFont::id, ID_BLEND_PATH, id_us_plus(), ID::next, and str.
Referenced by BKE_vfont_load_exists().
Definition at line 658 of file vfont.c.
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().
int BKE_vfont_select_get | ( | Object * | ob, |
int * | r_start, | ||
int * | r_end | ||
) |
Definition at line 618 of file vfont.c.
References BLI_assert, Object::data, Curve::editfont, EditFont::len, NULL, 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(), kill_selection(), material_slot_assign_exec(), set_case(), set_style(), toggle_style_exec(), and vfont_to_curve().
Definition at line 1744 of file vfont.c.
References BKE_vfont_to_curve_ex(), Object::data, NULL, and Curve::nurb.
Referenced by move_cursor(), and text_update_edited().
bool BKE_vfont_to_curve_ex | ( | Object * | ob, |
Curve * | cu, | ||
int | mode, | ||
ListBase * | r_nubase, | ||
const char32_t ** | r_text, | ||
int * | r_text_len, | ||
bool * | r_text_free, | ||
struct CharTrans ** | r_chartransdata | ||
) |
Definition at line 1709 of file vfont.c.
References data, ELEM, FONT_TO_CURVE_SCALE_ITERATIONS, 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 object_convert_exec().
Definition at line 1737 of file vfont.c.
References BKE_vfont_to_curve_ex(), BLI_assert, Object::data, NULL, OB_FONT, and Object::type.
Referenced by curve_from_font_object(), and evaluate_curve_type_object().
|
static |
Definition at line 431 of file vfont.c.
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(), NULL, Nurb::orderu, Nurb::orderv, Nurb::pntsu, Nurb::pntsv, BPoint::radius, Nurb::resolu, Curve::resolu, rot, sinf, BPoint::vec, x, rctf::xmax, rctf::xmin, y, rctf::ymax, and rctf::ymin.
Referenced by vfont_to_curve().
Definition at line 670 of file vfont.c.
References CU_CHINFO_SMALLCAPS_CHECK, CharInfo::flag, NULL, Curve::smallcaps_scale, and VChar::width.
Referenced by vfont_to_curve().
Definition at line 426 of file vfont.c.
References BLI_ghash_lookup(), VFontData::characters, and POINTER_FROM_UINT.
Referenced by BKE_vfont_build_char(), and vfont_to_curve().
|
static |
Definition at line 234 of file vfont.c.
References BKE_packedfile_new_from_memory(), builtin_font_data, builtin_font_size, CLOG_ERROR, LOG, MEM_mallocN, and NULL.
Referenced by BKE_vfont_load(), vfont_get_data(), and vfont_init_data().
Definition at line 683 of file vfont.c.
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 759 of file vfont.c.
References VFontData::ascender, and VFontData::em_height.
Referenced by vfont_descent(), and vfont_to_curve().
|
static |
Definition at line 148 of file vfont.c.
References BKE_packedfile_blend_read(), VFont::data, NULL, VFont::packedfile, and VFont::temp_pf.
|
static |
Definition at line 126 of file vfont.c.
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, NULL, VFont::packedfile, and VFont::temp_pf.
|
static |
Definition at line 77 of file vfont.c.
References BKE_packedfile_duplicate(), BKE_vfontdata_copy(), VFont::data, LIB_ID_CREATE_NO_USER_REFCOUNT, NULL, VFont::packedfile, and VFont::temp_pf.
Definition at line 763 of file vfont.c.
References VFontData::em_height, and vfont_ascent().
Referenced by vfont_to_curve().
|
static |
Definition at line 111 of file vfont.c.
References BKE_bpath_foreach_path_fixed_process(), BKE_BPATH_FOREACH_PATH_SKIP_PACKED, BKE_vfont_is_builtin(), VFont::filepath, BPathForeachPathData::flag, NULL, and VFont::packedfile.
Free (or release) any data used by this font (does not free the font itself).
Definition at line 100 of file vfont.c.
References BKE_packedfile_free(), BKE_vfont_free_data(), NULL, and VFont::packedfile.
Definition at line 249 of file vfont.c.
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, NULL, VFont::packedfile, pf, VFont::temp_pf, THREAD_LOCK_WRITE, and vfont_rwlock.
Referenced by BKE_vfont_build_char(), and vfont_to_curve().
Definition at line 57 of file vfont.c.
References BKE_packedfile_free(), BKE_vfontdata_from_freetypefont(), BLI_strncpy(), VFont::data, VFont::filepath, FO_BUILTIN_NAME, get_builtin_packedfile(), and pf.
|
static |
Definition at line 768 of file vfont.c.
References Curve::align_y, CurveCache::anim_path_accum_length, atan2f, VFontToCurveIter::bisect, BKE_anim_path_get_length(), BKE_nurbList_free(), BKE_vfont_build_char(), BKE_vfont_is_builtin(), BKE_vfont_select_get(), BKE_vfontdata_char_from_freetypefont(), BKE_where_on_path(), BLI_assert, BLI_assert_msg, BLI_rw_mutex_lock(), BLI_rw_mutex_unlock(), BLI_str_utf8_as_utf32(), build_underline(), ceilf, TempLineInfo::char_nr, char_width(), CLAMP, 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_UNDERLINE, CU_CHINFO_WRAP, CU_OVERFLOW_NONE, CU_OVERFLOW_SCALE, CU_OVERFLOW_TRUNCATE, Object_Runtime::curve_cache, CharTrans::dobreak, Curve::editfont, ELEM, VFontData::em_height, find_vfont_char(), CharInfo::flag, float(), FO_CURSDOWN, FO_CURSUP, 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, Curve::linedist, CharTrans::linenr, Curve::lines, M_PI, MARGIN_X_MIN, MARGIN_Y_MIN, CharInfo::mat_nr, VFontToCurveIter::max, MAX2, MAXTEXTBOX, MEM_calloc_arrayN, MEM_callocN, MEM_freeN, MEM_malloc_arrayN, VFontToCurveIter::min, Object::mode, mul_m3_m3m3(), mul_v3_fl(), normalize_v3(), NULL, OB_CURVES_LEGACY, OB_FONT, OB_MODE_EDIT, Object::obmat, Curve::overflow, EditFont::pos, EditFontSelBox::rot, Object::runtime, blender::math::safe_divide(), VFontToCurveIter::scale_to_fit, EditFont::selboxes, EditFont::selboxes_len, 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_to_curve_ex().
Definition at line 399 of file vfont.c.
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().
Definition at line 220 of file vfont.c.
Referenced by BKE_vfont_builtin_register(), and get_builtin_packedfile().
|
static |
Definition at line 221 of file vfont.c.
Referenced by BKE_vfont_builtin_register(), 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 1759 of file vfont.c.
Referenced by copy_selection(), and paste_text_exec().
|
static |
Definition at line 48 of file vfont.c.
Referenced by get_builtin_packedfile(), and vfont_get_data().
|
static |
Definition at line 49 of file vfont.c.
Referenced by vfont_get_data(), and vfont_to_curve().