K iG/<ddlmZddlmZddlmZGddZy)) annotations) ImageFont)_InkceZdZ d d dZd dZd d dZddZdZ ddZ d ddZ y)TextNc||_|xstj|_||_||_||_||_||_d|_ d|_ d|_ y)a :param text: String to be drawn. :param font: Either an :py:class:`~PIL.ImageFont.ImageFont` instance, :py:class:`~PIL.ImageFont.FreeTypeFont` instance, :py:class:`~PIL.ImageFont.TransposedFont` instance or ``None``. If ``None``, the default font from :py:meth:`.ImageFont.load_default` will be used. :param mode: The image mode this will be used with. :param spacing: The number of pixels between lines. :param direction: Direction of the text. It can be ``"rtl"`` (right to left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom). Requires libraqm. :param features: A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example ``"dlig"`` or ``"ss01"``, but can be also used to turn off default font features, for example ``"-liga"`` to disable ligatures or ``"-kern"`` to disable kerning. To get all supported features, see `OpenType docs`_. Requires libraqm. :param language: Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a `BCP 47 language code`_. Requires libraqm. FrN) textr load_defaultfontmodespacing directionfeatureslanguageembedded_color stroke_width stroke_fill)selfr r r rrrrs S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/PIL/ImageText.py__init__z Text.__init__s\T 4I224   "    ##$(,cH|jdvr d}t|d|_y)z? Use embedded color glyphs (COLR, CBDT, SBIX). )RGBRGBAz3Embedded color supported only in RGB and RGBA modesTN)r ValueErrorr)rmsgs r embed_colorzText.embed_color@s' 99O +GCS/ !"rc ||_||_y)a  :param width: The width of the text stroke. :param fill: Color to use for the text stroke when drawing. If not given, will default to the ``fill`` parameter from :py:meth:`.ImageDraw.ImageDraw.text`. N)rr)rwidthfills rstrokez Text.strokeIs"rc<|jdvry|jryy)N)1PIFr$rL)r r)rs r _get_fontmodezText._get_fontmodeSs! 99, ,  rct|jtrdnd}||jvr d}t||jj |j|j |j|j|jS)a Returns length (in pixels with 1/64 precision) of text. This is the amount by which following text should be offset. Text bounding box may extend past the length in some fonts, e.g. when using italics or accents. The result is returned as a float; it is a whole number if using basic layout. Note that the sum of two lengths may not equal the length of a concatenated string due to kerning. If you need to adjust for kerning, include the following character and subtract its length. For example, instead of:: hello = ImageText.Text("Hello", font).get_length() world = ImageText.Text("World", font).get_length() helloworld = ImageText.Text("HelloWorld", font).get_length() assert hello + world == helloworld use:: hello = ( ImageText.Text("HelloW", font).get_length() - ImageText.Text("W", font).get_length() ) # adjusted for kerning world = ImageText.Text("World", font).get_length() helloworld = ImageText.Text("HelloWorld", font).get_length() assert hello + world == helloworld or disable kerning with (requires libraqm):: hello = ImageText.Text("Hello", font, features=["-kern"]).get_length() world = ImageText.Text("World", font, features=["-kern"]).get_length() helloworld = ImageText.Text( "HelloWorld", font, features=["-kern"] ).get_length() assert hello + world == helloworld :return: Either width for horizontal text, or height for vertical text.   z&can't measure length of multiline text) isinstancer strrr getlengthr)rrr)rsplit_characterrs r get_lengthzText.get_length[ssT#-TYY"<$% dii ':CS/ !yy"" II    NN MM MM   rc n||jdk(rdnd}nt|dk7r d}t|t|jt r|jj dn|jj d}t|dk(r|||jfgS|dd vr|jdk7r d }t||j}|jjd |d|j|j|jd |jz|jz}|d}g} |jdk(r)|d } |D]} | j| |f|| f| |z } | Sg} d } |D]\} |jj| ||j|j|j}| j|t!| |} ^|ddk(r|t|dz |zdz z}n|ddk(r|t|dz |zz}d}|D]} |d } |dz }| | |z }|dvrn&|dk(r | |dz z } n|dk(r| |z } n d}t||dk(r|d k7r|t|dz k7rt| t r| j dn| j d}t|dkDr|d dk(r | | dz z} n |d dk(r| | z} |Dcgc]?}|jj|||j|j|jA}}d|dz}| t#|z }d }|D]7}| j| |f||f| |||t|dz z zz } |dz }9||z }b|d dk(r | |dz z} n |d dk(r| |z} | j| |f|| f||z }| Scc}w)Nttbltlaz#anchor must be a 2 character stringr+r,rtbz'anchor not supported for multiline textArmg@d)leftjustifycenterrightz4align must be "left", "center", "right" or "justify"r>  rl)rlenrr-r r.splitr)r getbboxrrrrappendr/maxsum)rxyanchoralignrlinesfontmode line_spacingtoppartsr=linewidths max_width line_widthidxwidth_differencewordsword word_widths word_anchoris r_splitz Text._splitsb >!^^u4T$F [A 7CS/ !$))S) IIOOD !'  u:?+, , !9 5!8;CS/ !%%' II    !!    ll  e >>U "a5D % tSk6489 $ %\ UF I 7!YY00(DNNDMM4==  j) :6  7ayCE Q,6<<c!E Q,66C9 $!uq#,vc{#: //h&,s22Dg%,,DPC$S/)Y&(A-s5zA~-,6dC+@ 3djjQUFV5zA~!!9+ IO3D#AY#- I-D). '!%!II// $ ( $ $ $  ' ''*F1Io +4s;7G+G($)#D!LL4+{D)IJ KN5EUVW5X$XXDFA#|+ !9#,s22DAY#%,,D tSk6489|#s9 $v 9 'sAN2c d}|j}|j|||D]\}}}|jj|||j|j |j |j|}|d|dz|d|dz|d|dz|d|dzf}||}t|d|dt|d|dt|d|dt|d|df}||d|d|d|dfS|S)a Returns bounding box (in pixels) of text. Use :py:meth:`get_length` to get the offset of following text with 1/64 pixel precision. The bounding box includes extra margins for some fonts, e.g. italics or accents. :param xy: The anchor coordinates of the text. :param anchor: The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left, specifically ``la`` for horizontal text and ``lt`` for vertical text. See :ref:`text-anchors` for details. :param align: For multiline text, ``"left"``, ``"center"``, ``"right"`` or ``"justify"`` determines the relative alignment of lines. Use the ``anchor`` parameter to specify the alignment to ``xy``. :return: ``(left, top, right, bottom)`` bounding box Nrrr6r9) r)r^r rGrrrrminrI)rrKrLrMbboxrOrS bbox_lines rget_bboxz Text.get_bboxsF0:>%%' $ B >  B ))  !!I! r!u$! r!u$! r!u$! r!u$ I | Q1.Q1.Q1.Q1. ' 4 <a5"Q%A1- - r)NrNNN)r z str | bytesr zNImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | Noner r.rfloatr str | Nonerzlist[str] | NonerrfreturnNone)rgrh)rN)r rer!z _Ink | Nonergrh)rgr.)rKtuple[float, float]rLrfrMr.rgz2list[tuple[tuple[float, float], str, str | bytes]]))rrNr=)rKrirLrfrMr.rgz!tuple[float, float, float, float]) __name__ __module__ __qualname__rrr"r)r1r^rcrrrrs  $%)#6-6-  6-6-6-6-#6-6- 6-p# 4 lu%u/9uBEu ;ur#)! 6 66 6 + 6rrN) __future__rr_typingrrrmrrrqs"wwr