|
Blender V5.0
|
#include <algorithm>#include <cmath>#include <cstdlib>#include <cstring>#include <cwctype>#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_math_vector.hh"#include "BLI_rect.h"#include "BLI_string_utf8.h"#include "BLI_threads.h"#include "BLI_utildefines.h"#include "DNA_curve_types.h"#include "DNA_object_types.h"#include "DNA_vfont_types.h"#include "BKE_anim_path.h"#include "BKE_curve.hh"#include "BKE_object_types.hh"#include "BKE_vfont.hh"#include "BKE_vfontdata.hh"Go to the source code of this file.
Classes | |
| struct | VCharPlaceHolder |
| struct | VFontToCurveIter |
| struct | VFontCursor_Params |
| struct | VFontInfoContext |
| struct | TextBoxBounds_ForCursor |
| struct | TempLineInfo |
Macros | |
| #define | MARGIN_X_MIN (cu_offset_scale.x + tb_scale.x) |
| #define | MARGIN_Y_MIN (cu_offset_scale.y + tb_scale.y) |
Functions | |
Private Utilities | |
| static void | mid_v2v2 (float a[2], float b[2]) |
| static float | vfont_metrics_ascent (const VFontData_Metrics *metrics) |
| static float | vfont_metrics_descent (const VFontData_Metrics *metrics) |
| static VFont * | vfont_from_charinfo (const Curve &cu, const CharInfo *info) |
| static VFontData * | vfont_data_ensure_with_lock (VFont *vfont) |
| static bool | vfont_char_find (const VFontData *vfd, char32_t charcode, VChar **r_che) |
| static VChar * | vfont_char_ensure_with_lock (VFont *vfont, char32_t charcode) |
VFont to Curve: Character Placeholder | |
Simple utility to create a dummy VChar on demand which can be used when the character's glyph isn't available. | |
| static VChar * | vfont_placeholder_ensure (VCharPlaceHolder &che_placeholder, char32_t charcode) |
| static VChar * | vfont_char_find_or_placeholder (const VFontData *vfd, char32_t charcode, VCharPlaceHolder &che_placeholder) |
VFont Build Character | |
| static Nurb * | build_underline (const Curve &cu, ListBase *nubase, const rctf *rect, const float yofs, const float rotate, const int charidx, const short mat_nr, const float font_size, Nurb *ul_prev_nu) |
| static void | vfont_char_build_impl (const Curve &cu, ListBase *nubase, const VChar *che, const CharInfo *info, const bool is_smallcaps, const blender::float2 &offset, const float rotate, const int charidx, const float fsize) |
| void | BKE_vfont_char_build (const Curve &cu, ListBase *nubase, uint charcode, const CharInfo *info, const bool is_smallcaps, const blender::float2 &offset, float rotate, int charidx, const float fsize) |
| static float | vfont_char_width (const Curve &cu, VChar *che, const bool is_smallcaps) |
| static char32_t | vfont_char_apply_smallcaps (char32_t charcode, const bool is_smallcaps) |
| static void | textbox_scale (TextBox *tb_dst, const TextBox *tb_src, float scale) |
VFont to Curve: Info Context | |
| static void | vfont_info_context_init (VFontInfoContext *vfinfo_ctx, const Curve &cu) |
| static void | vfont_info_context_update (VFontInfoContext *vfinfo_ctx, const Curve &cu, const CharInfo *info) |
VFont to Curve: 3D Text Layout Implementation | |
| static bool | vfont_to_curve (Object *ob, const 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, float *r_font_size_eval) |
VFont to Curve Public API | |
Access to 3D text layout. | |
| bool | BKE_vfont_to_curve_ex (Object *ob, const Curve &cu, const eEditFontMode mode, ListBase *r_nubase, const char32_t **r_text, int *r_text_len, bool *r_text_free, CharTrans **r_chartransdata, float *r_font_size_eval) |
| int | BKE_vfont_cursor_to_text_index (Object *ob, const blender::float2 &cursor_location) |
| 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 ThreadRWMutex | vfont_rwlock = BLI_RWLOCK_INITIALIZER |
VFont to Curve: Mouse Cursor to Text Offset | |
This is an optional argument to vfont_to_curve for getting the text offset into the string at a mouse cursor location. Used for getting text cursor (caret) position or selection range. | |
| #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 } |
Utilities relating to converting VFont's to curves as well as 3D text object layout.
Definition in file vfont_curve.cc.
| #define FONT_TO_CURVE_SCALE_ITERATIONS 20 |
Definition at line 595 of file vfont_curve.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 596 of file vfont_curve.cc.
Referenced by vfont_to_curve().
| #define MARGIN_X_MIN (cu_offset_scale.x + tb_scale.x) |
Referenced by vfont_to_curve().
| #define MARGIN_Y_MIN (cu_offset_scale.y + tb_scale.y) |
Referenced by vfont_to_curve().
| anonymous enum |
| Enumerator | |
|---|---|
| VFONT_TO_CURVE_INIT | |
| VFONT_TO_CURVE_BISECT | |
| VFONT_TO_CURVE_SCALE_ONCE | |
| VFONT_TO_CURVE_DONE | |
Definition at line 588 of file vfont_curve.cc.
| void BKE_vfont_char_build | ( | const Curve & | cu, |
| ListBase * | nubase, | ||
| uint | charcode, | ||
| const CharInfo * | info, | ||
| const bool | is_smallcaps, | ||
| const blender::float2 & | offset, | ||
| float | rotate, | ||
| int | charidx, | ||
| const float | fsize ) |
Definition at line 489 of file vfont_curve.cc.
References rotate(), vfont_char_build_impl(), vfont_char_find(), vfont_data_ensure_with_lock(), and vfont_from_charinfo().
Referenced by blender::nodes::node_geo_string_to_curves_cc::create_curve_instances().
| int BKE_vfont_cursor_to_text_index | ( | Object * | ob, |
| const blender::float2 & | cursor_location ) |
Definition at line 1876 of file vfont_curve.cc.
References VFontCursor_Params::cursor_location, data, Object::data, ELEM, FO_CURS, FONT_TO_CURVE_SCALE_ITERATIONS, 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().
| bool BKE_vfont_to_curve | ( | Object * | ob, |
| eEditFontMode | mode ) |
Definition at line 1921 of file vfont_curve.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, |
| const Curve & | cu, | ||
| const eEditFontMode | mode, | ||
| ListBase * | r_nubase, | ||
| const char32_t ** | r_text, | ||
| int * | r_text_len, | ||
| bool * | r_text_free, | ||
| CharTrans ** | r_chartransdata, | ||
| float * | r_font_size_eval ) |
Definition at line 1842 of file vfont_curve.cc.
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::ed::object::convert_font_to_curve_legacy_generic(), blender::nodes::node_geo_string_to_curves_cc::get_text_layout(), and make_duplis_font().
| bool BKE_vfont_to_curve_nubase | ( | Object * | ob, |
| const eEditFontMode | mode, | ||
| ListBase * | r_nubase ) |
Definition at line 1913 of file vfont_curve.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 |
| ul_prev_nu | The previous adjacent underline which has it's right edge welded with this underlines left edge to prevent gaps or overlapping geometry which can cause Z-fighting. |
Definition at line 301 of file vfont_curve.cc.
References Nurb::bezt, BLI_addtail(), Nurb::bp, Nurb::charidx, copy_v4_fl4(), cosf, CU_NURB_CYCLIC, Nurb::flagu, i, Nurb::knotsu, Nurb::knotsv, Nurb::mat_nr, MEM_calloc_arrayN(), MEM_callocN(), mid_v2v2(), mul_v2_fl(), Nurb::orderu, Nurb::orderv, Nurb::pntsu, Nurb::pntsv, BPoint::radius, Curve::resolu, Nurb::resolu, rotate(), sinf, BPoint::vec, x, rctf::xmax, rctf::xmin, y, rctf::ymax, and rctf::ymin.
Referenced by vfont_to_curve().
Calculate the mid-point between two points and assign it to both of them.
Definition at line 55 of file vfont_curve.cc.
References b.
Referenced by build_underline().
Definition at line 529 of file vfont_curve.cc.
References TextBox::h, TextBox::w, TextBox::x, and TextBox::y.
Referenced by vfont_to_curve().
|
static |
|
static |
Definition at line 375 of file vfont_curve.cc.
References Nurb::bezt, BLI_addtail(), Nurb::bp, Nurb::charidx, cosf, CU_SMOOTH, ListBase::first, Nurb::flag, i, 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, rotate(), Curve::shear, sinf, Curve::smallcaps_scale, BezTriple::vec, and x.
Referenced by BKE_vfont_char_build(), and vfont_to_curve().
Find the character or lazily initialize it.
The intended use-case for this function is that characters are initialized once. Any future access can then use vfont_char_find or vfont_char_find_or_placeholder.
Definition at line 127 of file vfont_curve.cc.
References BKE_vfontdata_char_from_freetypefont(), BLI_rw_mutex_lock(), BLI_rw_mutex_unlock(), VFont::data, THREAD_LOCK_READ, THREAD_LOCK_WRITE, vfont_char_find(), and vfont_rwlock.
Referenced by vfont_to_curve().
Definition at line 111 of file vfont_curve.cc.
References BLI_ghash_lookup_p(), VFontData::characters, and POINTER_FROM_UINT.
Referenced by BKE_vfont_char_build(), vfont_char_ensure_with_lock(), and vfont_char_find_or_placeholder().
|
static |
A version of vfont_char_find that returns a place-holder if the glyph cannot be found.
Definition at line 273 of file vfont_curve.cc.
References UNLIKELY, vfont_char_find(), and vfont_placeholder_ensure().
Referenced by vfont_to_curve().
Definition at line 508 of file vfont_curve.cc.
References Curve::smallcaps_scale, and VChar::width.
Referenced by vfont_to_curve().
Definition at line 84 of file vfont_curve.cc.
References BKE_vfont_data_ensure(), BLI_rw_mutex_lock(), BLI_rw_mutex_unlock(), VFont::data, THREAD_LOCK_WRITE, and vfont_rwlock.
Referenced by BKE_vfont_char_build(), vfont_info_context_init(), and vfont_info_context_update().
Definition at line 70 of file vfont_curve.cc.
References CU_CHINFO_BOLD, CU_CHINFO_ITALIC, CharInfo::flag, Curve::vfont, Curve::vfontb, Curve::vfontbi, and Curve::vfonti.
Referenced by BKE_vfont_char_build(), and vfont_info_context_update().
|
static |
Definition at line 609 of file vfont_curve.cc.
References BLI_assert, VFontInfoContext::vfd, Curve::vfont, VFontInfoContext::vfont, and vfont_data_ensure_with_lock().
Referenced by vfont_to_curve().
|
static |
Definition at line 618 of file vfont_curve.cc.
References VFontInfoContext::vfd, VFontInfoContext::vfont, vfont_data_ensure_with_lock(), and vfont_from_charinfo().
Referenced by vfont_to_curve().
|
static |
Definition at line 61 of file vfont_curve.cc.
References VFontData_Metrics::ascend_ratio, and VFontData_Metrics::em_ratio.
Referenced by vfont_metrics_descent(), vfont_placeholder_ensure(), and vfont_to_curve().
|
static |
Definition at line 65 of file vfont_curve.cc.
References VFontData_Metrics::em_ratio, and vfont_metrics_ascent().
Referenced by vfont_to_curve().
|
static |
Return a "placeholder" character, used for the glyph not found symbol, used when the font can't be loaded or it doesn't contain the requested glyph.
Definition at line 188 of file vfont_curve.cc.
References ARRAY_SET_ITEMS, ARRAY_SIZE, Nurb::bezt, VCharPlaceHolder::bezt, BLI_addtail(), bounds(), VCharPlaceHolder::che, CU_BEZIER, CU_NURB_CYCLIC, VCharPlaceHolder::data, VFontData_Metrics::em_ratio, Nurb::flagu, BezTriple::h1, BezTriple::h2, HD_VECT, VCharPlaceHolder::initialized, VCharPlaceHolder::metrics, VCharPlaceHolder::nu, VChar::nurbsbase, Nurb::pntsu, Nurb::pntsv, BezTriple::radius, Nurb::resolu, Nurb::type, BezTriple::vec, vfont_metrics_ascent(), and VChar::width.
Referenced by vfont_char_find_or_placeholder(), and vfont_to_curve().
|
static |
This function implements text layout & formatting with font styles, text boxes as well as text cursor placement.
Definition at line 669 of file vfont_curve.cc.
References Curve::align_y, atan2f, VFontToCurveIter::bisect, BKE_anim_path_get_length(), BKE_nurbList_free(), BKE_vfont_select_get(), BKE_vfontdata_metrics_get_defaults(), BKE_where_on_path(), BLI_assert, BLI_assert_msg, BLI_rctf_mul(), BLI_str_utf8_as_utf32(), bounds(), TextBoxBounds_ForCursor::bounds, build_underline(), ceilf, TextBoxBounds_ForCursor::char_index_last, TempLineInfo::char_nr, CLAMP, clamp_f(), 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_SMALLCAPS, CU_CHINFO_STYLE_ALL, CU_CHINFO_UNDERLINE, CU_OVERFLOW_NONE, CU_OVERFLOW_SCALE, CU_OVERFLOW_TRUNCATE, VFontCursor_Params::cursor_location, blender::math::distance_squared(), CharTrans::do_break, Curve::editfont, ELEM, VFontData_Metrics::em_ratio, CharInfo::flag, flag, float, FLT_MAX, FO_CURS, FO_CURS_IS_MOTION, FO_CURSDOWN, FO_CURSUP, FO_DUPLI, FO_EDIT, FO_LINE_BEGIN, FO_LINE_END, FO_PAGEDOWN, FO_PAGEUP, FO_SELCHANGE, EditFont::font_size_eval, FONT_TO_CURVE_SCALE_THRESHOLD, Curve::fsize, EditFontSelBox::h, TextBox::h, i, invert_m4_m4(), VFontToCurveIter::iteration, CharInfo::kern, EditFont::len, Curve::len_char32, Curve::linedist, CharTrans::linenr, M_PI, MARGIN_X_MIN, MARGIN_Y_MIN, CharInfo::mat_nr, VFontToCurveIter::max, max_ff(), max_ii(), MEM_calloc_arrayN(), MEM_freeN(), MEM_malloc_arrayN(), VFontData::metrics, VFontToCurveIter::min, min_ff(), min_ii(), Object::mode, mul_m3_m3m3(), mul_v3_fl(), normalize_v3(), OB_CURVES_LEGACY, OB_FONT, OB_MODE_EDIT, CharTrans::offset, Curve::overflow, EditFont::pos, VFontCursor_Params::r_string_offset, CharTrans::rotate, EditFontSelBox::rotate, 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, Curve::totbox, Object::type, Curve::ulheight, Curve::ulpos, unit_m4(), UNLIKELY, VFontInfoContext::vfd, VFontInfoContext::vfont, vfont_char_apply_smallcaps(), vfont_char_build_impl(), vfont_char_ensure_with_lock(), vfont_char_find_or_placeholder(), vfont_char_width(), vfont_info_context_init(), vfont_info_context_update(), vfont_metrics_ascent(), vfont_metrics_descent(), vfont_placeholder_ensure(), VFONT_TO_CURVE_BISECT, VFONT_TO_CURVE_DONE, VFONT_TO_CURVE_INIT, VFONT_TO_CURVE_SCALE_ONCE, EditFontSelBox::w, TextBox::w, VFontToCurveIter::word_wrap, Curve::wordspace, TempLineInfo::wspace_nr, EditFontSelBox::x, TextBox::x, TempLineInfo::x_max, TempLineInfo::x_min, rctf::xmax, rctf::xmin, Curve::xof, EditFontSelBox::y, TextBox::y, rctf::ymax, rctf::ymin, and Curve::yof.
Referenced by BKE_vfont_cursor_to_text_index(), and BKE_vfont_to_curve_ex().
|
static |
Locking on when manipulating the VFont because multiple objects may share a VFont. Depsgraph evaluation can evaluate multiple objects in different threads, so any changes to the VFont (such as glyph cache) must use locking.
Definition at line 46 of file vfont_curve.cc.
Referenced by vfont_char_ensure_with_lock(), and vfont_data_ensure_with_lock().