3

The createjs.Text class provides the usage of lineWidth, lineHeight, maxHeight, maxWidth, etc..

I can define a custom font size for my text but i need to calculate it.

Here is my code:

var headline = new createjs.Text("", "30px Arial", "#111");
headline.text = "My Test Headline";
headline.maxHeight = myMaxHeight * 0.1;
headline.maxWidth  = myMaxWidth;

var description = new createjs.Text("", "Arial", "#111");
description.text = "example Text, its size changes";
description.font = "" + 15 + "px Arial"; // here i want to calculate the font size
description.y = headline.maxHeight + 20;
description.lineWidth = myMaxHeight;
description.maxHeight = headline.maxHeight - description.y;
description.textBaseline = "top";
description.textAlign = "left";

The description text can change, i want to fit a bigger and smaller text in the space.

For example two pictures with the same text one doesn't got a font size the other one got a font size of 15px. If the text is bigger one, the font size should shrink. A smaller Text could got a font size of 15px or so.

enter image description here

enter image description here

How can i calculate a font size?

oops
  • 179
  • 1
  • 8

0 Answers0