Ë
    £èháf  ã                  óÞ  — d dl mZ d dlmZmZmZ d dlZd dlZd dlZd dl	Z	d dl
Z
d dlmZ ddlmZ ddlmZmZmZmZ ddlmZ dd	lmZ dd
lmZmZ erd dlmZ d dlmZmZ  ej@                  d«      Z!dZ"da#dZ$ e«       Zi dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“d d!“d"d!“d#d$“d%d$“d&d'“d(d'“d)d*“d*d+d+d,d,d-d-d.d.d/d/d0œ¥Z%d1d1d2œZ&e%jO                  «       D � �ci c]  \  } }| jQ                  d3«      sŒ|| “Œ c}} Z)d4Z*d5Z+d6Z,dad7„Z-dad8„Z.dbd9„Z/dcd:„Z0ddd;„Z1ded<„Z2dfded=„Z3dgd>„Z4dhded?„Z5dfdid@„Z6dAdBdCdDddEœ	 	 	 	 	 	 	 	 	 	 	 djdF„Z7dkdG„Z8dH„ Z9dI„ Z:dddJ„Z;dldK„Z<dmdL„Z=dmdM„Z> G dN„ dOej~                  «      Z@ G dP„ dQ«      ZA G dR„ dSeA«      ZB G dT„ dUeAej†                  «      ZD G dV„ dWeD«      ZE G dX„ dYeD«      ZFdndZ„ZG G d[„ d\eD«      ZH G d]„ d^eD«      ZI	 do	 	 	 	 	 	 	 dpd_„ZJdqdrd`„ZK e9«        yc c}} w )sé    )Úannotations)ÚOptionalÚTYPE_CHECKINGÚcastN)Úoptionsé   )ÚFontFace)ÚFontManagerÚSUPPORTED_TTF_TYPESÚFontNotFoundErrorÚUnsupportedFont)ÚFONT_SYNONYMS)ÚFontMeasurements)Ú	GlyphPathÚGlyphs)ÚDrawing)Ú	DXFEntityÚ	TextstyleÚezdxfúfont_manager_cache.jsonFz.cacheÚAMGDTzamgdt___.ttfz	AMGDT.SHXÚCOMPLEXzcomplex_.ttfzCOMPLEX.SHXÚISOCPz	isocp.ttfz	ISOCP.SHXÚITALICzitalicc_.ttfz
ITALIC.SHXÚGOTHICGzgothicg_.ttfzGOTHICG.SHXÚGREEKCz
greekc.ttfz
GREEKC.SHXÚROMANSzromans__.ttfz
ROMANS.SHXÚSCRIPTSzscripts_.ttfzSCRIPTS.SHXÚSCRIPTCzscriptc_.ttfzsimplex_.ttfzsymath__.ttfzsymap___.ttfzsymeteo_.ttfztxt_____.ttf)zSCRIPTC.SHXÚSIMPLEXzSIMPLEX.SHXÚSYMATHz
SYMATH.SHXÚSYMAPz	SYMAP.SHXÚSYMETEOzSYMETEO.SHXÚTXTúTXT.SHXzstandard.lff)r$   r%   ÚSHXgZd;ßOÕ?gZd;ßOå?z
*monospacec                óH   — | j                  «       }|t        v r	t        |   } | S )zEMap .shx font names to .ttf file names. e.g. "TXT" -> "txt_____.ttf" )ÚupperÚ	SHX_FONTS)Ú	font_nameÚ
font_uppers     ú1lib/python3.12/site-packages/ezdxf/fonts/fonts.pyÚmap_shx_to_ttfr-   T   s(   € ð —‘Ó"€JØ”YÑÜ˜jÑ)ˆ	ØÐó    c                óì   — | j                  «       }t        j                  |d«      }t        j	                  |«      r|S |j                  d«      s| dz   }n| dd dz   }t        j	                  |«      r|S | S )zEMap .shx font names to .lff file names. e.g. "TXT" -> "standard.lff" Ú z.SHXú.lffNéüÿÿÿ)r(   Ú	LFF_FONTSÚgetÚfont_managerÚhas_fontÚendswith)r*   r+   ÚnameÚlff_names       r,   Úmap_shx_to_lffr:   ]   sr   € à—‘Ó"€JÜ�=‰=˜ RÓ(€DÜ×Ñ˜TÔ"ØˆØ×Ñ˜vÔ&Ø˜vÑ%‰à˜S˜b�> FÑ*ˆÜ×Ñ˜XÔ&ØˆØÐr.   c                óR   — | j                  «       }|j                  d«      ryd|vryy)Nú.shxTÚ.F)Úlowerr7   )r*   r8   s     r,   Úis_shx_font_namer?   l   s*   € Ø�?‰?Ó€DØ‡}�}�VÔØØ
�$�ØØr.   c                óH   — t         j                  | j                  «       «      S )zEMaps .ttf filenames to .shx font names. e.g. "txt_____.ttf" -> "TXT" )Ú
TTF_TO_SHXr4   r>   )Úttfs    r,   Úmap_ttf_to_shxrC   u   s   € ä�>‰>˜#Ÿ)™)›+Ó&Ð&r.   c                 ó*   — t        t        «       «       y)zðBuilds or rebuilds the font manager cache. The font manager cache has a fixed
    location in the cache directory of the users home directory "~/.cache/ezdxf" or the
    directory specified by the environment variable "XDG_CACHE_HOME".
    N)Úbuild_font_manager_cacheÚ_get_font_manager_path© r.   r,   Úbuild_system_font_cacherH   z   s   € ô
 Ô3Ó5Õ6r.   c                ó,   — t         j                  | «      S )zqReturns the :class:`FontFace` definition for the given font filename
    e.g. "LiberationSans-Regular.ttf".

    )r5   Úget_font_face)r*   s    r,   Úfind_font_facerK   ‚   s   € ô
 ×%Ñ% iÓ0Ð0r.   c                óh   — t        | t        «      st        d«      ‚|rt        | «      } t	        | «      S )a/  Returns  the :class:`FontFace` definition for the given font filename
    e.g. "LiberationSans-Regular.ttf".

    This function translates a DXF font definition by the TTF font file name into a
    :class:`FontFace` object. Returns the :class:`FontFace` of the default font when a
    font is not available on the current system.

    Args:
        font_name: raw font file name as stored in the
            :class:`~ezdxf.entities.Textstyle` entity
        map_shx: maps SHX font names to TTF replacement fonts,
            e.g. "TXT" -> "txt_____.ttf"

    úfont_name has invalid type)Ú
