[Bf-blender-cvs] [0c32e3b3122] master: Fix T91756: String to Curve node produces NaN when size is zero
Jacques Lucke
noreply at git.blender.org
Wed Sep 29 12:40:46 CEST 2021
Commit: 0c32e3b312212196b2748327713ab3bc31825412
Author: Jacques Lucke
Date: Wed Sep 29 12:40:36 2021 +0200
Branches: master
https://developer.blender.org/rB0c32e3b312212196b2748327713ab3bc31825412
Fix T91756: String to Curve node produces NaN when size is zero
===================================================================
M source/blender/blenkernel/intern/font.c
===================================================================
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 1053b727cbc..0e159418724 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -34,6 +34,7 @@
#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"
@@ -794,8 +795,8 @@ static bool vfont_to_curve(Object *ob,
bool ok = false;
const float font_size = cu->fsize * iter_data->scale_to_fit;
const bool word_wrap = iter_data->word_wrap;
- const float xof_scale = cu->xof / font_size;
- const float yof_scale = cu->yof / font_size;
+ const float xof_scale = safe_divide(cu->xof, font_size);
+ const float yof_scale = safe_divide(cu->yof, font_size);
int last_line = -1;
/* Length of the text disregarding \n breaks. */
float current_line_length = 0.0f;
@@ -889,7 +890,7 @@ static bool vfont_to_curve(Object *ob,
linedist = cu->linedist;
curbox = 0;
- textbox_scale(&tb_scale, &cu->tb[curbox], 1.0f / font_size);
+ textbox_scale(&tb_scale, &cu->tb[curbox], safe_divide(1.0f, font_size));
use_textbox = (tb_scale.w != 0.0f);
xof = MARGIN_X_MIN;
More information about the Bf-blender-cvs
mailing list