Ë
    £ehe  ã                   ó€   — d Z ddlZddlZddlZ ej                  e«      Zg d¢Zd„ Zd„ Z	e	fd„Z
e	fd„Zded	ed
efd„Zy)z#
Various round-to-integer helpers.
é    N)ÚnoRoundÚotRoundÚ
maybeRoundÚ	roundFuncÚnearestMultipleShortestReprc                 ó   — | S ©N© ©Úvalues    úW/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fontTools/misc/roundTools.pyr   r      s   € Ø€Ló    c                 óD   — 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
            float: The rounded value.
    ç      à?)ÚintÚmathÚfloorr   s    r   r   r      s   € ô* Œt�z‰z˜% #™+Ó&Ó'Ð'r   c                 ó<   —  || «      }t        || z
  «      |k  r|S | S r	   )Úabs)ÚvÚ	toleranceÚroundÚroundeds       r   r   r   0   s&   € Ù�A‹h€GÜ˜' A™+Ó&¨)Ò3ˆ7Ð:¸Ð:r   c                 ó~   — | dk  rt        d«      ‚| dk(  rt        S | dk\  r|S t        j                  t        | |¬«      S )Nr   z#Rounding tolerance must be positiver   ©r   r   )Ú
ValueErrorr   Ú	functoolsÚpartialr   r   s     r   r   r   5   sC   € Ø�1‚}ÜÐ>Ó?Ð?à�A‚~Üˆà�CÒØˆä×ÑœZ°9ÀEÔJÐJr   r   ÚfactorÚreturnc                 óš  — | syt        | |z  «      |z  } d|z  }| |z
  }| |z   }t        |«      t        |«      k7  rt        t        t	        | «      «      «      S d}||z  }||z  }t        |«      t        |«      k(  r||k7  sJ ‚t        t        |«      «      D ]  }||   ||   k7  sŒ n |j                  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   B   së   € ñ. Øä�E˜F‘NÓ# fÑ,€EØ
�‰,€CØ	�‰€BØ	�‰€Bä
ˆ2ƒw”#�b“'ÒÜ”5œ˜u›Ó&Ó'Ð'à
€CØ	ˆr‰€BØ	ˆr‰€BÜˆr‹7”c˜"“gÒ "¨¢(Ð*Ð*Ü”3�r“7‹^ò ˆØˆa‰5�B�q‘E‹>Ùðð �W‰W�S‹\€FØ�AŠ:Ðˆ:Ø
�a˜&‘jÑ
!€CØ�‰;Ðr   )Ú__doc__r   r   ÚloggingÚ	getLoggerÚ__name__ÚlogÚ__all__r   r   r   r   r$   r#   r   r
   r   r   ú<module>r4      sg   ðñó Û Û à€g×Ñ˜Ó!€ò€òò(ð0 $+ó ;ð
  'ó 
Kð, uð ,°eð ,Àô ,r   