isinstanceÚstrÚ	TypeErrorr-   rK   )r*   Úmap_shxs     r,   rJ   rJ   Š   s2   € ô �i¤Ô%ÜÐ4Ó5Ð5ÙÜ" 9Ó-ˆ	Ü˜)Ó$Ð$r.   c                ó‚  — t        |«      dk(  r| S |j                  «       }|D ]™  }|dk(  r%t        | «      }t        j	                  |«      sŒ)|c S |dk(  r>| j                  «       j                  d«      s| dz  } t        j	                  | «      sŒl| c S |dk(  sŒvt        | «      }t        j	                  |«      sŒ—|c S  | S )zòResolves a .shx font name, the argument `order` defines the resolve order:

    - "t" = map .shx fonts to TrueType fonts (.ttf, .ttc, .otf)
    - "s" = use shapefile fonts (.shx, .shp)
    - "l" = map .shx fonts to LibreCAD fonts (.lff)

    r   ÚtÚsr<   Úl)Úlenr>   r-   r5   r6   r7   r:   )r*   ÚorderÚtype_strr8   s       r,   Úresolve_shx_font_namerY       s´   € ô ˆ5ƒz�Q‚ØÐØ�K‰K‹M€EÛˆØ�sŠ?Ü! )Ó,ˆDÜ×$Ñ$ TÕ*Ø’Ø˜Š_Ø—?‘?Ó$×-Ñ-¨fÔ5Ø˜VÑ#�	Ü×$Ñ$ YÕ/Ø Ò Ø˜‹_Ü! )Ó,ˆDÜ×$Ñ$ TÕ*Ø’ð ð Ðr.   c                ó|   — t        | t        «      st        d«      ‚t        | «      rt	        | |«      } t        | «      S )aÉ  Returns the :class:`FontFace` definition for the given font filename
    e.g. "LiberationSans-Regular.ttf".

    This function translates a DXF font definition by the TTF font file name into a
    :class:`FontFace` object. Returns the :class:`FontFace` of the default font when a
    font is not available on the current system.

    The order argument defines the resolve order for .shx fonts:

    - "t" = map .shx fonts to TrueType fonts (.ttf, .ttc, .otf)
    - "s" = use shapefile fonts (.shx, .shp)
    - "l" = map .shx fonts to LibreCAD fonts (.lff)

    Args:
        font_name: raw font file name as stored in the
            :class:`~ezdxf.entities.Textstyle` entity
        order: resolving order

    rM   )rN   rO   rP   r?   rY   rK   )r*   rW   s     r,   Úresolve_font_facer[   ¼   s9   € ô( �i¤Ô%ÜÐ4Ó5Ð5Ü˜	Ô"Ü)¨)°UÓ;ˆ	Ü˜)Ó$Ð$r.   c                ó”   — |rt        | «      } n"t        | «      rt        ddt        t        ¬«      S t        | d¬«      }|j                  S )aF  Get :class:`FontMeasurements` for the given font filename
    e.g. "LiberationSans-Regular.ttf".

    Args:
        font_name: raw font file name as stored in the
            :class:`~ezdxf.entities.Textstyle` entity
        map_shx: maps SHX font names to TTF replacement fonts,
            e.g. "TXT" -> "txt_____.ttf"

    r   r   ©ÚbaselineÚ
