Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-02-24 03:03:31 +0300
committerCampbell Barton <campbell@blender.org>2022-02-24 04:18:39 +0300
commitc9582b2752c8e016f128f71a530cab283ba26f64 (patch)
tree3bd856e1632b0b2c06e079db4624b691e0e3a836
parent88712453f6c1a337ad0bf47c039d7c2cb58a5591 (diff)
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.
-rw-r--r--source/blender/blenkernel/intern/vfont.c17
1 files changed, 16 insertions, 1 deletions
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));