Ë
    £èhà1  ã                  óZ  — d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	 d dl
mZ d dlmZmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZ d dlmZ g d¢Zeeef   ZdZdej:                  d df	 	 	 	 	 	 	 	 	 	 	 dd„Zdej:                  d df	 	 	 	 	 	 	 	 	 	 	 dd„Zd d„Z d!d"d„Z!	 	 	 	 	 	 	 	 	 	 d#d„Z"	 	 	 	 	 	 	 	 	 	 d$d„Z#dej:                  d ddf	 	 	 	 	 	 	 	 	 	 	 d%d„Z$d„ Z%d&d„Z&d'd„Z'd(d„Z(ejR                   G d„ dejT                  «      «       Z+e+jX                  fd)d„Z-e+jX                  dfd)d„Z.y)*é    )Úannotations)ÚUnionN)ÚTextÚAttribÚHatchÚ
DXFGraphic)Úconst)ÚTextEntityAlignmentÚMAP_TEXT_ENUM_TO_ALIGN_FLAGS)ÚMatrix44ÚBoundingBox)Úpath)ÚPath)Úfonts)ÚEntityQuery)	Úmake_path_from_strÚmake_paths_from_strÚmake_hatches_from_strÚmake_path_from_entityÚmake_paths_from_entityÚmake_hatches_from_entityÚvirtual_entitiesÚexplodeÚKind)ÚTEXTÚATTRIBç      ð?c                ó  — t        | «      dk(  r
t        «       S t        |«      }t        | ||«      }t	        j
                  |gd¬«      }|j                  j                  |«      }	t        |	|||«      }
|�|
|z  }
|j                  |
«      S )a«  Convert a single line string `s` into a :term:`Multi-Path` object.
    The text `size` is the height of the uppercase letter "X" (cap height).
    The paths are aligned about the insertion point at (0, 0).
    BASELINE means the bottom of the letter "X".

    Args:
         s: text to convert
         font: font face definition as :class:`~ezdxf.tools.fonts.FontFace` object
         size: text size (cap height) in drawing units
         align: alignment as :class:`ezdxf.enums.TextEntityAlignment`,
            default is :attr:`LEFT`
         length: target length for the :attr:`ALIGNED` and :attr:`FIT` alignments
         m: transformation :class:`~ezdxf.math.Matrix44`

    r   T)Úfast)
Úlenr   Úget_fontÚ_str_to_pathr   ÚbboxÚmeasurementsÚscale_from_baselineÚalignment_transformationÚ	transform)ÚsÚfontÚsizeÚalignÚlengthÚmÚabstract_fontÚpr#   Údraw_units_fmÚmatrixs              ú6lib/python3.12/site-packages/ezdxf/addons/text2path.pyr   r       s„   € ô. ˆ1ƒv�‚{Ü‹vˆÜ˜T“N€Mä�Q˜ tÓ,€AÜ�9‰9�a�S˜tÔ$€Dð "×.Ñ.×BÑBÀ4ÓH€MÜ% m°T¸5À&ÓI€FØ€}Ø�!‰ˆØ�;‰;�vÓÐó    c                ót   — t        | «      dk(  rg S t        | |||||«      }t        |j                  «       «      S )a  Convert a single line string `s` into a list of
    :class:`~ezdxf.path.Path` objects. All paths are returned as a list of
    :term:`Single-Path` objects.
    The text `size` is the height of the uppercase letter "X" (cap height).
    The paths are aligned about the insertion point at (0, 0).
    BASELINE means the bottom of the letter "X".

    Args:
         s: text to convert
         font: font face definition as :class:`~ezdxf.tools.fonts.FontFace` object
         size: text size (cap height) in drawing units
         align: alignment as :class:`ezdxf.enums.TextEntityAlignment`,
            default is :attr:`LEFT`
         length: target length for the :attr:`ALIGNED` and :attr:`FIT` alignments
         m: transformation :class:`~ezdxf.math.Matrix44`

    r   )r    r   ÚlistÚ	sub_paths)r(   r)   r*   r+   r,   r-   r/   s          r2   r   r   G   s9   € ô2 ˆ1ƒv�‚{Øˆ	Ü˜1˜d D¨%°¸Ó;€AÜ�—‘“ÓÐr3   c                ón   — t         j                  j                  | «      }t        j                  |d¬«      S )Nr   ©Ú