cap_heightÚx_heightÚdescender_height)r_   )r-   r?   r   ÚX_HEIGHT_FACTORÚDESCENDER_FACTORÚTrueTypeFontÚmeasurements)r*   rQ   Úfonts      r,   Úget_font_measurementsrg   ×   sL   € ñ Ü" 9Ó-‰	Ü	˜)Ô	$ÜØØÜ$Ü-ô	
ð 	
ô ˜	¨aÔ0€DØ×ÑÐr.   z
sans-serifÚRegularé�  é   ©ÚfamilyÚstyleÚweightÚwidthÚitalicc                ó4   — t         j                  | ||||«      S )a  Returns a :class:`FontFace` that matches the given properties best. The search
    is based the descriptive properties and not on comparing glyph shapes. Returns
    ``None`` if no font was found.

    Args:
        family: font family name e.g. "sans-serif", "Liberation Sans"
        style: font style e.g. "Regular", "Italic", "Bold"
        weight: weight in the range from 1-1000 (usWeightClass)
        width: width in the range from 1-9 (usWidthClass)
        italic: ``True``, ``False`` or ``None`` to ignore this flag

    )r5   Úfind_best_matchrk   s        r,   rr   rr   ï   s   € ô( ×'Ñ'¨°°v¸uÀfÓMÐMr.   c                ó,   — t         j                  | «      S )zQReturns the true type font file name without parent directories e.g. "Arial.ttf".)r5   Úfind_font_name)Ú	font_faces    r,   Úfind_font_file_namerv     s   € ä×&Ñ& yÓ1Ð1r.   c                 óN   — t        «        t        j                  t        d¬«       y)zcReload all cache files. The cache files are loaded automatically at the import
    of `ezdxf`.
    T)ÚreverseN)Ú_load_font_managerr5   Úadd_synonymsr   rG   r.   r,   Úloadr{     s   € ô Ôô ×Ñœm°TÐÕ:r.   c                 óH   — t        j                  dt        «      } | t        z  S )NÚXDG_CACHE_HOME)r   Úxdg_pathÚCACHE_DIRECTORYÚFONT_MANAGER_CACHE_FILE)Ú
cache_paths    r,   rF   rF     s!   € Ü×!Ñ!Ð"2´OÓD€JØÔ/Ñ/Ð/r.   c                 ó  — t        «       } | j                  «       r%	 t        j                  | j	                  «       «       y t        | «       y # t
        $ r+}t        j                  dt        |«      › �«       Y d }~Œ;d }~ww xY w)NúError loading cache file: )
rF   Úexistsr5   ÚloadsÚ	read_textÚIOErrorÚloggerÚinforO   rE   )Úfm_pathÚes     r,   ry   ry     sj   € Ü$Ó&€GØ‡~�~Ôð	?Ü×Ñ˜w×0Ñ0Ó2Ô3Øô ˜WÕ%øô ò 	?Ü�K‰KÐ4´S¸³V°HÐ=×>Ñ>ûð	?ús   œ#A Á	B Á!A;Á;B c                óæ  — da t        j                  «        | dz  }|j                  «       r%	 t        j	                  |j                  «       «       yt        j                  t        | «      gd¬«       t        j                  «       }	 |j                  |«       y# t        $ r!}t        dt        |«      › �«       Y d}~Œmd}~ww xY w# t        $ r!}t        dt        |«      › �«       Y d}~yd}~ww xY w)zúLoad font manger cache for system under test (sut).

    Load the fonts included in the repository folder "./fonts" to guarantee the tests
    have the same fonts available on all systems.

    This function should be called from "conftest.py".

    Tr   Nrƒ   F)Úsupport_dirszError writing cache file: )ÚSUT_FONT_MANAGER_CACHEr5   Úclearr„   r…   r†   r‡   ÚprintrO   ÚbuildÚdumpsÚ
write_text)Úrepo_font_pathÚ
cache_filer‹   rT   s       r,   Úbuild_sut_font_manager_cacher–   %  sÛ   € ð "ÐÜ×ÑÔØÐ";Ñ;€JØ×ÑÔð	9Ü×Ñ˜z×3Ñ3Ó5Ô6Øô ×Ñœ˜NÓ+Ð,¸5ÐÔAÜ×ÑÓ€Að5Ø×Ñ˜aÕ øô ò 	9ÜÐ.¬s°1«v¨hÐ7×8Ñ8ûð	9ûô ò 5ÜÐ*¬3¨q«6¨(Ð3×4Ñ4ûð5ús/   ­#B ÂC Â	CÂ"B>Â>CÃ	C0ÃC+Ã+C0c                ój   — | j                  «       s	 | j                  d¬«       y y # t        $ r Y y w xY w)NT)Úparents)r„   Úmkdirr‡   )Úpaths    r,   Úmake_cache_directoryr›   @  s7   € Ø�;‰;Œ=ð	Ø�J‰J˜tˆJÕ$ð øô ò 	Ùð	ús   ’& ¦	2±2c                ó¤  — t         j                  «        t         j                  «        t         j                  «       }| j                  }t        |«       |j                  «       s#t        j                  dt        |«      › d�«       y 	 | j                  |«       y # t        $ r,}t        j                  dt        |«      › d�«       Y d }~y d }~ww xY w)Nz%Cannot create cache home directory: 'z\', cache files will not be saved.
See also issue https://github.com/mozman/ezdxf/issues/923.zError writing cache file: 'Ú')r5   r�   r‘   r’   Úparentr›   r„   rˆ   ÚwarningrO   r“   r‡   )rš   rT   Ú	cache_dirr‹   s       r,   rE   rE   H  s°   € Ü×ÑÔÜ×ÑÔÜ×ÑÓ€AØ—‘€IÜ˜Ô#Ø×ÑÔÜ�‰Ø3´C¸	³NÐ3Cð DXð Yô	
ð 	ð@Ø�‰˜ÕøÜò @Ü�‰Ð4´S¸³V°H¸AÐ>×?Ñ?ûð@ús   ÂB Â	CÂ#"C
Ã
Cc                  óF   — e Zd Z ej                  «       Zej                  Zy)ÚFontRenderTypeN)Ú__name__Ú
__module__Ú__qualname__ÚenumÚautoÚOUTLINEÚSTROKErG   r.   r,   r¢   r¢   Z  s   „ àˆd�i‰i‹k€Gð �Y‰Y�Fr.   r¢   c                  óZ  — e Zd ZU dZej
                  ZdZded<   dd„Z	e
