Next / Previous / Contents / Shipman's homepage

22.4. OutBlock.__makeBlock(): Build the block element

This method creates the XSL-FO block and attaches these properties to it:

There is one outright kludge here. For reasons the author has been unable to discern, the height of a font of size N is always N×1.2 when actually rendered. Hence, we will add the negative of that oversize rendering to the space-after property so that the fonts will be “set solid”, before adding the extra leading specified by the --leading option. As an additional fudge factor, we use 1.26, because in some font sizes the column will hold one less line.

listext2
# - - -   O u t B l o c k . m a k e B l o c k

    def makeBlock(self, parent):
        '''Create the block element.

          [ parent is an et.Element ->
              parent  +:=  a block element with OUT_BLOCK_PROPS
                  and additional properties as specified by
                  Args() and self.__isBreak ]
        '''

The space-after value that will be applied is equal to the extra leading specified by Args().extraLeading minus 0.26 times the font size.

listext2
        #-- 1
        # [ spaceAfter  :=  an h.FoDim equal to Args().extraLeading -
        #       (20% of Args().pointSize)
        #   props  :=  an empty dictionary ]
        nominalSize = h.FoDim(Args().pointSize, 'pt')
        correction = nominalSize * Decimal('-0.26')
        spaceAfter = Args().extraLeading + correction
        props = {}

        #-- 2
        if self.__isBreak:
            props['break-before'] = 'column'

        #-- 3
        # [ if spaceAfter is not zero ->
        #     props['space-after'] = str(spaceAfter)
        #   else -> I ]
        if spaceAfter.n != 0:
            props['space-after'] = str(spaceAfter)

        #-- 4
        # [ parent  +:=  a new block element with attributes
        #       OUT_BLOCK_PROPS and props
        #   block  :=  that new block element ]
        block = subElement(parent,
            E.block(OUT_BLOCK_PROPS, props))

        #-- 5
        return block