40 N_(
"Let the text use more space than the specified height")},
45 N_(
"Scale the text size to fit inside the width and height")},
50 N_(
"Only output curves that fit within the width and height. Output the remainder to the "
51 "\"Remainder\" output.")},
52 {0,
nullptr, 0,
nullptr,
nullptr},
60 N_(
"Align text to the left")},
65 N_(
"Align text to the center")},
70 N_(
"Align text to the right")},
75 N_(
"Align text to the left and the right")},
80 N_(
"Align text to the left and the right, with equal character spacing")},
81 {0,
nullptr, 0,
nullptr,
nullptr},
89 N_(
"Align text to the top")},
94 N_(
"Align text to the top line's baseline")},
99 N_(
"Align text to the middle")},
103 N_(
"Bottom Baseline"),
104 N_(
"Align text to the bottom line's baseline")},
109 N_(
"Align text to the bottom")},
110 {0,
nullptr, 0,
nullptr,
nullptr},
118 N_(
"Set the pivot point for each character at its midpoint")},
123 N_(
"Set the pivot point for each character at its top left")},
128 N_(
"Set the pivot point for each character at its top center")},
133 N_(
"Set the pivot point for each character at its top right")},
138 N_(
"Set the pivot point for each character at its bottom left")},
143 N_(
"Set the pivot point for each character at its bottom center")},
148 N_(
"Set the pivot point for each character at its bottom right")},
149 {0,
nullptr, 0,
nullptr,
nullptr},
154 b.use_custom_socket_order();
155 b.allow_any_socket_order();
161 .anonymous_attribute_output()
164 .anonymous_attribute_output()
166 b.add_output<
decl::Vector>(
"Pivot Point"_ustr).anonymous_attribute_output();
175 auto &p =
b.add_panel(
"Alignment"_ustr).default_closed(
true);
184 .
description(
"Point around which to rotate each character instance");
187 auto &p =
b.add_panel(
"Spacing"_ustr).default_closed(
true);
188 p.add_input<
decl::Float>(
"Character Spacing"_ustr).default_value(1.0f).min(0.0f);
189 p.add_input<
decl::Float>(
"Word Spacing"_ustr).default_value(1.0f).min(0.0f);
190 p.add_input<
decl::Float>(
"Line Spacing"_ustr).default_value(1.0f).min(0.0f);
193 auto &p =
b.add_panel(
"Text Box"_ustr).default_closed(
true);
205 .usage_by_menu(
"Overflow"_ustr,
226 if (!
bounds.has_value()) {
227 return {0.0f, 0.0f, 0.0f};
232 switch (pivot_mode) {
248 return {0.0f, 0.0f, 0.0f};
287 if (layout.
text.empty()) {
295 const float font_size = std::max(params.
extract_input<
float>(
"Size"_ustr), 0.0f);
296 const float char_spacing = params.
extract_input<
float>(
"Character Spacing"_ustr);
297 const float word_spacing = params.
extract_input<
float>(
"Word Spacing"_ustr);
298 const float line_spacing = params.
extract_input<
float>(
"Line Spacing"_ustr);
299 const float textbox_w = params.
extract_input<
float>(
"Text Box Width"_ustr);
308 cu.smallcaps_scale = 0.75f;
313 cu.fsize = font_size;
314 cu.spacing = char_spacing;
315 cu.wordspace = word_spacing;
316 cu.linedist = line_spacing;
319 cu.tb = MEM_new_array<TextBox>(
MAXTEXTBOX, __func__);
320 cu.tb->w = textbox_w;
321 cu.tb->h = textbox_h;
325 cu.len_char32 = len_chars;
330 memcpy(cu.str, layout.
text.c_str(), len_bytes + 1);
331 cu.strinfo = MEM_new_array<CharInfo>(len_chars + 1, __func__);
336 const char32_t *r_text =
nullptr;
337 float final_font_size = 0.0f;
363 layout.
text.c_str(), layout.
text.size(), i + 1);
365 layout.
text = layout.
text.substr(0, offset);
372 for (
const int i : layout.
positions.index_range()) {
380 for (
const int i : layout.
positions.index_range()) {
392 MEM_SAFE_DELETE(chartransdata);
393 MEM_SAFE_DELETE(cu.str);
394 MEM_SAFE_DELETE(cu.strinfo);
395 MEM_SAFE_DELETE(cu.tb);
409 for (
int i : layout.
char_codes.index_range()) {
420 const float2 char_offset = {0, 0};
422 cu, &cu.
nurb, layout.
char_codes[i], &charinfo,
false, char_offset, 0, i, 1);
424 if (curves_id ==
nullptr) {
425 if (pivot_required) {
438 curves.transform(size_matrix);
440 if (pivot_required) {
448 const char32_t char_code[2] = {layout.
char_codes[i], 0};
449 char inserted_utf8[8] = {0};
451 geometry_set.
set_name(std::string(inserted_utf8,
len));
468 for (const int i : range) {
469 handles[i] = char_handles.lookup(layout.char_codes[i]);
470 transforms[i] = math::from_location<float4x4>(
471 {layout.positions[i].x, layout.positions[i].y, 0});
486 *line_id, AttrDomain::Instance);
494 *line_id, AttrDomain::Instance);
505 for (
const int i : layout.
char_codes.index_range()) {
523 params.
set_output(
"Remainder"_ustr, std::move(layout->truncated_text));
526 if (layout->positions.is_empty()) {
533 auto instances = std::make_unique<bke::Instances>();
546 ntype.
ui_name =
"String to Curves";
548 "Generate a paragraph of text with a specific font, using a curve instance to store each "
Low-level operations for curves.
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_STRING_TO_CURVES
#define BLT_I18NCONTEXT_ID_TEXT
Read Blender memory allocation and freeing.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void reinitialize(const int64_t new_size)
constexpr IndexRange()=default
MutableSpan< int > reference_handles_for_write()
int add_reference(const InstanceReference &reference)
bke::MutableAttributeAccessor attributes_for_write()
MutableSpan< float4x4 > transforms_for_write()
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
void error_message_add(const NodeWarningType type, StringRef message) const
std::optional< std::string > get_output_anonymous_attribute_id_if_needed(const UString output_identifier, const bool force_create=false)
T extract_input(const UString identifier)
T get_input(const UString identifier) const
void set_default_remaining_outputs()
bool anonymous_attribute_output_is_required(const UString output_identifier)
void set_output(const UString identifier, T &&value)
std::optional< std::string > translation_context
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Curves * curve_legacy_to_curves(const Curve &curve_legacy)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
std::optional< Bounds< T > > min_max(const std::optional< Bounds< T > > &a, const T &b)
internal::ShallowZeroInitializeTag shallow_zero_initialize()
void debug_randomize_curve_order(bke::CurvesGeometry *curves)
MatT from_scale(const VecBase< typename MatT::base_type, ScaleDim > &scale)
static Map< int, int > create_curve_instances(GeoNodeExecParams ¶ms, TextLayout &layout, bke::Instances &instances)
static void add_instances_from_handles(bke::Instances &instances, const Map< int, int > &char_handles, const TextLayout &layout)
static const EnumPropertyItem rna_node_geometry_string_to_curves_align_y_items[]
static void create_attributes(GeoNodeExecParams ¶ms, const TextLayout &layout, bke::Instances &instances)
static void node_init(bNodeTree *, bNode *node)
static float3 get_pivot_point(GeoNodeExecParams ¶ms, bke::CurvesGeometry &curves)
static const EnumPropertyItem rna_node_geometry_string_to_curves_overflow_items[]
static const EnumPropertyItem rna_node_geometry_string_to_curves_align_x_items[]
static const EnumPropertyItem rna_node_geometry_string_to_curves_pivot_mode[]
static std::optional< TextLayout > get_text_layout(GeoNodeExecParams ¶ms)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
static void node_register()
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_nurbList_free(ListBaseT< Nurb > *lb)
GeometryNodeStringToCurvesAlignYMode
@ GEO_NODE_STRING_TO_CURVES_ALIGN_Y_BOTTOM_BASELINE
@ GEO_NODE_STRING_TO_CURVES_ALIGN_Y_TOP
@ GEO_NODE_STRING_TO_CURVES_ALIGN_Y_TOP_BASELINE
@ GEO_NODE_STRING_TO_CURVES_ALIGN_Y_BOTTOM
@ GEO_NODE_STRING_TO_CURVES_ALIGN_Y_MIDDLE
size_t BLI_str_utf8_as_utf32(char32_t *__restrict dst_w, const char *__restrict src_c, size_t dst_w_maxncpy) ATTR_NONNULL(1
void BKE_vfont_char_build(const Curve &cu, ListBaseT< Nurb > *nubase, unsigned int charcode, const CharInfo *info, bool is_smallcaps, const float2 &offset, float rotate, int charidx, float fsize)
MatBase< float, 4, 4 > float4x4
bool BKE_vfont_to_curve_ex(Object *ob, const Curve &cu, eEditFontMode mode, ListBaseT< Nurb > *r_nubase, const char32_t **r_text, int *r_text_len, bool *r_text_free, CharTrans **r_chartransdata, float *r_font_size_eval)
size_t size_t BLI_str_utf32_as_utf8(char *__restrict dst, const char32_t *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
VecBase< float, 2 > float2
BMesh const char void * data
int BLI_str_utf8_offset_from_index(const char *str, size_t str_len, int index_target) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
GeometryNodeStringToCurvesAlignXMode
@ GEO_NODE_STRING_TO_CURVES_ALIGN_X_FLUSH
@ GEO_NODE_STRING_TO_CURVES_ALIGN_X_CENTER
@ GEO_NODE_STRING_TO_CURVES_ALIGN_X_JUSTIFY
@ GEO_NODE_STRING_TO_CURVES_ALIGN_X_RIGHT
@ GEO_NODE_STRING_TO_CURVES_ALIGN_X_LEFT
VFont * BKE_vfont_builtin_ensure()
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes) ATTR_NONNULL(1
VecBase< float, 3 > float3
GeometryNodeStringToCurvesOverflowMode
@ GEO_NODE_STRING_TO_CURVES_MODE_TRUNCATE
@ GEO_NODE_STRING_TO_CURVES_MODE_OVERFLOW
@ GEO_NODE_STRING_TO_CURVES_MODE_SCALE_TO_FIT
GeometryNodeStringToCurvesPivotMode
@ GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_BOTTOM_RIGHT
@ GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_MIDPOINT
@ GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_BOTTOM_CENTER
@ GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_TOP_CENTER
@ GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_BOTTOM_LEFT
@ GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_TOP_LEFT
@ GEO_NODE_STRING_TO_CURVES_PIVOT_MODE_TOP_RIGHT
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void set_name(std::string name)
static constexpr int _200
MutableVArraySpan< T > span
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_instances(std::unique_ptr< Instances > instances)
Vector< char32_t > char_codes
std::string truncated_text
Array< int > line_numbers
Map< int, float3 > pivot_points
Array< int > word_numbers
Vector< float2 > positions