[Bf-blender-cvs] [c9582b2752c] blender-v3.1-release: Fix T95116: Scale to fit fails with a single word & non-zero Y-size

Campbell Barton noreply at git.blender.org
Thu Feb 24 02:19:03 CET 2022


Commit: c9582b2752c8e016f128f71a530cab283ba26f64
Author: Campbell Barton
Date:   Thu Feb 24 11:03:31 2022 +1100
Branches: blender-v3.1-release
https://developer.blender.org/rBc9582b2752c8e016f128f71a530cab283ba26f64

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.

===================================================================

M	source/blender/blenkernel/intern/vfont.c

===================================================================

diff --git a/source/blender/blenkernel/intern/vfont.c b/source/blender/blenkernel/intern/vfont.c
index 4a598288ee6..537d49d6f8a 100644
--- a/source/blender/blenkernel/intern/vfont.c
+++ b/source/blender/blenkernel/intern/vfont.c
@@ -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));



More information about the Bf-blender-cvs mailing list