def split(self, aW, aH):
        """
        Figure out a nice range of splits

        Assume we would prefer 5 lines (at least) on a splitted flowable
        before a break, and 4 on the last flowable after a break.
        So, the minimum wrap height for a fragment will be 5 * leading
        """
        rW, rH = self.wrap(aW, aH)
        if rH > aH:

            minH1 = getattr(self.style, 'allowOrphans', 5) * self.style.leading
            minH2 = getattr(self.style, 'allowWidows', 4) * self.style.leading

            # If there's no way to fid a decent fragment,
            # refuse to split
            if aH < minH1:
                return []

            # Now, don't split too close to the end either
            pw, ph = self.wrap(aW, aH)
            if ph - aH < minH2:
                aH = ph - minH2

        return XPreformatted.split(self, aW, aH)
Esempio n. 2
0
    def split(self, aW, aH):
        """
        Figure out a nice range of splits

        Assume we would prefer 5 lines (at least) on a splitted flowable
        before a break, and 4 on the last flowable after a break.
        So, the minimum wrap height for a fragment will be 5 * leading
        """
        rW, rH = self.wrap(aW, aH)
        if rH > aH:

            minH1 = getattr(self.style, 'allowOrphans', 5) * self.style.leading
            minH2 = getattr(self.style, 'allowWidows', 4) * self.style.leading

            # If there's no way to fid a decent fragment,
            # refuse to split
            if aH < minH1:
                return []

            # Now, don't split too close to the end either
            pw, ph = self.wrap(aW, aH)
            if ph - aH < minH2:
                aH = ph - minH2

        return XPreformatted.split(self, aW, aH)