j                  dd„«       Ze
j                  	 d	 	 	 	 	 	 	 dd„«       Ze
j                  dd„«       Ze
j                  dd	„«       Ze
j                  	 d	 	 	 	 	 	 	 dd
„«       Ze
j                  	 d	 	 	 	 	 	 	 dd„«       Zy)ÚAbstractFontzJThe `ezdxf` font abstraction for text measurement and text path rendering.Ú	undefinedrO   r8   c                ó   — || _         y ©N)re   )Úselfre   s     r,   Ú__init__zAbstractFont.__init__h  s
   € Ø(ˆÕr.   c                 ó   — y)úDReturns the text width in drawing units for the given `text` string.NrG   ©r¯   Útexts     r,   Ú
text_widthzAbstractFont.text_widthk  ó   € ð 	r.   c                 ó   — y)únReturns the text width in drawing units, bypasses the stored `cap_height` and
        `width_factor`.
        NrG   ©r¯   r´   r_   Úwidth_factors       r,   Útext_width_exzAbstractFont.text_width_exp  s   € ð 	r.   c                 ó   — y)z=Returns the width of a "space" character a.k.a. word spacing.NrG   ©r¯   s    r,   Úspace_widthzAbstractFont.space_widthy  r¶   r.   c                 ó   — y)ú,Returns the 2D text path for the given text.NrG   r³   s     r,   Ú	text_pathzAbstractFont.text_path~  s   € ð 	r.   c                 ó   — y)úiReturns the 2D text path for the given text, bypasses the stored `cap_height`
        and `width_factor`.NrG   r¹   s       r,   Útext_path_exzAbstractFont.text_path_exƒ  ó   € ð 	r.   c                 ó   — y)úqReturns a list of 2D glyph paths for the given text, bypasses the stored
        `cap_height` and `width_factor`.NrG   r¹   s       r,   Útext_glyph_pathszAbstractFont.text_glyph_paths‹  rÅ   r.   N)re   r   ©r´   rO   ÚreturnÚfloat©ç      ð?©r´   rO   r_   rË   rº   rË   rÊ   rË   ©rÊ   rË   ©r´   rO   rÊ   r   ©r´   rO   r_   rË   rº   rË   rÊ   r   ©r´   rO   r_   rË   rº   rË   rÊ   zlist[GlyphPath])r£   r¤   r¥   Ú__doc__r¢   r©   Úfont_render_typer8   Ú__annotations__r°   ÚabcÚabstractmethodrµ   r»   r¾   rÁ   rÄ   rÈ   rG   r.   r,   r«   r«   b  s%  … ÙTà%×,Ñ,ÐØ€Dˆ#Óó)ð 	×Ñòó ðð 	×ÑàBEðØðØ%*ðØ:?ðà	òó ðð 	×Ñòó ðð 	×Ñòó ðð 	×ÑàBEðØðØ%*ðØ:?ðà	òó ðð 	×ÑàBEðØðØ%*ðØ:?ðà	òó ñr.   r«   c                  óÂ   ‡ — e Zd ZdZej
                  ZeZdde	e
f	 	 	 	 	 	 	 	 	 dˆ fd„Zdd„Z	 d	 	 	 	 	 	 	 dd„Zdd„Z	 d	 	 	 	 	 	 	 dd„Z	 d	 	 	 	 	 	 	 dd	„Zdd
„Zˆ xZS )ÚMonospaceFontau  Represents a monospaced font where each letter has the same cap- and descender
    height and the same width. The given cap height and width factor are the default
    values for measurements and rendering. The extended methods can override these
    default values.

    This font exists only for generic text measurement in tests and does not render any
    glyphs!

    rÍ   r   c           	     óº   •— t         ‰| �  t        ||||z  ||z  ¬«      «       t        |«      | _        | j
                  j                  | j                  z  | _        y )Nr]   )Úsuperr°   r   ÚabsÚ_width_factorre   r_   Ú_space_width)r¯   r_   rº   r^   Údescender_factorÚx_height_factorÚ	__class__s         €r,   r°   zMonospaceFont.__init__¢  s_   ø€ ô 	‰ÑÜØ!Ø%Ø# oÑ5Ø!+Ð.>Ñ!>ô	ô	
