� ��gDD����dZddlmZmZddlmZddlmZddlmZm Z ddl m Z ddl m Z ddlmZmZdd lmZdd lmZmZdd lmZmZdd lmZmZmZGd �de��ZGd�de��ZGd�de��Z Gd�de��Z!Gd�de��Z"Gd�de"��Z#Gd�de"��Z$d�Z%Gd�de"��Z&dd�d �Z'Gd!�d"e��Z(Gd#�d$��Z)d%S)&zGlyphSets returned by a TTFont.�)�ABC�abstractmethod)�Mapping)�contextmanager)�copy�deepcopy)�SimpleNamespace)�Vector)�otRound� fixedToFloat)�deprecateFunction)� Transform�DecomposedTransform)� TransformPen�TransformPointPen)�DecomposingRecordingPen�lerpRecordings�replayRecordingc��eZdZdZdd�d�Zedefd���Zed���Zd�Z d �Z d �Z e d e � ��d ���ZdS)� _TTGlyphSetzlGeneric dict-like GlyphSet class that pulls metrics from hmtx and glyph shape from TrueType or CFF. T�� recalcBoundsc�6�||_||_d|jvrd�|jdjD��ni|_|�|ni|_i|_|�|ni|_d|_g|_g|_ ||_ |dj |_ t|�d��dd��|_d|_|r_ddlm}t|�d��d d��|_|j�+||jj|dj|��|_dSdSdS) N�fvarc��i|] }|jd�� S)r��axisTag)�.0�axiss �j/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fontTools/ttLib/ttGlyphSet.py� <dictcomp>z(_TTGlyphSet.__init__.<locals>.<dictcomp>s�� @� @� @��T�\�1� @� @� @�r�hmtx�vmtx�metrics��VarStoreInstancer�HVAR�table)r�font�axes�defaultLocationNormalized�location� rawLocation�originalLocation�depth� locationStack�rawLocationStack� glyphsMappingr%�hMetrics�getattr�get�vMetrics� hvarTable�fontTools.varLib.varStorer'�VarStore� hvarInstancer)�selfr*r-r3rr's r �__init__z_TTGlyphSet.__init__sK��(����� ����"�"� A� @���6�):�)?� @� @� @� @�� �&� %-�$8���b�� ����,4�,@���b����� ���� "���*����V� �,�� ������ 0� 0�)�T�B�B�� ���� � � C� C� C� C� C� C�$�T�X�X�f�%5�%5�w��E�E�D�N��~�)�%6�%6��N�+�T�&�\�->��&�&��"�"�"�  � �*�)r"�resetc#�K�|j�|j��|j�|j��|r=|j���|_|j���|_n%|j���|_i|_|j�|��|j�|�� dV�|j� ��|_|j� ��|_dS#|j� ��|_|j� ��|_wxYw�N) r1�appendr-r2r.r/rr,�update�pop)r<r-r>s r � pushLocationz_TTGlyphSet.pushLocation5s8���� ��!�!�$�-�0�0�0� ��$�$�T�%5�6�6�6� � "� �1�6�6�8�8�D�M�#�=�B�B�D�D�D� � � �M�.�.�0�0�D�M�!�D� � � ���X�&�&�&� �����)�)�)� ;��J�J�J� �.�2�2�4�4�D�M�#�4�8�8�:�:�D� � � ��!�.�2�2�4�4�D�M�#�4�8�8�:�:�D� � :� :� :� :s �D�>Ec#�K� |j}|xjdz c_|V�|xjdzc_dS#|xjdzc_wxYw)N�)r0)r<r0s r � pushDepthz_TTGlyphSet.pushDepthHsT���� ��J�E� �J�J�!�O�J�J��K�K�K� �J�J�!�O�J�J�J�J��D�J�J�!�O�J�J�J�J�J�Js �1�Ac��||jvSr@�r3�r<� glyphNames r � __contains__z_TTGlyphSet.__contains__Qs���D�.�.�.r"c�N�t|j�����Sr@)�iterr3�keys�r<s r �__iter__z_TTGlyphSet.__iter__Ts���D�&�+�+�-�-�.�.�.r"c�*�t|j��Sr@)�lenr3rPs r �__len__z_TTGlyphSet.__len__Ws���4�%�&�&�&r"z#use 'glyphName in glyphSet' instead)�categoryc��||jvSr@rIrJs r �has_keyz_TTGlyphSet.has_keyZs���D�.�.�.r"N)�__name__� __module__� __qualname__�__doc__r=r�boolrDrGrLrQrTr �DeprecationWarningrW�r"r rrs���������GK������8�;�D�;�;�;��^�;�$����^��/�/�/�/�/�/�'�'�'���-�8J����/�/���/�/�/r"rc�&��eZdZd�fd� Zd�Z�xZS)�_TTGlyphSetGlyfTc���|d|_t���|||j|���|�d��|_dS)N�glyfr�gvar)� glyfTable�superr=r6� gvarTable)r<r*r-r� __class__s �r r=z_TTGlyphSetGlyf.__init__bsH����f���� ������x���l��S�S�S����&�)�)����r"c�0�t|||j���S)Nr)� _TTGlyphGlyfrrJs r � __getitem__z_TTGlyphSetGlyf.__getitem__gs���D�)�$�:K�L�L�L�Lr")T�rXrYrZr=rj� __classcell__�rgs@r r`r`asS�������*�*�*�*�*�*� M�M�M�M�M�M�Mr"r`c�F��eZdZ�fd�Zd�Zd�Zedefd���Z�xZ S)�_TTGlyphSetCFFc� ��d|vrdnd}t||j�����dj|_t ���|||j��|�|��dS)N�CFF2zCFF r)�list�cff�values� CharStrings� charStringsrer=� setLocation)r<r*r-�tableTagrgs �r r=z_TTGlyphSetCFF.__init__lsx���#�t�^�^�6�6�����X�� 2� 9� 9� ;� ;�<�<�Q�?�K��� ������x��)9�:�:�:� ����"�"�"�"�"r"c�"�t||��Sr@)� _TTGlyphCFFrJs r rjz_TTGlyphSetCFF.__getitem__rs���4��+�+�+r"c���d|_|rPddlm}t|jdd��}|�0||j|jdj|��}|j|_dSdSd|_dS)Nrr&�varStorer) �blenderr9r'r5rv� otVarStorer*r+�interpolateFromDeltas)r<r-r'r|� instancers r rwz_TTGlyphSetCFF.setLocationus����� � � � D� C� C� C� C� C��t�/��T�B�B�H��#�-�-��'���6�):�)?���� � )�>�� � � � $�#�  �D�L�L�Lr"r>c#�K�|�|��t�|||��5} |V�|�|j��n#|�|j��wxYw ddd��dS#1swxYwYdSr@)rwrrDr-)r<r-r>�values r rDz_TTGlyphSetCFF.pushLocation�s����� ����"�"�"� � %� %�d�H�e� <� <� 0�� 0�� � � �� � ���/�/�/�/��� � ���/�/�/�/����/�  0� 0� 0� 0� 0� 0� 0� 0� 0� 0� 0� 0���� 0� 0� 0� 0� 0� 0s'�B�A�B�A1�1B�B� B) rXrYrZr=rjrwrr\rDrlrms@r roroks}�������#�#�#�#�#� ,�,�,� � � � �0�D�0�0�0��^�0�0�0�0�0r"roc�$��eZdZ�fd�Zd�Z�xZS)�_TTGlyphSetVARCc���||_t���|||��|dj|_dS)N�VARC)�glyphSetrer=r)� varcTable)r<r*r-r�rgs �r r=z_TTGlyphSetVARC.__init__�s8��� �� � ������x��2�2�2��f��+����r"c�f�|j}||jjvr |j|St ||��Sr@)r��Coverage�glyphsr�� _TTGlyphVARC)r<rK�varcs r rjz_TTGlyphSetVARC.__getitem__�s6���~�� �D�M�0� 0� 0��=��+� +��D�)�,�,�,r"rkrms@r r�r��sG�������,�,�,�,�,� -�-�-�-�-�-�-r"r�c�:�eZdZdZdd�d�Zed���Zd�ZdS)�_TTGlyphaSGlyph object that supports the Pen protocol, meaning that it has .draw() and .drawPoints() methods that take a pen object as their only argument. Additionally there are 'width' and 'lsb' attributes, read from the 'hmtx' table. If the font contains a 'vmtx' table, there will also be 'height' and 'tsb' attributes. Trc��||_||_||_|j|\|_|_|j�|j|\|_|_nd\|_|_|j ra|j �\|j j �|j � |��n|j j j|}|xj|j|z c_dSdSdS)N�NN)r��namerr4�width�lsbr7�height�tsbr-r8� AdvWidthMapr*� getGlyphID�mappingr;)r<r�rKr�varidxs r r=z_TTGlyph.__init__�s��� �� ��� �(���'�0��;��� �D�H� � � (�$,�$5�i�$@� !�D�K����$.� !�D�K��� � � 9��!3�!?��%�1�9�� �(�(��3�3�3��'�3�;�I�F� � �J�J�(�0��8� 8�J�J�J�J�  9� 9�!?�!?r"c��t�)�dDraw the glyph onto ``pen``. See fontTools.pens.basePen for details how that works. )�NotImplementedError�r<�pens r �drawz _TTGlyph.draw�s �� "�!r"c�N�ddlm}|�||����dS)�eDraw the glyph onto ``pen``. See fontTools.pens.pointPen for details how that works. r)�SegmentToPointPenN)�fontTools.pens.pointPenr�r�)r<r�r�s r � drawPointsz_TTGlyph.drawPoints�s:�� >�=�=�=�=�=� � � �#�#�C�(�(�)�)�)�)�)r"N)rXrYrZr[r=rr�r�r^r"r r�r��sg��������=A�9�9�9�9�9�$�"�"��^�"� *�*�*�*�*r"r�c�&�eZdZd�Zd�Zd�Zd�ZdS)ric���|���\}}|j���5}|rd}|�||jj|��ddd��dS#1swxYwYdS)r�rN)�_getGlyphAndOffsetr�rGr�rd�r<r��glyph�offsetr0s r r�z_TTGlyphGlyf.draw�s����/�/�1�1� ��v� �]� $� $� &� &� =�%�� ��� �J�J�s�D�M�3�V� <� <� <�  =� =� =� =� =� =� =� =� =� =� =� =���� =� =� =� =� =� =��&A$�$A(�+A(c���|���\}}|j���5}|rd}|�||jj|��ddd��dS#1swxYwYdS)r�rN)r�r�rGr�rdr�s r r�z_TTGlyphGlyf.drawPoints�s����/�/�1�1� ��v� �]� $� $� &� &� C�%�� ��� � � �S�$�-�"9�6� B� B� B�  C� C� C� C� C� C� C� C� C� C� C� C���� C� C� C� C� C� Cr�c���|jjr!|jj�|���}n|jj|j}t |d��r|j|jz nd}||fS)N�xMinr) r�r-rf�_getGlyphInstancerdr��hasattrr�r�)r<r�r�s r r�z_TTGlyphGlyf._getGlyphAndOffset�si�� �=� !� 7�d�m�&=�&I��*�*�,�,�E�E��M�+�D�I�6�E�*1�%��*@�*@�G���E�J�&�&�a���f�}�r"c ���ddlm}ddlm}ddlm}|j}|j}|jj |j }|j }|j }|� |j ||��\} } d\} } |D]�} ||j| j��}|s�| j}d|vrq| �b|� |j ||��\} }|ddkr|dn.t#t%t'|d������} ||| | ��}| ||��|zz } ��t)||j ��}t+|| ||j���\}}}}||_||_|j�||_||_|S)Nr)� iup_delta)�GlyphCoordinates)� supportScalarr�rFr)�fontTools.varLib.iupr��fontTools.ttLib.tables._g_l_y_fr��fontTools.varLib.modelsr�r�rdrf� variationsr�r4r7�_getCoordinatesAndControlsr-r+� coordinatesrr�rangerSr�_setCoordinatesrr�r�r8r�r�)r<r�r�r�r�rdr�r4r7r��_� origCoords�endPts�var�scalar�delta�controlr�r�r�r�r�s r r�z_TTGlyphGlyf._getGlyphInstance�s���2�2�2�2�2�2�D�D�D�D�D�D�9�9�9�9�9�9��=���&� ��'�2�4�9�=� ��$���$��"�=�=� �I�x�� � �� �Q�(�� �F�� <� <�C�"�]�8�#4�c�h�?�?�F�� ���O�E��u�}�}��%�*3�*N�*N�� �8�X�+�+�'�J��'.�a�j�A�o�o��� � �4��c�'�RS�*�o�o�@V�@V�;W�;W��"� �%��V�<�<�� �+�+�E�2�2�V�;� ;�K�K��Y�t�y�)�*�*��"1� �;� ��8I�# �# �# ���s�F�C������� � � %��D�J� �D�K�� r"N)rXrYrZr�r�r�r�r^r"r riri�sS������ =� =� =� C� C� C����(�(�(�(�(r"ric��eZdZd�ZdS)rzc�p�|jj|j�||jj��dS)r�N)r�rvr�r�r}r�s r r�z_TTGlyphCFF.draws1�� � �!�$�)�,�1�1�#�t�}�7L�M�M�M�M�Mr"N)rXrYrZr�r^r"r rzrzs(������N�N�N�N�Nr"rzc���|jdkrH|j}||j}|�|d��}|j}|j}||cxko|kncS|jdkr#|j} | ||jdz } | dkS|jdkr!|jD]} t| |||��sdS�dS|jdkr!|jD]} t| |||��rdS�dS|jdkrt|j |||�� SdS) NrFr��FT��) �Format� AxisIndexrr6�FilterRangeMinValue�FilterRangeMaxValue� DefaultValue�VarIdx�ConditionTable�_evaluateCondition�conditionTable) � condition�fvarAxesr-r�� axisIndexr� axisValue�minValue�maxValuer�� subconditions r r�r�sg����1����'� ��9�%�-���L�L��!�,�,� ��0���0���9�0�0�0�0��0�0�0�0�0� � �Q� � ��&�� ��9�+�,�Q�/�/���q�y�� � �Q� � �%�4� � �L�%�l�H�h� �R�R� ��u�u� ��t� � �Q� � �%�4� � �L�!�,��(�I�N�N� ��t�t� ��u� � �Q� � �%� � $�h��)� � � � ��ur"c� �eZdZd�Zd�Zd�ZdS)r�c�^��ddlm}m}|j}|j}|jj�|j��}|j j |}ddl m } ddl m} |jdj�| |j�|jj��} |jD�]�} | j|jzr4|jj| j} t3| �|jj| ��s�Fi}| j��|jj| j}t;| j��}| j|kr|tA| | jd��z }tC|��tC|��ks&JtC|��tC|��f����fd�tE||��D��}| j#|kr1| | j#}tI| ��} | �%|��| j&}| j|j'z}|jj�(||��5|j�(||��5|j| j)k}|s: |�*| j)||jj+��n#tX$rd }YnwxYw|r�|�-��}| j)|jkr|jn|j}|| j)}|r&t]||��}|�/|��n%ta||��}|�1|��ddd��n #1swxYwYddd��n #1swxYwY���dS) r�r)�VarComponentFlags�NO_VARIATION_INDEX)�MultiVarStoreInstancerr&rN�c�2��i|]\}}�|j|��Sr^r)r�i�vr�s �r r!z&_TTGlyphVARC._draw.<locals>.<dictcomp>is3������/3�q�!�H�Q�K�'����r"T)2�fontTools.ttLib.tables.otTablesr�r�r�r�r�r��indexr��VarCompositeGlyphs�VarCompositeGlyph�fontTools.varLib.multiVarStorer�r9r'r*r+� MultiVarStorer-� components�flags�HAVE_CONDITION� ConditionListr��conditionIndexr��axisIndicesIndex�AxisIndicesList�Itemr � axisValues�axisValuesVarIndex�fi2flrS�zip�transformVarIndexr�applyTransformDeltas� transform�RESET_UNSPECIFIED_AXESrDrK�addVarComponentr.�AttributeError� toTransformrr�rr�)r<r�� isPointPenr�r�r�r��idxr�r�r'r��compr�r-� axisIndicesr��deltasr�r>�shouldDecompose�t� compGlyphSet�g�tPenr�s @r �_drawz_TTGlyphVARC._drawAs$��� � � � � � � � � �=���!���m�"�(�(���3�3���'�9�#�>��I�I�I�I�I�I�?�?�?�?�?�?��=��(�-��*�*� � ��$�-�*@� � � ��$�6 )�6 )�D��z�-�<�<� � �.�=�d�>Q�R� �)��x���)?�������H��$�0�"�2�7��8M�N� �#�D�O�4�4� ��*�.@�@�@��%� �$�2I�(J�B�"O�"O�O�J��;�'�'�3�z�?�?�:�:�:�� �$�$�� �O�O�=�:�:�:�����7:�;� �7S�7S������%�);�;�;�"�4�#9�:����~�~���)�)�&�1�1�1���I��J�!2�!I�I�E���'�4�4�X�u�E�E� )� )��]�/�/��%�@�@�)�)�&*�i�4�>�&A�O�*�3�3��/�/� $�� �4�=�;T������ .�3�3�3�.2�O�O�O�3����'� )�%�1�1�3�3�� $�~���:�:�!�M�M�!)�!2�%� )���8��%�)�#4�S�!�#<�#<�D��L�L��.�.�.�.�#/��Q�#7�#7�D��F�F�4�L�L�L�1)�)�)�)�)�)�)�)�)�)�)����)�)�)�)� )� )� )� )� )� )� )� )� )� )� )���� )� )� )� )��;6 )�6 )s[�L �"L �6&I�L � I, �)L �+I, �,BL �= L � L � L �L �L � L$ �'L$ c�2�|�|d��dS)NF�rr�s r r�z_TTGlyphVARC.draw�s�� � � �3������r"c�2�|�|d��dS)NTr r�s r r�z_TTGlyphVARC.drawPoints�s�� � � �3������r"N)rXrYrZrr�r�r^r"r r�r�@sE������L)�L)�L)�\�������r"r�Trc�Z�t|��dksJ�|dd}|dd}|dd}|dd}td��D]}|d=�|���rxt|��t|j��ksJ�d�|jD��|_t ||j��D]$\} } t | d ��r| \| _| _�%nO|jdkrt|��dksJ�n.t|��t|j ��ksJ�||_ |r|� |��t||z ��} t||z ��} t|j |z ��} t||j z ��}| | | |fS) Nr������r����������rF�����c�,�g|]}t|����Sr^)r)rrs r � <listcomp>z#_setCoordinates.<locals>.<listcomp>�s��D�D�D�4�D��J�J�D�D�Dr"�x)rSr�� isCompositer�r�r�r�y�numberOfContoursr�rr r��yMax)r��coordrdr� leftSideX� rightSideX�topSideY� bottomSideYr��pr�horizontalAdvanceWidth�verticalAdvanceWidth�leftSideBearing�topSideBearings r r�r��s��� �u�:�:��?�?�?�?��b� �!� �I��r��1��J��R�y��|�H���)�A�,�K� �1�X�X���� �"�I�I� ����� "��5�z�z�S��!1�2�2�2�2�2�2�D�D�5�3C�D�D�D����5�%�"2�3�3� #� #�G�A�t��t�S�!�!� #�!"������� #� � �1� $� $��5�z�z�Q�������5�z�z�S��!2�3�3�3�3�3�3�!����&� ���9�%�%�%�$�Z�)�%;�<�<��"�8�k�#9�:�:���e�j�9�4�5�5�O��X�� �2�3�3�N�����  �r"c�2�eZdZdZd d�Zd�Zd�Zd�Zd�ZdS) � LerpGlyphSeta+A glyphset that interpolates between two other glyphsets. Factor is typically between 0 and 1. 0 means the first glyphset, 1 means the second glyphset, and 0.5 means the average of the two glyphsets. Other values are possible, and can be useful to extrapolate. Defaults to 0.5. ��?c�0�||_||_||_dSr@)� glyphset1� glyphset2�factor)r<r&r'r(s r r=zLerpGlyphSet.__init__�s��"���"����� � � r"c�d�||jvr||jvrt||��St|���r@)r&r'� LerpGlyph�KeyError�r<� glyphnames r rjzLerpGlyphSet.__getitem__�s9�� ��� &� &�9���+F�+F��Y��-�-� -��y�!�!�!r"c�&�||jvo||jvSr@)r&r'r,s r rLzLerpGlyphSet.__contains__�s���D�N�*�J�y�D�N�/J�Jr"c��t|j��}t|j��}t|�|����Sr@)�setr&r'rN� intersection�r<�set1�set2s r rQzLerpGlyphSet.__iter__�s<���4�>�"�"���4�>�"�"���D�%�%�d�+�+�,�,�,r"c��t|j��}t|j��}t|�|����Sr@)r0r&r'rSr1r2s r rTzLerpGlyphSet.__len__�s<���4�>�"�"���4�>�"�"���4�$�$�T�*�*�+�+�+r"N)r$) rXrYrZr[r=rjrLrQrTr^r"r r#r#�sq������������ "�"�"� K�K�K�-�-�-� ,�,�,�,�,r"r#c��eZdZd�Zd�ZdS)r*c�"�||_||_dSr@)�glyphsetr-)r<r-r8s r r=zLerpGlyph.__init__�s�� �� �"����r"c�|�t|jj��}|jj|j�|��t|jj��}|jj|j�|��|jj}tt|j |j |��|��dSr@) rr8r&r-r�r'r(rrr�)r<r�� recording1� recording2r(s r r�zLerpGlyph.draw�s���,�T�]�-D�E�E� � � ����/�4�4�Z�@�@�@�,�T�]�-D�E�E� � � ����/�4�4�Z�@�@�@���%����z�'7��9I�6�R�R�TW�X�X�X�X�Xr"N)rXrYrZr=r�r^r"r r*r*�s7������#�#�#�Y�Y�Y�Y�Yr"r*N)*r[�abcrr�collections.abcr� contextlibrrr�typesr �fontTools.misc.vectorr �fontTools.misc.fixedToolsr r r��fontTools.misc.loggingToolsr �fontTools.misc.transformrr�fontTools.pens.transformPenrr�fontTools.pens.recordingPenrrrrr`ror�r�rirzr�r�r�r#r*r^r"r �<module>rFs#��%�%�#�#�#�#�#�#�#�#�#�#�#�#�#�#�%�%�%�%�%�%���������!�!�!�!�!�!�(�(�(�(�(�(�D�D�D�D�D�D�D�D�9�9�9�9�9�9�C�C�C�C�C�C�C�C�G�G�G�G�G�G�G�G�����������J/�J/�J/�J/�J/�'�J/�J/�J/�ZM�M�M�M�M�k�M�M�M�!0�!0�!0�!0�!0�[�!0�!0�!0�H -� -� -� -� -�k� -� -� -�)*�)*�)*�)*�)*�s�)*�)*�)*�XJ�J�J�J�J�8�J�J�J�ZN�N�N�N�N�(�N�N�N� � � �FS�S�S�S�S�8�S�S�S�l>B�#�#�#�#�#�L,�,�,�,�,�7�,�,�,�B Y� Y� Y� Y� Y� Y� Y� Y� Y� Yr"
Memory