# How to fill a whole rectangle with text?

I have a rectangle with specified dimensions and I'd like to fill it with text, so that the text uses all (well, as much as possible) of the available area.

I tried to do it with

Framed@Pane[
TextCell[ExampleData[{"Text", "LoremIpsum"}],
TextJustification -> 0, TextAlignment -> Center, ImageMargins -> 0],
ImageSize -> 1/2 {1920, 1080}, ImageSizeAction -> "ResizeToFit",
Alignment -> {Center, Center}]


I'm not concerned about the little gaps caused by the TextJustification option, but ImageSizeAction -> "ResizeToFit" bothers me because it leaves empty spaces at the top and bottom of the rectangle. This becomes more apparent when the rectangle size gets bigger, and I want to make some very large images.

Rectangle size 960x540:

Rectangle size 1920x1080:

I would expect that the font size would increase to fill the empty space, but this does not happen.

-
Strange indeed. If I magnify my view at some point it behaves correctly. I would try to do it differently because the end user could just change his zoom and ruin the format. Leaving the fonts free to get magnified seems troublesome.By the way, if you don't use ImageSize at all it seems fine. –  tchronis Mar 2 at 13:27
Looks like a bug to me. I used StringTake[ExampleData[...], n] and varied n with a Manipulate. For some string lengths the font is magnified as expected, for others it isn't. –  Simon Woods Mar 2 at 13:53

You can use a scaled font size with FontSize -> Scaled[1/100] that automatically changes with the rectangle size (but all of the text might not be used). This gives the following rectangles:
One limitation is that Scaled depends on the width and not on the height. If the aspect ratio of all the images is the same, then it won't be much of a problem. –  Michael E2 Mar 2 at 17:30
Thanks, with FontSize -> Scaled[] and the addition of FontTracking and LineSpacing (and lots of trial and error) I managed to completely fill the rectangle. It should be noted that as soon as the text overflows the rectangle and is cut off, the evaluation takes a really long time - this is most probably a bug. –  shrx Mar 2 at 19:18