ô %(¨Ó$5ˆÔØ ×-Ñ-×8Ñ8¸4×;MÑ;MÑMˆÕr.   c                ód   — | j                  || j                  j                  | j                  «      S )z=Returns the text width in drawing units for the given `text`.)r»   re   r_   rÝ   r³   s     r,   rµ   zMonospaceFont.text_widthµ  s.   € à×!Ñ!Ø�$×#Ñ#×.Ñ.°×0BÑ0Bó
ð 	
r.   c                ó$   — t        |«      |z  |z  S )r¸   )rV   r¹   s       r,   r»   zMonospaceFont.text_width_ex»  s   € ô �4‹y˜:Ñ%¨Ñ4Ð4r.   c                ód   — | j                  || j                  j                  | j                  «      S )zOReturns the rectangle text width x cap height as :class:`NumpyPath2d` instance.)rÄ   re   r_   rÝ   r³   s     r,   rÁ   zMonospaceFont.text_pathÃ  s)   € à× Ñ   t×'8Ñ'8×'CÑ'CÀT×EWÑEWÓXÐXr.   c                óì   — ddl m} | j                  |||«      } |d«      }|j                  |df«       |j                  ||f«       |j                  d|f«       |j	                  «        t        |«      S )z–Returns the rectangle text width x cap height as  :class:`NumpyPath2d`
        instance, bypasses the stored `cap_height` and `width_factor`.
        r   )ÚPath)r   r   )Ú
ezdxf.pathræ   r»   Úline_toÚcloser   )r¯   r´   r_   rº   ræ   rµ   Úps          r,   rÄ   zMonospaceFont.text_path_exÇ  sh   € õ 	$à×'Ñ'¨¨j¸,ÓGˆ
Ù�‹LˆØ	�	‰	�:˜q�/Ô"Ø	�	‰	�:˜zÐ*Ô+Ø	�	‰	�1�j�/Ô"Ø	�‰Œ	Ü˜‹|Ðr.   c                ó*   — | j                  |||«      gS )zHReturns the same rectangle as the method :meth:`text_path_ex` in a list.)rÄ   r¹   s       r,   rÈ   zMonospaceFont.text_glyph_paths×  s   € ð ×!Ñ! $¨
°LÓAÐBÐBr.   c                ó   — | j                   S ©z$Returns the width of a "space" char.©rÞ   r½   s    r,   r¾   zMonospaceFont.space_widthÝ  ó   € à× Ñ Ð r.   )
r_   rË   rº   rË   r^   rË   rß   rË   rà   rË   rÉ   rÌ   rÎ   rÐ   rÑ   rÒ   rÏ   )r£   r¤   r¥   rÓ   r¢   r©   rÔ   Ú	MONOSPACEr8   rc   rb   r°   rµ   r»   rÁ   rÄ   rÈ   r¾   Ú__classcell__©rá   s   @r,   rÙ   rÙ   ”  sý   ø„ ñð &×,Ñ,ÐØ€Dð
 "ØØ"2Ø!0ðNàðNð ðNð ð	Nð
  ðNð õNó&
ð CFð5Øð5Ø%*ð5Ø:?ð5à	ó5óYð
 CFðØðØ%*ðØ:?ðà	óð" CFðCØðCØ%*ðCØ:?ðCà	óC÷!r.   rÙ   c                  óÌ   ‡ — e Zd ZU dZ e«       Zded<   ddˆ fd„Zej                  dd„«       Z