cap_height)r   Úfont_managerÚfind_font_nameÚ	make_font)r)   Ú	font_names     r2   r!   r!   f   s)   € Ü×"Ñ"×1Ñ1°$Ó7€IÜ�?‰?˜9°Ô5Ð5r3   c                óD   — |j                  | |¬«      j                  «       S )Nr8   )Útext_path_exÚto_path)r(   Úrender_enginer*   s      r2   r"   r"   k   s!   € Ø×%Ñ% a°DÐ%Ó9×AÑAÓCÐCr3   c                ó6  — t         |   \  }}t        | |||«      }d}d}|t        j                  k(  r||j                  j
                  z  }|}n,|t        j                  k(  r||j                  j
                  z  }|dk7  r|t        j                  ||d«      z  }|S )a‹  Returns the alignment transformation matrix to transform a basic
    text path at location (0, 0) and alignment :attr:`LEFT` into the final text
    path of the given alignment.
    For the alignments :attr:`FIT` and :attr:`ALIGNED` defines the argument
    `length` the  total length of the final text path. The given bounding box
    defines the rendering borders of the basic text path.

    r   )	r   Úbasic_alignment_transformationr
   ÚALIGNEDr*   ÚxÚFITr   Úscale)	Úfmr#   r+   r,   ÚhalignÚvalignr1   Ú	stretch_xÚ	stretch_ys	            r2   r&   r&   o   s—   € ô 2°%Ñ8�N€FˆFÜ+¨B°°f¸fÓE€Fà€IØ€IØÔ#×+Ñ+Ò+Ø˜TŸY™YŸ[™[Ñ(ˆ	Ø‰	Ø	Ô%×)Ñ)Ò	)Ø˜TŸY™YŸ[™[Ñ(ˆ	Ø�CÒØ”(—.‘. ¨I°sÓ;Ñ;ˆØ€Mr3   c                ó°  — |t         j                  k(  rd}n�|t         j                  k(  r+|j                  €J d«       ‚|j                  j                   }nQ|t         j
                  k(  s|dkD  r+|j                  €J d«       ‚|j                  j                   }nt        d|› �«      ‚| j                  }| j                  }|t         j                  k(  rd}nU|t         j                  k(  r| }n>|t         j                  k(  r| dz  }n$|t         j                  k(  r|}nt        d|› �«      ‚|dk(  r| | j                  dz  z   }t        j                   ||d«      S )	Ng        zinvalid empty bounding boxé   zinvalid halign argument: zinvalid valign argument: é   g       @r   )r	   ÚLEFTÚRIGHTÚextmaxrE   ÚCENTERÚcenterÚ
ValueErrorr9   Údescender_heightÚBASELINEÚTOPÚMIDDLEÚBOTTOMÚtotal_heightr   Ú	translate)rH   r#   rI   rJ   Úshift_xr9   rV   Úshift_ys           r2   rC   rC   Œ   s5  € ð ”—‘ÒØ‰Ø	”5—;‘;Ò	Ø�{‰{Ð&ÐDÐ(DÓDÐ&Ø—;‘;—=‘=�.‰Ø	”5—<‘<Ò	 6¨A¢:Ø�{‰{Ð&ÐDÐ(DÓDÐ&Ø—;‘;—=‘=�.‰äÐ4°V°HÐ=Ó>Ð>Ø—‘€JØ×*Ñ*ÐØ”—‘ÒØ‰Ø	”5—9‘9Ò	Ø�+‰Ø	”5—<‘<Ò	Ø�+ ‘/‰Ø	”5—<‘<Ò	Ø"‰äÐ4°V°HÐ=Ó>Ð>Ø�‚{Ø�+ §¡°#Ñ 5Ñ5ˆÜ×Ñ˜g w°Ó2Ð2r3   c                ó¾  — t        |«      }|j                  t        j                  j                  u rg S t        | ||||«      }t        |xs i «      }|j                  dd«       |j                  dd«       |j                  dt        j                  «       t        j                  |d|¬«      }	|�|	D �
cg c]  }
|
j                  |«      ‘Œ c}
S t        |	«      S c c}
w )až  Convert a single line string `s` into a list of virtual
    :class:`~ezdxf.entities.Hatch` entities.
    The text `size` is the height of the uppercase letter "X" (cap height).
    The paths are aligned about the insertion point at (0, 0).
    The HATCH entities are aligned to this insertion point. BASELINE means the
    bottom of the letter "X".

    .. important::

        Returns an empty list for .shx, .shp and .lff fonts a.k.a. stroke fonts.

    Args:
         s: text to convert
         font: font face definition as :class:`~ezdxf.tools.fonts.FontFace` object
         size: text size (cap height) in drawing units
         align: alignment as :class:`ezdxf.enums.TextEntityAlignment`,
            default is :attr:`LEFT`
         length: target length for the :attr:`ALIGNED` and :attr:`FIT` alignments
         dxfattribs: additional DXF attributes
         m: transformation :class:`~ezdxf.math.Matrix44`

    Ú
