§
    ÛóÉj  ã            	       óî   — U d Z ddlZddlZddlZddlmZ ddlmZ  ej        e	¦  «        Z
g d¢Zeegef         Zeed<   	 dedefd	„Zdedefd
„Zefdedededefd„Zefdededefd„Zdededefd„ZdS )z#
Various round-to-integer helpers.
é    N)ÚCallable)Ú	TypeAlias)ÚnoRoundÚotRoundÚ
maybeRoundÚ	roundFuncÚnearestMultipleShortestReprÚRoundingFunctionÚvalueÚreturnc                 ó   — | S )z§Return float value unmodified; do not round.

    Args:
            value (float): The input floating-point value.

    Returns
            float: The same value.
    © ©r   s    ú~/home/lighthouse/badge-speaker-benchmark/.benchmark-venv-community/lib64/python3.11/site-packages/fontTools/misc/roundTools.pyr   r      s	   € ð €Ló    c                 óJ   — t          t          j        | dz   ¦  «        ¦  «        S )a  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
            int: The rounded value.
    ç      à?)ÚintÚmathÚfloorr   s    r   r   r   &   s    € õ* �tŒz˜% #™+Ñ&Ô&Ñ'Ô'Ð'r   ÚvÚ	toleranceÚroundc                 óL   —  || ¦  «        }t          || z
  ¦  «        |k    r|n| S )aŠ  Round only if rounding changes the value by no more than a given amount.

    Args:
            value (float): The input floating-point value.
            tolerance (float): The maximum absolute difference permitted.
            round (function): The rounding strategy, taking and giving a float.

    Returns
            float: A rounded value if within tolerance, otherwise the original.
    )Úabs)r   r   r   Úroundeds       r   r   r   >   s1   € ð ˆe�A‰hŒh€GÝ˜' A™+Ñ&Ô&¨)Ò3Ð3ˆ7ˆ7¸Ð:r   c                 óŽ   — | dk     rt          d¦  «        ‚| dk    rt          S | dk    r|S t          j        t          | |¬¦  «        S )aä  Make a conditional rounding strategy from a base strategy and tolerance.

    This preconfigures :func:`maybeRound` with fixed arguments, allowing it to be
    used anywhere a simple rounding function is accepted.

    The tolerance is validated to ensure it is absolute, and the cases where
    rounding would never or always occur are optimized. Rounding must never
    change a value by more than 0.5 for this to be sound (e.g.  :py:func:`ceil`
    could change by too much).

    Args:
            tolerance (float): The maximum absolute difference permitted.
            round (function): The rounding strategy, taking and giving a float.

    Returns
            function: A strategy that conditionally rounds based on tolerance.
    r   z#Rounding tolerance must be positiver   ©r   r   )Ú
ValueErrorr   Ú	functoolsÚpartialr   r   s     r   r   r   M   sR   € ð$ �1‚}€}ÝÐ>Ñ?Ô?Ð?à�A‚~€~Ýˆà�CÒÐØˆåÔ�Z°9ÀEÐJÑJÔJÐJr   Úfactorc                 ó  — | sdS t          | |z  ¦  «        |z  } d|z  }| |z
  }| |z   }t          |¦  «        t          |¦  «        k    r)t          t          t	          | ¦  «        ¦  «        ¦  «        S d}||z  }||z  }t          |¦  «        t          |¦  «        k    r||k    sJ ‚t          t          |¦  «        ¦  «        D ]}||         ||         k    r nŒ|                     d¦  «        }||k     sJ ‚d||z
  z  }|| z  S )a"  Round to nearest multiple of factor and return shortest decimal representation.

    This chooses the float that is closer to a multiple of the given factor while
    having the shortest decimal representation (the least number of fractional decimal
    digits).

    For example, given the following:

    >>> nearestMultipleShortestRepr(-0.61883544921875, 1.0/(1<<14))
    '-0.61884'

    Useful when you need to serialize or print a fixed-point number (or multiples
    thereof, such as F2Dot14 fractions of 180 degrees in COLRv1 PaintRotate) in
    a human-readable form.

    Args:
        value (value): The value to be rounded and serialized.
        factor (float): The value which the result is a close multiple of.

    Returns:
        str: A compact string representation of the value.
    z0.0r   z%.8fú.z%%.%df)r   r   ÚstrÚfloatr   ÚlenÚrangeÚfind)r   r"   ÚepsÚloÚhiÚfmtÚiÚperiods           r   r	   r	   k   s  € ð. ð Øˆuå�E˜F‘NÑ#Ô# fÑ,€EØ
�‰,€CØ	�‰€BØ	�‰€Bå
ˆ2�w„w•#�b‘'”'ÒÐÝ•5�˜u™œÑ&Ô&Ñ'Ô'Ð'à
€CØ	ˆr‰€BØ	ˆr‰€BÝˆr‰7Œ7•c˜"‘g”gÒÐ "¨¢( ( ( (Ý•3�r‘7”7‰^Œ^ð ð ˆØˆaŒ5�B�q”EŠ>ˆ>ØˆEð à�WŠW�S‰\Œ\€FØ�AŠ:ˆ:ˆ:ˆ:Ø
�a˜&‘jÑ
!€CØ�‰;Ðr   )Ú__doc__r   r    ÚloggingÚcollections.abcr   Útypingr   Ú	getLoggerÚ__name__ÚlogÚ__all__r&   r
   Ú__annotations__r   r   r   r   r   r%   r	   r   r   r   ú<module>r9      s‘  ððð ð ð €€€Ø Ð Ð Ð Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð à€gÔ˜Ñ!Ô!€ðð ð €ð '¨ w° ~Ô6Ð �)Ð 6Ð 6Ñ 6ð,ð	�5ð 	˜Uð 	ð 	ð 	ð 	ð(�5ð (˜Sð (ð (ð (ð (ð0 FMð ;ð ;�%ð ; Eð ;Ð2Bð ;ÐQVð ;ð ;ð ;ð ;ð ;Bð Kð K˜ð KÐ'7ð KÐFVð Kð Kð Kð Kð<, uð ,°eð ,Àð ,ð ,ð ,ð ,ð ,ð ,r   