Next / Previous / Contents / Shipman's homepage

9.8. FoDim.convert(): Change units

fohelpers.py
# - - -   F o D i m . c o n v e r t

    def convert(self, newUnits):
        '''Convert to the same value in different units (appproximately).
        '''

For the static method that computes the conversion factor for an arbitrary pair of XSL-FO units, see Section 9.9, “FoDim.confactor(): Find the conversion factor between two units”.

fohelpers.py
        #-- 1 --
        # [ factor   :=  the number by which self.n must be multiplied
        #       to convert from self.units to newUnits ]
        factor = FoDim.confactor(self.units, newUnits)

        #-- 2 --
        return FoDim(self.n * factor, newUnits)