� ��g'K��<�dZddlmZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z ddlmZmZmZmZmZmZmZmZmZddlmZmZddlmZmZmZmZm Z m!Z!m"Z"ej#e$��Z%eeeege&fZ'd-d�Z(dde(fd.d�Z)dde(fd/d�Z*d0d�Z+d1d!�Z,d2d%�Z-d3d)�Z.d4d,�Z/dS)5z�Allows building all the variable fonts of a DesignSpace version 5 by splitting the document into interpolable sub-space, then into each VF. �)� annotationsN)�Any�Callable�Dict�Iterator�List�Tuple�cast) �AxisDescriptor�AxisMappingDescriptor�DesignSpaceDocument�DiscreteAxisDescriptor�InstanceDescriptor�RuleDescriptor�SimpleLocationDict�SourceDescriptor�VariableFontDescriptor)� StatNames� getStatNames)� ConditionSet�Range�Region�getVFUserRegion�locationInRegion�regionInRegion�userRegionToDesignRegion�docr �instancer� statNamesr�return�strc��|jp|j�d��}|jp|j�d��}|�d|�d�S)z�Default callable to synthesize an instance filename when makeNames=True, for instances that don't specify an instance name in the designspace. This part of the name generation can be overriden because it's not specified by the STAT table. �en�-z.ttf)� familyName� familyNames�get� styleName� styleNames)rrrr%r(s �n/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fontTools/designspaceLib/split.py�defaultMakeInstanceFilenamer+)sW���$�G� �(=�(A�(A�$�(G�(G�J��"�D�i�&:�&>�&>�t�&D�&D�I�� *� *�9� *� *� *�*�T� makeNames�bool�expandLocations�makeInstanceFilename�MakeInstanceFilenameCallable�8Iterator[Tuple[SimpleLocationDict, DesignSpaceDocument]]c #��K�g}i}|jD]z}t|d��r+tt|��}|�|���=tt |��}t |j|j|j ��||j <�{tj d�|D���}|D];}d�t||��D��} t|i|�| �d|||���} | | fV��<dS)a�Split the given DS5 into several interpolable sub-designspaces. There are as many interpolable sub-spaces as there are combinations of discrete axis values. E.g. with axes: - italic (discrete) Upright or Italic - style (discrete) Sans or Serif - weight (continuous) 100 to 900 There are 4 sub-spaces in which the Weight axis should interpolate: (Upright, Sans), (Upright, Serif), (Italic, Sans) and (Italic, Serif). The sub-designspaces still include the full axis definitions and STAT data, but the rules, sources, variable fonts, instances are trimmed down to only keep what falls within the interpolable sub-space. Args: - ``makeNames``: Whether to compute the instance family and style names using the STAT data. - ``expandLocations``: Whether to turn all locations into "full" locations, including implicit default axis values where missing. - ``makeInstanceFilename``: Callable to synthesize an instance filename when makeNames=True, for instances that don't specify an instance name in the designspace. This part of the name generation can be overridden because it's not specified by the STAT table. .. versionadded:: 5.0 �valuesc��g|] }|j�� S�)r4��.0�axiss r*� <listcomp>z%splitInterpolable.<locals>.<listcomp>hs��+Q�+Q�+Q�D�D�K�+Q�+Q�+Qr,c�$�i|] \}}|j|��Sr6��name)r8� discreteAxis�values r*� <dictcomp>z%splitInterpolable.<locals>.<dictcomp>js1�� � � �#� �e� � �u� � � r,T��keepVFsr-r/r0N)�axes�hasattrr r�appendr r�minimum�maximum�defaultr=� itertools�product�zip�_extractSubSpace) rr-r/r0� discreteAxes�interpolableUserRegionr9�valueCombinationsr4�discreteUserLocation�subDocs r*�splitInterpolablerR6sC����D�L�%'���� � �� �4�� "� "� ��.��5�5�D� � � �� %� %� %� %����-�-�D�05�� �� �� �1�1� "�4�9� -� -� "�)�+Q�+Q�L�+Q�+Q�+Q�R��#� +� +�� � �'*�<��'@�'@� � � ��"� � >�%� >�)=� >���+�!5�  � � ��#�F�*�*�*�*�*� +� +r,F�)Iterator[Tuple[str, DesignSpaceDocument]]c #��K�|���D]G}t||��}t||d|||���}i|j�|j�|_|j|fV��HdS)a$Convert each variable font listed in this document into a standalone designspace. This can be used to compile all the variable fonts from a format 5 designspace using tools that can only deal with 1 VF at a time. Args: - ``makeNames``: Whether to compute the instance family and style names using the STAT data. - ``expandLocations``: Whether to turn all locations into "full" locations, including implicit default axis values where missing. - ``makeInstanceFilename``: Callable to synthesize an instance filename when makeNames=True, for instances that don't specify an instance name in the designspace. This part of the name generation can be overridden because it's not specified by the STAT table. .. versionadded:: 5.0 FrAN)�getVariableFontsrrL�libr=)rr-r/r0�vf� vfUserRegion�vfDocs r*�splitVariableFontsrZys�����.�"�"�$�$� � ��&�s�B�/�/� � � � ���+�!5�  � � ��,�u�y�+�B�F�+�� ��g�u�n����� � r,�Dict[str, DesignSpaceDocument]c�v�i}t|��D]&\}}t|��D]\}}d|_|||<��'|S)z�Convert each variable font listed in this document into a standalone format 4 designspace. This can be used to compile all the variable fonts from a format 5 designspace using tools that only know about format 4. .. versionadded:: 5.0 z4.1)rRrZ� formatVersion)r�vfs� _locationrQ�vfNamerYs r*� convert5to4ra�s_�� �C�.�s�3�3� � �� �6�/��7�7� � �M�F�E�"'�E� ��C��K�K� � �Jr,� userRegionrrBc�H ������t��}��fd�}�jD]�}�|j�t�t��r�t |d��r�t t|��}|�t|j |j|j |j t�j |j ���jp|jt�j|j���fd�|jD��dd�� � ����gx|_} d�|jD����jD�]�} t'�fd�| j���D����s�6t'�fd�| j���D����s't.�d| j| j����t3��} | �| j�����| �| j������jD]q}|j| vr� �|j��j |j ks'�j��j|jks�j|jkr!t.�d |j���q�r| �t9| j| j� �������t;����} t=�j| ��|_�j |_ �j!D]�} tE��#| j$�����s�+|�%tM| j'| j(| j)| jtU�|| ����| j+| j,| j-| j.| j/| j0� � � ����|�1��}��1��}|�|� |j2|_2|r}��3��D]h}ti�|��}tk|���rF|�6to|j|j'�fd �|j8D��|j9� �����i�j:D�]@}tE|�;������s�'|�rcty�|�;�����}|j,p|j=�>d��}|j-p|j?�>d��}|�@t�d id|j'p |�||���d|j(�d|j)�d|jp|�d|���d�rin|jB�dtU�||�����d|�d|�d|jCp|jC�d|jDp|jE�>d���d|jFp|jF�d|j2p|j=�d|jGp|j?�d|jHp|jE�d|jIpi�d|j9�������|�@t�d id|j'�d|j(�d|j)�d|j�d�rin|jB�dtU�||�����d|j,�d|j-�d|jC�d|jD�d|jF�d|j2�d|jG�d|jH�d|jI�d|j9������B�j9|_9|S)!Nc�@���r|����S|jS�N)�getFullDesignLocation�designLocation)�objectrr/s ��r*�maybeExpandDesignLocationz3_extractSubSpace.<locals>.maybeExpandDesignLocation�s(��� � )��/�/��4�4� 4��(� (r,rFc�R��g|]#\}}�j|cxkr �jk�nn||f��$Sr6)rFrG)r8�user�design�ranges �r*r:z$_extractSubSpace.<locals>.<listcomp>�sQ������(�D�&� �=�D�A�A�A�A�E�M�A�A�A�A�A��v��A�A�Ar,) �tagr=� labelNames�hiddenrFrHrG�map� axisOrdering� axisLabelsc��h|] }|j�� Sr6r<r7s r*� <setcomp>z#_extractSubSpace.<locals>.<setcomp>�s��4�4�4��$�)�4�4�4r,c3� �K�|]}|�vV�� dSrer6�r8r9� subDocAxess �r*� <genexpr>z#_extractSubSpace.<locals>.<genexpr>�s(�����O�O�$�4�:�%�O�O�O�O�O�Or,c3� �K�|]}|�vV�� dSrer6rws �r*ryz#_extractSubSpace.<locals>.<genexpr>�s(�����P�P�$�4�:�%�P�P�P�P�P�Pr,zPIn axis mapping from input %s, some output axes are not in the variable-font: %szALimiting axis ranges used in <mapping> elements not supported: %s)� inputLocation�outputLocation) �filename�path�fontr=rg� layerNamer%r(� muteKerning�muteInfo�mutedGlyphNamesc�T��g|]$}t�|jt���"|��%Sr6)� isinstancer=r)r8� axisSubsetrbs �r*r:z$_extractSubSpace.<locals>.<listcomp>:s@���%�%�%� *�)�*�Z�_�*E�u�M�M�%�&�%�%�%r,)r=r}� axisSubsetsrVr#r}r~rr=� � userLocationrgr%r(�postScriptFontName�styleMapFamilyName�styleMapStyleName�localisedFamilyName�localisedStyleName�localisedStyleMapFamilyName�localisedStyleMapStyleNamerVr6)Jr rCr=r�rrDr r �addAxisrnrorp�maxrFrH�minrGrq� axisMappings�allr{�keysr|�LOGGER�error�set�updaterEr r�_subsetRulesBasedOnConditions�rules�rulesProcessingLast�sourcesr� map_backwardrg� addSourcerr}r~r�_filterLocationr�r%r(r�r�r�� findDefaultr�rUrr�addVariableFontrr�rV� instances�getFullUserLocationrr&r'r)� addInstancerr�r�r��styleMapFamilyNamesr�r�r�r�)rrbrBr-r/r0rQrir9�mappings�mapping� mappingAxes� designRegion�source� vfDefault� oldDefaultrWrXrrr%r(rmrxs`` ` @@r*rLrL�sk�������!� "� "�F�)�)�)�)�)�)� ������4�9�%�� �e�U� #� #� ���i�(@�(@� ����-�-�D� �N�N������#���;��� �t�|�<�<�!�M�9�T�\��� �t�|�<�<�����,0�H���� "&�#�#��� � � ��,&(�'�F��(�4�4�� �4�4�4�J��#�" �" ���O�O�O�O�'�2G�2L�2L�2N�2N�O�O�O�O�O� � ��P�P�P�P�'�2H�2M�2M�2O�2O�P�P�P�P�P� � �L�L�b��%��&� � � � ��e�e� ����7�0�5�5�7�7�8�8�8����7�1�6�6�8�8�9�9�9��H� � �D��y� �+�+���t�y�)�E�� ���-�-��M�-�%�-�4�<�2O�2O��=�D�L�0�0�� � �W��I����� 1� ��� !�%�3�&�5� � � � � � � �,�C��<�<�L�0���L�I�I�F�L�!$�!8�F���+� � ���� 0� 0��1F� G� G��T�T� � ���� ����[��[��[�.�� 9� 9�&� A� A� � �!�*�!�,� �*�"�.��� &� 6� � � � � � � �&�"�"�$�$�I����"�"�J����!7�(2�(F� �%����&�&�(�(� � �B�*�3��3�3�L��l�J�7�7� ��&�&�*��W�!#��%�%�%�%�.0�n�%�%�%� �F� � � � � � ���M�<�<���� <� <�S� A� A�:�N�N� � � �8 �$�S�(�*F�*F�s�*K�*K�L�L�I�!�,�O� �0E�0I�0I�$�0O�0O�J� �*�L�i�.B�.F�.F�t�.L�.L�I� � � �"����%�.�F�+�+�C��9�E�E���"����"��� � "��E�Z�*E�*E�)�*E�*E�� � (7�!Q���H�<Q�� �$3�"�$=�$=�h�$G�$G�$�$�$�� *�z��(�i��(0�'B�(4� �3���(0�'B�(?� �4�8�8��>�>��� '/�&@�'3� �2��#�$)1�(D�)-� �,��'�((0�'B�(,� �+��+�,19�0T�15� �4��/�008�/R�0���3�4!� � �5� � � � �> � � �"����%�.�.��!����"����"��� � (7�!Q���H�<Q�� � $3�"�$=�$=�h�$G�$G�$�$�$� � (�2�2��'�0�0��(0�'B�'B��(0�'B�'B��'/�&@�&@��)1�(D�(D��(0�'B�'B�� 19�0T�0T�!�"08�/R�/R�#�$!� � �%� � � � �.��F�J� �Mr,� conditionSet�List[Dict[str, Any]]rc���i}|D]b}|�d��|�d��}}t|�|n tj |�|n tj��||d<�c|S)NrFrGr=)r'r�math�inf)r��c� conditionrFrGs r*�_conditionSetFromr��sx���A�!� � � �$�=�=��3�3�Y�]�]�9�5M�5M���$��*�G�G��� ��*�G�G��� � ��)�F� ��� �Hr,r��List[RuleDescriptor]r�c �(�g}|D�] }t|jg|j���}|jD]�}t |��}g}d}|���D]�\} } | |vr� t | ttf��r| || vr�1d}�4| || vr�?|| � | ��} | �$|� | | j | j d�����d}��|s|j� |����|jr|� |���� |S)N)r=� conditionSets�subsFT)r=rFrG) rr=r�r�r��itemsr��float�int� intersectionrErFrG) r�r��newRules�rule�newRule� conditionset�cs�newConditionset�discardConditionset� selectionName�selectionValuer�s r*r�r��s|��$&(�H��)%�)%��"0���"�4�9�# �# �# ��!�.�# >�# >�L�"�<�0�0�B�46�O�"'� �1=�1C�1C�1E�1E� 7� 7�-� �~� ��*�*���n�u�c�l�;�;�7�%��M�):�:�:��/3�+�+�&��M�):�:�:��')�-�'8�'E�'E�n�'U�'U� �'�3�+�2�2�,9�/;�/C�/;�/C�!"�!"�����37�/�/�&� >��%�,�,�_�=�=�=�� � � %� �O�O�G� $� $� $�� �Or,�location�Dict[str, float]c�D���fd�|���D��S)Nc�Z��i|]'\}}|�v� t�|t���$||��(Sr6)r�r)r8r=r?rbs �r*r@z#_filterLocation.<locals>.<dictcomp>�sH��� � � � �D�%� �:� � �*�Z��-=�u�"E�"E� � �e� � � r,)r�)rbr�s` r*r�r��s8��� � � � �#�>�>�+�+� � � �r,)rr rrrrr r!) rr r-r.r/r.r0r1r r2) rr r-r.r/r.r0r1r rS)rr r r[)rr rbrrBr.r-r.r/r.r0r1r r )r�r�r r)r�r�r�rr r�)rbrr�r�r r�)0�__doc__� __future__rrI�loggingr��typingrrrrrr r �fontTools.designspaceLibr r r rrrrrr�"fontTools.designspaceLib.statNamesrr�fontTools.designspaceLib.typesrrrrrrr� getLogger�__name__r�r!r1r+rRrZrarLr�r�r�r6r,r*�<module>r�s`����#�"�"�"�"�"��������� � � � �C�C�C�C�C�C�C�C�C�C�C�C�C�C�C�C�C�C� � � � � � � � � � � � � � � � � � � � � � �G�F�F�F�F�F�F�F������������������� �� �8� $� $��'��,�i�8�#�=� �� +� +� +� +�� �9T� @+�@+�@+�@+�@+�J�!�9T� "�"�"�"�"�J����"U�U�U�U�p � � � �>�>�>�>�B�����r,
Memory