solid_fillé   Úpattern_nameÚSOLIDÚcolorT)Ú	edge_pathÚ
dxfattribs)r!   Úfont_render_typer   ÚFontRenderTypeÚSTROKEr   ÚdictÚ
setdefaultr	   ÚBYLAYERr   Ú
to_hatchesr'   r5   )r(   r)   r*   r+   r,   rf   r-   Úfont_ÚpathsÚhatchesÚhatchs              r2   r   r   ª   sÇ   € ô> �T‹N€EØ×Ñ¤×!5Ñ!5×!<Ñ!<Ñ<Øˆ	ô    4¨¨u°fÓ=€EÜ�jÒ& BÓ'€JØ×Ñ˜,¨Ô*Ø×Ñ˜.¨'Ô2Ø×Ñ˜'¤5§=¡=Ô1Ü�o‰o˜e¨tÀ
ÔK€GØ€}á07Ó8± u�—‘ Õ"°Ñ8Ð8ä�G‹}Ðùò 9s   Â4Cc                ó‚   — | €t        d«      ‚| j                  «       t        vrt        d| j                  «       › �«      ‚y )Nzentity is Nonezunsupported entity type: )Ú	TypeErrorÚdxftypeÚVALID_TYPES©Úentitys    r2   Úcheck_entity_typerx   Ü   sB   € Ø€~ÜÐ(Ó)Ð)Ø�^‰^Ó¤Ñ,ÜÐ3°F·N±NÓ4DÐ3EÐFÓGÐGð -r3   c                ó<  — t        | «       | j                  «       }t        |t        j                  | j                  «       «      | j                  j                  | j                  «       | j                  «       ¬«      }| j                  «       }|j                  |«      S )z¡Convert text content from DXF entities TEXT and ATTRIB into a
    :term:`Multi-Path` object.
    The paths are located at the location of the source entity.
    )r*   r+   r,   )rx   Ú
plain_textr   r   Úget_font_facer=   ÚdxfÚheightÚget_align_enumÚ
fit_lengthÚwcs_transformation_matrixr'   )rw   Útextr/   r-   s       r2   r   r   ã   s�   € ô �fÔØ×ÑÓ€DÜØÜ×Ñ˜F×,Ñ,Ó.Ó/Ø�Z‰Z×ÑØ×#Ñ#Ó%Ø× Ñ Ó"ô	€Að 	×(Ñ(Ó*€AØ�;‰;�q‹>Ðr3   c                óF   — t        t        | «      j                  «       «      S )z÷Convert text content from DXF entities TEXT and ATTRIB into a
    list of :class:`~ezdxf.path.Path` objects. All paths are returned as a
    list of :term:`Single-Path` objects.
    The paths are located at the location of the source entity.

    )r5   r   r6   rv   s    r2   r   r   ö   s   € ô Ô% fÓ-×7Ñ7Ó9Ó:Ð:r3   c                ó¾   — t        | «       | j                  j                  }| j                  «       }t	        | «      }t        t        j                  |d||¬«      «      S )a   Convert text content from DXF entities TEXT and ATTRIB into a
    list of virtual :class:`~ezdxf.entities.Hatch` entities.
    The hatches are placed at the same location as the source entity and have
    the same DXF attributes as the source entity.

    T)re   Ú	extrusionrf   )rx   r|   r„   Úgraphic_propertiesr   r5   r   rm   )rw   r„   Úattribsro   s       r2   r   r      sX   € ô �fÔØ—
‘
×$Ñ$€IØ×'Ñ'Ó)€GÜ" 6Ó*€EÜÜ�‰ØØØØô		
óð r3   c                  ó   — e Zd ZdZdZdZdZy)r   a–  The :class:`Kind` enum defines the DXF types to create as bit flags,
    e.g. 1+2 to get HATCHES as filling and SPLINES and POLYLINES as outline:

    === =========== ==============================
    Int Enum        Description
    === =========== ==============================
    1   HATCHES     :class:`~ezdxf.entities.Hatch` entities as filling
    2   SPLINES     :class:`~ezdxf.entities.Spline` and 3D :class:`~ezdxf.entities.Polyline`
                    entities as outline
    4   LWPOLYLINES :class:`~ezdxf.entities.LWPolyline` entities as approximated
                    (flattened) outline
    === =========== ==============================

    ra   rN   rO   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚHATCHESÚSPLINESÚLWPOLYLINES© r3   r2   r   r     s   „ ñð €GØ€GØ�Kr3   r   c                ó  — t        | «       | j                  j                  }| j                  «       }g }|t        j
                  z  r|j                  t        | «      «       |t        j                  t        j                  z   z  r~t        | «      }|t        j                  z  r&|j                  t        j                  ||¬«      «       |t        j                  z  r'|j                  t        j                  |||¬«      «       t        |«      S )aŸ  Convert the text content of DXF entities TEXT and ATTRIB into virtual
    SPLINE and 3D POLYLINE entities or approximated LWPOLYLINE entities
    as outlines, or as HATCH entities as fillings.

    Returns the virtual DXF entities as an :class:`~ezdxf.query.EntityQuery`
    object.

    Args:
        entity: TEXT or ATTRIB entity
        kind: kind of entities to create as bit flags, see enum :class:`Kind`

    )rf   )r„   rf   )rx   r|   r„   r…   r   rŒ   Úextendr   r�   rŽ   r   r   Úto_splines_and_polylinesÚto_lwpolylinesr   )rw   Úkindr„   r†   Úentitiesro   s         r2   r   r   +  sË   € ô �fÔØ—
