Skip to content

Commit 1b48f08

Browse files
committed
Use 1.05 downscale factor for text width scaling.
In many cases reducing font size by factor 2 changes output width by factor 1.95. To avoid text overflow, add this missing factor.
1 parent 8f4dd28 commit 1b48f08

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/JSRootPainter.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,13 +1581,14 @@
15811581

15821582
if (fo_g.property('_scale')) {
15831583
var box = painter.GetBoundarySizes(fo_g.node());
1584-
painter.TextScaleFactor(1.* box.width / parseInt(fo_g.attr('width')), draw_g);
1584+
painter.TextScaleFactor(1.05* box.width / parseInt(fo_g.attr('width')), draw_g);
15851585
painter.TextScaleFactor(1.* box.height / parseInt(fo_g.attr('height')), draw_g);
15861586
}
15871587
});
15881588

15891589
// adjust font size
15901590
var f = draw_g.property('text_factor');
1591+
15911592
var font = draw_g.property('text_font');
15921593
if ((f>0) && ((f<0.9) || (f>1.))) {
15931594
font.size = Math.floor(font.size/f);
@@ -1708,7 +1709,7 @@
17081709
if (scale) txt.classed('hidden_text',true).attr('opacity','0'); // hide rescale elements
17091710

17101711
if (box.width > draw_g.property('max_text_width')) draw_g.property('max_text_width', box.width);
1711-
if ((w>0) && scale) this.TextScaleFactor(1.*box.width / w, draw_g);
1712+
if ((w>0) && scale) this.TextScaleFactor(1.05*box.width / w, draw_g);
17121713
if ((h>0) && scale) this.TextScaleFactor(1.*box.height / h, draw_g);
17131714

17141715
return box.width;
@@ -2824,7 +2825,7 @@
28242825
for (var n = 0; n < 2; ++n)
28252826
sumw += this.DrawText((n == 0) ? "start" : "end",
28262827
margin_x, posy, width-2*margin_x, stepy, parts[n], jcolor);
2827-
this.TextScaleFactor(sumw/(width-2*margin_x), this.draw_g);
2828+
this.TextScaleFactor(1.05*sumw/(width-2*margin_x), this.draw_g);
28282829
}
28292830
} else {
28302831
this.DrawText(pavetext['fTextAlign'], margin_x, posy, width-2*margin_x, stepy, lines[j], jcolor);

0 commit comments

Comments
 (0)