dd„Z	 d	 	 	 	 	 	 	 dd„Zdd„Z	 d	 	 	 	 	 	 	 dd	„Z	 d	 	 	 	 	 	 	 dd
„Zdd„Zˆ xZS )Ú_CachedFontz#Abstract font with caching support.zdict[str, Glyphs]Ú_glyph_cachesc                óL  •— || _         | j                  |«      }|| _        t        |«      | _        t        |«      | _        |j                  | j                  «      }t        ‰| �!  |j                  j                  |«      «       | j                  j                  |z  |z  | _        y r®   )r8   Úcreate_cacheÚglyph_cacherË   r_   rº   Úget_scaling_factorrÛ   r°   Úfont_measurementsÚscaler¾   rÞ   )r¯   r*   r_   rº   ÚcacheÚscale_factorrá   s         €r,   r°   z_CachedFont.__init__ç  sŽ   ø€ ØˆŒ	Ø×!Ñ! )Ó,ˆØ ˆÔÜ 
Ó+ˆŒÜ! ,Ó/ˆÔØ#×6Ñ6°t·±ÓGˆÜ‰Ñ˜×0Ñ0×6Ñ6°|ÓDÔEà×Ñ×(Ñ(¨<Ñ7¸,ÑFð 	Õr.   c                 ó   — y r®   rG   )r¯   r*   s     r,   r÷   z_CachedFont.create_cacheó  s   € àr.   c                óP   — | j                  || j                  | j                  «      S )r²   )r»   r_   rº   r³   s     r,   rµ   z_CachedFont.text_width÷  s!   € à×!Ñ! $¨¯©¸×9JÑ9JÓKÐKr.   c                ó^   — |j                  «       sy| j                  j                  |||«      S )r¸   r   )Ústriprø   Úget_text_lengthr¹   s       r,   r»   z_CachedFont.text_width_exû  s+   € ð �z‰zŒ|ØØ×Ñ×/Ñ/°°jÀ,ÓOÐOr.   c                óP   — | j                  || j                  | j                  «      S )rÀ   )rÄ   r_   rº   r³   s     r,   rÁ   z_CachedFont.text_path  s#   € ð × Ñ   t§¡¸×8IÑ8IÓJÐJr.   c                ó<   — | j                   j                  |||«      S )rÃ   )rø   Úget_text_pathr¹   s       r,   rÄ   z_CachedFont.text_path_ex
  s   € ð
 ×Ñ×-Ñ-¨d°JÀÓMÐMr.   c                ó<   — | j                   j                  |||«      S )rÇ   )rø   Úget_text_glyph_pathsr¹   s       r,   rÈ   z_CachedFont.text_glyph_paths  s   € ð
 ×Ñ×4Ñ4°T¸:À|ÓTÐTr.   c                ó   — | j                   S rí   rî   r½   s    r,   r¾   z_CachedFont.space_width  rï   r.   rÌ   )r*   rO   r_   rË   rº   rË   ©r*   rO   rÊ   r   rÉ   rÎ   rÐ   rÑ   rÒ   rÏ   )r£   r¤   r¥   rÓ   Údictrõ   rÕ   r°   rÖ   r×   r÷   rµ   r»   rÁ   rÄ   rÈ   r¾   rñ   rò   s   @r,   rô   rô   â  sÖ   ø… Ù-á'+£v€MÐ$Ó-ö

ð 	×Ñòó ðóLð
 CFðPØðPØ%*ðPØ:?ðPà	óPóKð CFðNØðNØ%*ðNØ:?ðNà	óNð CFðUØðUØ%*ðUØ:?ðUà	óU÷!r.   rô   c                  ó0   — e Zd ZdZej
                  Zdd„Zy)rd   a  Represents a TrueType font. Font measurement and glyph rendering is done by the
    `fontTools` package. The given cap height and width factor are the default values
    for measurements and glyph rendering. The extended methods can override these
    default values.
    c                óä  — ddl m} t        j                  |«      j                  j                  «       }	 | j                  |   S # t        $ r Y nw xY w	 t        j                  |«      }	  ||«      }n# t        $ r t        ‚w xY wnZ# t        $ rN t        j                  «       }t        j                  d|› d|› d�«        |t        j                  |«      «      }Y nw xY w|| j                  |<   |S )Nr   ©ÚTTFontRendererzreplacing unsupported font 'z' by 'r�   )Úttfontsr  Úpathlibræ   r8   r>   rõ   ÚKeyErrorr5   Úget_ttf_fontÚ	Exceptionr   Úfallback_font_namerˆ   r‰   )r¯   rB   r  ÚkeyÚtt_fontrü   r  s          r,   r÷   zTrueTypeFont.create_cache&  s÷   € Ý+ä�l‰l˜3Ó×$Ñ$×*Ñ*Ó,ˆð	Ø×%Ñ% cÑ*Ð*øÜò 	Ùð	úð		RÜ"×/Ñ/°Ó4ˆGð&Ù& wÓ/‘øÜò &Ü%Ð%ð&úð øô ò 	RÜ!-×!@Ñ!@Ó!BÐÜ�K‰KÐ6°s°e¸6ÐBTÐAUÐUVÐWÔXÙ"¤<×#<Ñ#<Ð=OÓ#PÓQŠEð	Rúð #(ˆ×Ñ˜3ÑØˆs<   µA Á	AÁAÁB Á*A3 Á2B Á3BÂB ÂACÃCN©rB   rO   rÊ   r   )r£   r¤   r¥   rÓ   r¢   r¨   rÔ   r÷   rG   r.   r,   rd   rd     s   „ ñð &×-Ñ-Ðôr.   rd   c                  ó,   — e Zd Zej                  Zdd„Zy)Ú_UnmanagedTrueTypeFontc                óº   — ddl m} ddlm} |j	                  «       }	 | j
                  |   S # t        $ r Y nw xY w | ||d¬«      «      }|| j
                  |<   |S )Nr   r  r   )ÚTTFont)Ú