‘
×$Ñ$€IØ×'Ñ'Ó)€GØ!#€HàŒd�l‰lÒØ�‰Ô0°Ó8Ô9ØŒt�|‰|œd×.Ñ.Ñ.Ò/Ü& vÓ.ˆØ”$—,‘,ÒØ�O‰OœD×9Ñ9¸%ÈGÔTÔUØ”$×"Ñ"Ò"Ø�O‰OÜ×#Ñ# E°YÈ7ÔSôô �xÓ Ð r3   c                ó¨   — t        | |«      }|€| j                  «       }| j                  «        |�|D ]  }|j                  |«       Œ t	        |«      S )an  Explode the text `entity` into virtual entities,
    see :func:`virtual_entities`. The source entity will be destroyed.

    The target layout is given by the `target` argument, if `target` is ``None``,
    the target layout is the source layout of the text entity.

    Returns the created DXF entities as an :class:`~ezdxf.query.EntityQuery`
    object.

    Args:
        entity: TEXT or ATTRIB entity to explode
        kind: kind of entities to create as bit flags, see enum :class:`Kind`
        target: target layout for new created DXF entities, ``None`` for the
            same layout as the source entity.

    )r   Ú
get_layoutÚdestroyÚ
add_entityr   )rw   r”   Útargetr•   Úes        r2   r   r   K  sX   € ô"   ¨Ó-€Hð €~Ø×"Ñ"Ó$ˆØ
‡N�NÔàÐÛˆAØ×Ñ˜aÕ ð ä�xÓ Ð r3   )r(   Ústrr)   úfonts.FontFacer*   Úfloatr,   rž   r-   r   Úreturnr   )r(   rœ   r)   r�   r*   rž   r,   rž   r-   r   rŸ   ú
list[Path])r)   r�   rŸ   úfonts.AbstractFont)r   )r(   rœ   rA   r¡   r*   rž   rŸ   r   )
rH   úfonts.FontMeasurementsr#   r   r+   r
   r,   rž   rŸ   r   )
rH   r¢   r#   r   rI   ÚintrJ   r£   rŸ   r   )r(   rœ   r)   r�   r*   rž   r,   rž   r-   r   rŸ   úlist[Hatch])rw   ÚAnyTextrŸ   r   )rw   r¥   rŸ   r    )rw   r¥   rŸ   r¤   )rw   r¥   r”   r£   rŸ   r   )/Ú
__future__r   Útypingr   ÚenumÚezdxf.entitiesr   r   r   r   Úezdxf.lldxfr	   Úezdxf.enumsr
   r   Ú
ezdxf.mathr   r   Úezdxfr   Ú
ezdxf.pathr   Úezdxf.fontsr   Úezdxf.queryr   Ú__all__r¥   ru   rP   r   r   r!   r"   r&   rC   r   rx   r   r   r   ÚuniqueÚIntEnumr   rŒ   r   r   r�   r3   r2   Ú<module>r´      s  ðõ #Ý Û ç :Ó :Ý ß Iß ,Ý Ý Ý Ý #ò
€ð ��f�Ñ
€Ø €ð Ø
×
"Ñ
"ØØð$Ø
ð$à
ð$ð ð$ð
 ð$ð ð$ð 
ó$ðT Ø
×
"Ñ
"ØØðØ
ðà
ðð ðð
 ðð ðð óó>6ô
DðØðà
ðð ðð ð	ð
 óð:3Øð3Ø&1ð3Ø;>ð3ØHKð3àó3ðB Ø
×
"Ñ
"ØØØð/Ø
ð/à
ð/ð ð/ð
 ð/ð ð/ð ó/òdHóó&;óð* ‡�ôˆ4�<‰<ó ó ðð* 37·,±,ô !ð@ *.¯©¸dõ !r3   