Henri Menke
31. August 2016 um 19:45
Dear list,

when I use a body font size other than the standard, issuing \vfill will move the content off the grid. MWE is below. How do I fix this?

Cheers, Henri

---

\setupbodyfont[9pt]
\setuplayout[grid=yes]
\showgrid
\starttext
Hello

\vfill

World
\stoptext

You can calculate the number of lines which have to be inserted to move the text
to the bottom of the text. The first step for this is to put the text which should be
moved into a \vbox which allows paragraphs and not only short texts. Afterwards
you can determine how much space is left on the page and with the \getnoflines
command you get the number of lines for the free space.

%%%% begin example
\define\MoveToBottom
  {\par
   \dowithnextbox
     {\scratchdimen\dimexpr\pagegoal-\pagetotal-\nextboxht-\lineheight\relax
      \getnoflines\scratchdimen
      \emptylines[\number\noflines]%
      \flushnextbox}
     \vbox}

\setuplayout[grid=yes]

\showgrid

\starttext

Hello

\MoveToBottom{World}

\page

\input knuth

\MoveToBottom{\input ward }

\stoptext
%%%% end example

Wolfgang