I'm wondering how this could be done in TeX:

This is along the lines of Text spirals with TikZ but in a rectangle, with all text the same size, and all text should be at right angles (unlike the above example, where some letters at corners are not.)
Needs to be dynamic as I'm trying to get a whole lot of text on one letter-sized page - think for example a page filled up with text in 7-point font - and have the text fill the entire page (and never overflow onto other pages), no matter how much text exists.
Here's an algorithm in python that gives the kind of rectangular spiral I'm talking about:
def spiral(X, Y):
x = y = 0
dx = 0
dy = -1
for i in range(max(X, Y)**2):
if (-X/2 < x <= X/2) and (-Y/2 < y <= Y/2):
print (x, y)
# DO STUFF...
if x == y or (x < 0 and x == -y) or (x > 0 and x == 1-y):
dx, dy = -dy, dx
x, y = x+dx, y+dy

\documentclass{...}and ending with\end{document}. – Apr 08 '15 at 07:43