Fix T91756: String to Curve node produces NaN when size is zero

This commit is contained in:
Jacques Lucke 2021-09-29 12:40:36 +02:00
parent 4cf4bb2664
commit 0c32e3b312
Notes: blender-bot 2023-02-14 08:40:26 +01:00
Referenced by issue #91756, String to Curves node produces NaN when size is zero
1 changed files with 4 additions and 3 deletions

View File

@ -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;