diff options
Diffstat (limited to 'Lib/fontTools/misc/fixedTools.py')
-rw-r--r-- | Lib/fontTools/misc/fixedTools.py | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/Lib/fontTools/misc/fixedTools.py b/Lib/fontTools/misc/fixedTools.py index 931b665e..f0474abf 100644 --- a/Lib/fontTools/misc/fixedTools.py +++ b/Lib/fontTools/misc/fixedTools.py @@ -17,15 +17,13 @@ functions for converting between fixed-point, float and string representations. The maximum value that can still fit in an F2Dot14. (1.99993896484375) """ -from fontTools.misc.py23 import * -import math +from .roundTools import otRound import logging log = logging.getLogger(__name__) __all__ = [ "MAX_F2DOT14", - "otRound", "fixedToFloat", "floatToFixed", "floatToFixedToFloat", @@ -41,30 +39,6 @@ __all__ = [ MAX_F2DOT14 = 0x7FFF / (1 << 14) -def otRound(value): - """Round float value to nearest integer towards ``+Infinity``. - - The OpenType spec (in the section on `"normalization" of OpenType Font Variations <https://docs.microsoft.com/en-us/typography/opentype/spec/otvaroverview#coordinate-scales-and-normalization>`_) - defines the required method for converting floating point values to - fixed-point. In particular it specifies the following rounding strategy: - - for fractional values of 0.5 and higher, take the next higher integer; - for other fractional values, truncate. - - This function rounds the floating-point value according to this strategy - in preparation for conversion to fixed-point. - - Args: - value (float): The input floating-point value. - - Returns - float: The rounded value. - """ - # See this thread for how we ended up with this implementation: - # https://github.com/fonttools/fonttools/issues/1248#issuecomment-383198166 - return int(math.floor(value + 0.5)) - - def fixedToFloat(value, precisionBits): """Converts a fixed-point number to a float given the number of precision bits. |