fontNumber)r  r  ÚfontTools.ttLibr  r>   rõ   r  )r¯   rB   r  r  r  rü   s         r,   r÷   z#_UnmanagedTrueTypeFont.create_cache?  sa   € Ý+Ý*à�i‰i‹kˆð	Ø×%Ñ% cÑ*Ð*øÜò 	Ùð	úá™v c°aÔ8Ó9ˆØ"'ˆ×Ñ˜3ÑØˆs   ž- ­	9¸9Nr  )r£   r¤   r¥   r¢   r¨   rÔ   r÷   rG   r.   r,   r  r  <  s   „ Ø%×-Ñ-Ðôr.   r  c                ó,   — t        t        | «      |«      S )a  This function bypasses the FontManager and loads the TrueType font straight from
    the file system, requires the absolute font file path e.g. "C:/Windows/Fonts/Arial.ttf".

    .. warning::

        Expert feature, use with care: no fallback font and no error handling.

    )r  rO   )Ú	font_pathr_   s     r,   Úsideload_ttfr   M  s   € ô "¤# i£.°*Ó=Ð=r.   c                  ó0   — e Zd ZdZej
                  Zdd„Zy)ÚShapeFileFonta(  Represents a shapefile font (.shx, .shp). Font measurement and glyph rendering is
    done by the ezdxf.fonts.shapefile module. The given cap height and width factor are
    the default values for measurements and glyph rendering. The extended methods can
    override these default values.

    c                ó¬   — |j                  «       }	 | j                  |   S # t        $ r Y nw xY wt        j	                  |«      }|| j                  |<   |S r®   )r>   rõ   r  r5   Úget_shapefile_glyph_cache©r¯   r*   r  rø   s       r,   r÷   zShapeFileFont.create_cached  s\   € Ø�o‰oÓˆð	Ø×%Ñ% cÑ*Ð*øÜò 	Ùð	úä"×<Ñ<¸YÓGˆØ"-ˆ×Ñ˜3ÑØÐó   ’! ¡	-¬-Nr	  ©r£   r¤   r¥   rÓ   r¢   r©   rÔ   r÷   rG   r.   r,   r"  r"  Z  ó   „ ñð &×,Ñ,Ðôr.   r"  c                  ó0   — e Zd ZdZej
                  Zdd„Zy)ÚLibreCadFonta!  Represents a LibreCAD font (.shx, .shp). Font measurement and glyph rendering is
    done by the ezdxf.fonts.lff module. The given cap height and width factor are the
    default values for measurements and glyph rendering. The extended methods can
    override these default values.

    c                ó¬   — |j                  «       }	 | j                  |   S # t        $ r Y nw xY wt        j	                  |«      }|| j                  |<   |S r®   )r>   rõ   r  r5   Úget_lff_glyph_cacher%  s       r,   r÷   zLibreCadFont.create_cachey  s\   € Ø�o‰oÓˆð	Ø×%Ñ% cÑ*Ð*øÜò 	Ùð	úä"×6Ñ6°yÓAˆØ"-ˆ×Ñ˜3ÑØÐr&  Nr	  r'  rG   r.   r,   r*  r*  o  r(  r.   r*  c                ó\  — | t         k(  rt        ||«      S t        j                  | «      j                  j                  «       }t        ||«      }|t        v r	 t        | ||«      S |dk(  s|dk(  r	 t        | ||«      S |dk(  r	 t!        | ||«      S |dk(  r1t        j#                  | dd¬«      }|�Ct%        |j&                  ||«      S t        j                  d| › �«       t        j                  «       } 	 t        | ||«      S # t        $ r-}t        j                  dt        |«      › �«       |cY d}~S d}~ww xY w# t        $ r Y ŒRt        $ r t        j                  «       } Y Œpw xY w# t        $ r Y Œw xY w# t        $ r-}t        j                  dt        |«      › �«       |cY d}~S d}~ww xY w)	už  Returns a font abstraction based on class :class:`AbstractFont`.

    Supported font types:

    - .ttf, .ttc and .otf - TrueType fonts
    - .shx, .shp - AutodeskÂ® shapefile fonts
    - .lff - LibreCAD font format

    The special name "\*monospace" returns the fallback font :class:`MonospaceFont` for
    testing and basic measurements.

    .. note:: The font definition files are not included in `ezdxf`.

    Args:
        font_name: font file name as stored in the :class:`~ezdxf.entities.Textstyle`
            entity e.g. "OpenSans-Regular.ttf"
        cap_height: desired cap height in drawing units.
        width_factor: horizontal text stretch factor

    zno default font found: Nr<   z.shpr1   r0   )rl   rm   rp   zunsupported font-name suffix: )rð   rÙ   r  ræ   Úsuffixr>   r   rd   r   rˆ   rŸ   rO   r"  r   r5   r  r*  rr   Ú	make_fontÚfilename)r*   r_   rº   ÚextÚlast_resortr‹   ru   s          r,   r/  r/  „  s²  € ð. ”IÒÜ˜Z¨Ó6Ð6Ü
