Fix T95116: Scale to fit fails with a single word & non-zero Y-size

The scale-to-fit option did nothing for single words when
the text box had a height. This happened because it was expected that
text would be wrapped however single words never wrap.

Now the same behavior for zero-height text boxes is used when text
can't be wrapped onto multiple lines.
This commit is contained in:
Campbell Barton 2022-02-24 11:03:31 +11:00
parent 88712453f6
commit c9582b2752
Notes: blender-bot 2023-12-08 16:39:08 +01:00
Referenced by issue #95116, Scale to fit text box fail with a single word & non-zero height
1 changed files with 16 additions and 1 deletions

View File

@ -1001,7 +1001,22 @@ static bool vfont_to_curve(Object *ob,
}
else if (x_used > x_available) {
// CLOG_WARN(&LOG, "linewidth exceeded: %c%c%c...", mem[i], mem[i+1], mem[i+2]);
for (j = i; j && (mem[j] != '\n') && (chartransdata[j].dobreak == 0); j--) {
for (j = i; (mem[j] != '\n') && (chartransdata[j].dobreak == 0); j--) {
/* Special case when there are no breaks possible. */
if (UNLIKELY(j == 0)) {
if (i == slen) {
/* Use the behavior of zero a height text-box when a break cannot be inserted.
*
* Typically when a text-box has any height and overflow is set to scale
* the text will wrap to fit the width as necessary. When wrapping isn't
* possible it's important to use the same code-path as zero-height lines.
* Without this exception a single word will not scale-to-fit (see: T95116). */
tb_scale.h = 0.0f;
}
break;
}
bool dobreak = false;
if (ELEM(mem[j], ' ', '-')) {
ct -= (i - (j - 1));