Unless you are using a fixed-width font, it is almost impossible to do that kind of layout using an expression on sourceText alone.
I prefer doing it with text animator like this:
add a position text-animator.
set the position-value to: 10,000 , 10,000
remove the default range and add an expression selector
change its “based on” property to: “Lines”
this is the expression for that selector:
i = textIndex-1; st = text.sourceText.style; ld = st.autoLeading ? st.fontSize*1.2 : st.leading;
rowH = 128; columnW = 360;
itemsPerRow = 8; x = (i%itemsPerRow) * columnW; y = Math.floor(i/itemsPerRow) * rowH;
y-= ld*i; // offset the already present Y-difference caused by newlines [x, y]/100;
This will fill up the “grid” rows first, then columns.
If you want it to fill up by columns first, then change the middle part to:
itemsPerColumn = 8; x = Math.floor(i/itemsPerColumn) * columnW; y = (i%itemsPerColumn) * rowH;
Some extra remarks:
It will look best with the paragraph Right Aligned I suppose.
Make sure that in the Paragraph palette “Add space before” and “…after” and all the other margin parameters are set to 0px. (they don’t get count in the leading and will push each next cell a bit more down and off the grid)
Some Fonts lay out their digits so that they line up nicer in spreadsheets (as if they are fixed-width) but to get that feature, the kerning of your text-layer needs to be set to “Metrics”. Not all fonts have this (for example Museo, Montserrat or more Display/whimsical stuff like Comic sans or Herculanum don’t) but most professional typefaces that are used for layout do.
You can of course hook up some of the parameters to sliders.