�,‰,�yÓ
!×
(Ñ
(×
.Ñ
.Ó
0€CÜ 
¨LÓ9€KØ
Ô!Ñ!ð	Ü 	¨:°|ÓDÐDð 
�Š˜# š-ð	:Ü  ¨J¸ÓEÐEð 
�Šð	Ü 	¨:°|ÓDÐDð 
�ŠÜ ×0Ñ0Ø F°4ð 1ó 
ˆ	ð Ð Ü˜Y×/Ñ/°¸\ÓJÐJä�‰Ð7¸	°{ÐCÔDÜ ×3Ñ3Ó5ˆ	ðÜ˜I z°<Ó@Ð@øô9 !ò 	Ü�N‰NÐ4´S¸³V°HÐ=Ô>ØÕûð	ûô !ò 	ÙÜò 	:ä$×7Ñ7Ó9ŠIð	:ûô !ò 	Ùð	ûô ò Ü�‰Ð0´°Q³°Ð9Ô:ØÕûðúsf   ÁD  Á0D9 ÂE& Ã3E5 Ä 	D6Ä	"D1Ä+D6Ä1D6Ä9	E#ÅE#Å"E#Å&	E2Å1E2Å5	F+Å>"F&Æ F+Æ&F+c                óÄ  — | j                   r|€| j                   }|€
t        «       S d}| j                  j                  d«      r| j                  j                  }t        «       }|rzt        d|j                  j                  |«      «      }|j                  «       \  }}}|r|rdnd}|rdnd}	t        |||	¬«      }|S |j                  j                  }
|
rt        |
«      }|S )	aþ  Returns the :class:`FontFace` defined by the associated text style.
    Returns the default font face if the `entity` does not have or support
    the DXF attribute "style". Supports the extended font information stored in
    :class:`~ezdxf.entities.Textstyle` table entries.

    Pass a DXF document as argument `doc` to resolve text styles for virtual
    entities which are not assigned to a DXF document. The argument `doc`
    always overrides the DXF document to which the `entity` is assigned to.

    r0   rm   r   ÚItalicrh   i¼  ri   )rl   rm   rn   )Údocr	   ÚdxfÚis_supportedrm   r   Ústylesr4   Úget_extended_font_datarf   rJ   )Úentityr5  Ú
style_nameru   rm   rl   rp   ÚboldÚ
text_styleÚtext_weightrB   s              r,   Úget_entity_font_facer?  Ä  sÒ   € ð ‡z‚z�c�kØ�j‰jˆØ
€{Ü‹zÐà€Jð ‡z�z×Ñ˜wÔ'Ø—Z‘Z×%Ñ%ˆ
ä“
€IÙÜ�[ #§*¡*§.¡.°Ó"<Ó=ˆØ$×;Ñ;Ó=Ñˆ�˜ÙÙ%+™°ˆJÙ!%™#¨3ˆKÜ ¨°jÈÔUˆIð
 Ðð —)‘)—.‘.ˆCÙÜ)¨#Ó.�	ØÐr.   )r*   rO   rÊ   rO   )r*   rO   rÊ   Úbool)rB   rO   rÊ   zOptional[str])rÊ   ÚNone)r*   rO   rÊ   r	   )T)r*   rO   rW   rO   rÊ   rO   )Útsl)r*   rO   rÊ   r   )rl   rO   rm   rO   rn   Úintro   rC  rp   zOptional[bool]rÊ   zOptional[FontFace])ru   r	   rÊ   rO   )r”   úpathlib.PathrÊ   rA  )rš   rD  rÊ   rA  )r  zstr | os.PathLikerÊ   r«   rÌ   )r*   rO   r_   rË   rº   rË   rÊ   r«   r®   )r:  r   r5  zOptional[Drawing]rÊ   r	   )LÚ
__future__r   Útypingr   r   r   rÖ   r¦   ÚloggingÚosr  r   r   ru   r	   r5   r
   r   r   r   Úfont_synonymsr   rú   r   Úglyphsr   r   Úezdxf.documentr   Úezdxf.entitiesr   r   Ú	getLoggerrˆ   r€   rŽ   r   r)   r3   Úitemsr7   rA   rc   rb   rð   r-   r:   r?   rC   rH   rK   rJ   rY   r[   rg   rr   rv   r{   rF   ry   r–   r›   rE   ÚEnumr¢   r«   rÙ   ÚABCrô   rd   r  r   r"  r*  r/  r?  )ÚkÚvs   00r,   Ú<module>rS     s  ðõ #ß 0Ñ 0Û 
Û Û Û 	Û å Ý ÷ó õ )Ý /ß %áÝ&ß3à	ˆ×	Ñ	˜7Ó	#€Ø3Ð àÐ Ø€Ù‹}€ð'ð ˆ^ð'ð �ð'ð ˆ~ð'ð �>ð'ð ˆ[ð'ð  �ð!'ð" ˆnð#'ð$ �.ð%'ð& ˆ~ð''ð( �>ð)'ð* ˆlð+'ð, �,ð-'ð. ˆnð/'ð0 �.ð1'ð2 ˆ~ð3'ð4 �>ð5'ð6 ˆ~ð7'ð8 "ØØ!ØØ ØØØØ!ØØòM'€	ðR Øñ€	ð  )Ÿ™Ô0ÔFÑ0‘t�q˜!°A·J±J¸uÕ4Eˆa�‰dÐ0ÒF€
ØÐ Ø€Ø€	óóóó'ó
7ó1ô%ó,ô8%ô6ð4 ØØØØ"ñNàðNð ðNð ð	Nð
 ðNð ðNð óNó.2ò
;ò0ó
&ó5ó6ó@ô$�T—Y‘Yô ÷/ñ /ôdK!�Lô K!ô\8!�, §¡ô 8!ôv�;ô ô>˜[ô ó"
>ô�Kô ô*�;ô ð, >Að=Øð=Ø %ð=Ø5:ð=àó=ô@"ñJ …ùów Gs   ÃG)Ã5G)