§
    ¢”je  ã                   ó~   — 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dS )z#
Various round-to-integer helpers.
é    N)ÚnoRoundÚotRoundÚ
maybeRoundÚ	roundFuncÚnearestMultipleShortestReprc                 ó   — | S ©N© ©Úvalues    úh/var/www/finuniver-perm.ru/html/portfolio/venv/lib/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
            float: The rounded value.
    ç      à?)ÚintÚmathÚfloorr   s    r   r   r      s    € õ* �tŒz˜% #™+Ñ&Ô&Ñ'Ô'Ð'r   c                 óL   —  || ¦  «        }t          || z
  ¦  «        |k    r|n| S r	   )Úabs)ÚvÚ	toleranceÚroundÚroundeds       r   r   r   0   s/   € Øˆ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 )Nr   z#Rounding tolerance must be positiver   ©r   r   )Ú
ValueErrorr   Ú	functoolsÚpartialr   r   s     r   r   r   5   sP   € Ø�1‚}€}ÝÐ>Ñ?Ô?Ð?à�A‚~€~Ýˆà�CÒÐØˆåÔ�Z°9ÀEÐJÑJÔJÐJr   r   ÚfactorÚreturnc                 ó  — | 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   B   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Ú	getLoggerÚ__name__ÚlogÚ__all__r   r   r   r   r$   r#   r   r
   r   r   ú<module>r4      sÙ   ððð ð €€€Ø Ð Ð Ð Ø €€€à€gÔ˜Ñ!Ô!€ðð ð €ðð ð ð(ð (ð (ð0 $+ð ;ð ;ð ;ð ;ð
  'ð 
Kð 
Kð 
Kð 
Kð, uð ,°eð ,Àð ,ð ,ð ,ð ,ð ,ð ,r   