Next / Previous / Contents / Shipman's homepage

19.4. BodyLayout.__findHeights(): Calculate lines per column

listext2
# - - -   B o d y L a y o u t . _ _ f i n d H e i g h t s

    def __findHeights(self):
        '''Calculate lines per column.

          [ self.pageBox and self.oddMargins are as invariant ->
              self.linesPerCol  :=  as invariant ]
        '''

First we find the height of one line in points as the sum of the font size plus any extra leading. Then we find the height of the column in points, as the page height minus the top and bottom margins. The number of lines per column is the floor of the quotient.

listext2
        #-- 1
        # [ blockHigh  :=  height of one line block as an h.FoDim
        #   columnHigh  :=  height of one column as an h.FoDim ]
        blockHigh = (h.FoDim(Args().pointSize, "pt") +
                     Args().extraLeading)
        columnHigh = (self.oddDims.pageBox.high -
            (self.oddDims.pageMargins.top +
             self.oddDims.pageMargins.bot + HEADING_EXTENT))
listext2
        #-- 2
        # [ self.linesPerCol  :=  blockHigh divided by
        #       columnHigh, minus one ]
        self.linesPerCol = int(columnHigh.convert("pt").n /
                               blockHigh.convert("pt").n)