1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
Ë
³òúh…0ãó<—ddlmZddlmZddlmZGd„d«Zy)é)Ú annotationsé)Ú    ImageFont)Ú_Inkcó–—eZdZ                        d                                                                d
d„Zd d„Zd d d„Zdd„Zd„Z                                dd„Z            d                            dd„Z    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_defaultÚfontÚmodeÚspacingÚ    directionÚfeaturesÚlanguageÚembedded_colorÚ stroke_widthÚ stroke_fill)Úselfr
r r rrrrs        ú@H:\Change_password\venv_build\Lib\site-packages\PIL/ImageText.pyÚ__init__z Text.__init__s\€ðTˆŒ    ØÒ4œI×2Ñ2Ó4ˆŒ    àˆŒ    ØˆŒ Ø"ˆŒØ ˆŒ Ø ˆŒ à#ˆÔà#$ˆÔØ(,ˆÕócóH—|jdvr d}t|«‚d|_y)z?
        Use embedded color glyphs (COLR, CBDT, SBIX).
        )ÚRGBÚRGBAz3Embedded color supported only in RGB and RGBA modesTN)r Ú
ValueErrorr)rÚmsgs  rÚ embed_colorzText.embed_color@s'€ð 9‰9˜OÑ +ØGˆCܘS“/Ð !Ø"ˆÕ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)rÚwidthÚfills   rÚstrokez Text.strokeIs€ð"ˆÔ؈Õrcó<—|jdvry|jryy)N)Ú1ÚPÚIÚFr$rÚL)r r)rs rÚ _get_fontmodezText._get_fontmodeSs!€Ø 9‰9Ð,Ñ ,ØØ ×  Ò  Øàrcó—t|jt«rdnd}||jvr d}t|«‚|jj |j|j «|j|j|j«S)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)rÚsplit_characterrs   rÚ
get_lengthzText.get_length[ss€ôT#-¨T¯Y©Y¼Ô"<™$À%ˆØ ˜dŸi™iÑ 'Ø:ˆCܘS“/Ð !؏y‰y×"Ñ"Ø I‰IØ × Ñ Ó  Ø N‰NØ M‰MØ M‰Mó 
ð    
rc ón—|€|jdk(rdnd}nt|«dk7r d}t|«‚t|jt
«r|jj d«n|jj d«}t|«dk(r|||jfgS|dd    vr|jdk7r d
}t|«‚|j«}|jjd |d|j|j|j«d |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 k7r|t|«dz
k7rt| t
«r| j d«n| j d«}t|«dkDrÃ|d dk(r    |
| dz z}
n |d dk(r|
| z}
|Dcgc]?}|jj|||j|j|j«‘ŒA}}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)NÚttbÚltÚlaéz#anchor must be a 2 character stringr+r,rÚtbz'anchor not supported for multiline textÚAérÚmg@Údéÿÿÿÿ)ÚleftÚjustifyÚcenterÚrightz4align must be "left", "center", "right" or "justify"r>ú ó ÚrÚl)rÚlenrr-r
r.Úsplitr)r ÚgetbboxrrrrÚappendr/ÚmaxÚsum)rÚxyÚanchorÚalignrÚlinesÚfontmodeÚ line_spacingÚtopÚpartsr=ÚlineÚwidthsÚ    max_widthÚ
line_widthÚidxÚwidth_differenceÚwordsÚwordÚ word_widthsÚ word_anchorÚis                      rÚ_splitz Text._split‘sb€ð ˆ>Ø!Ÿ^™^¨uÒ4‘T¸$‰FÜ ‹[˜AÒ Ø7ˆCܘS“/Ð !ô˜$Ÿ)™)¤SÔ)ð I‰IO‰O˜DÔ !à—‘—‘ Ó'ð    ô
ˆu‹:˜Š?ؘ §¡Ð+Ð,Ð ,à !‰9˜Ñ  §¡°5Ò!8Ø;ˆCܘS“/Ð !à×%Ñ%Ó'ˆà I‰I× Ñ ØØØØ— ‘ Ø— ‘ Ø×!Ñ!ó  ðñ ð×Ññ  ðl‰lñ     ð    ð‰eˆØˆØ >‰>˜UÒ "ؐa‘5ˆDØò %Ø— ‘ ˜t S˜k¨6°4Ð8Ô9ؘ Ñ$‘ð %ð\ˆ ðUˆFØ ˆIØò 7Ø!ŸY™Y×0Ñ0ؘ( D§N¡N°D·M±MÀ4Ç=Á=ó
ð— ‘ ˜jÔ)Ü     ¨:Ó6‘    ð  7ða‰y˜CÒØœ˜E›
 Q™¨,Ñ6¸Ñ<Ñ<‘ؘ‘˜cÒ!Øœ˜E›
 Q™¨,Ñ6Ñ6àˆCØó9 $Ø˜!‘uØq‘Ø#,¨v°c©{Ñ#:РðÐ/Ñ/ØØ˜hÒ&ØÐ,¨sÑ2Ñ2‘DؘgÒ%ØÐ,Ñ,‘DàPCÜ$ S›/Ð)ð˜YÓ&Ø(¨AÓ-Øœs 5›z¨A™~Ó-ô,6°d¼CÔ+@˜Ÿ
™
 3œÀdÇjÁjÐQUÓFVðô˜5“z A’~à! !™9¨Ò+Ø  I°¡OÑ3™DØ# A™Y¨#Ò-Ø  IÑ-˜Dð).ö    'ð!%ð!ŸI™I×/Ñ/Ø $Ø (Ø $§¡Ø $§ ¡ Ø $§ ¡ õ ð    '˜ ð    'ð'*¨F°1©I¡o˜ Ø+4´s¸;Ó7GÑ+GÐ(ؘØ$)ò#˜DØ!ŸL™L¨4°¨+°{ÀDÐ)IÔJØ  K°¡NÐ5EÌÈUËÐVWÉÑ5XÑ$XÑX˜DØ ™F™Að#ð˜|Ñ+˜Ù ð˜!‘9 Ò#ØÐ,¨sÑ2Ñ2‘DؘA‘Y #Ò%ØÐ,Ñ,DØ— ‘ ˜t S˜k¨6°4Ð8Ô9ؐ|Ñ#’ðs9 $ðvˆ ùò9    'sËAN2c
ó—d}|j«}|j|||«D]Ä\}}}|jj|||j|j
|j |j|«}|d|dz|d|dz|d|dz|d|dzf}|€|}Œt|d|d«t|d|d«t|d|d«t|d|d«f}ŒÆ|€|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 rGrrrrÚminrI)rrKrLrMÚbboxrOrSÚ    bbox_lines        rÚget_bboxz Text.get_bboxsF€ð0:>ˆØ×%Ñ%Ó'ˆØ $§ ¡ ¨B°¸Ó >ò    Ñ ˆB˜ØŸ    ™    ×)Ñ)ØØØ—‘Ø— ‘ Ø— ‘ Ø×!Ñ!ØóˆIð˜!‘ ˜r !™uÑ$ؘ!‘ ˜r !™uÑ$ؘ!‘ ˜r !™uÑ$ؘ!‘ ˜r !™uÑ$ð    ˆIð ˆ|Ø ‘ô˜˜Q™ ¨1¡Ó.ܘ˜Q™ ¨1¡Ó.ܘ˜Q™ ¨1¡Ó.ܘ˜Q™ ¨1¡Ó.ð    ‘ð'    ð4 ˆ<ؐa‘5˜"˜Q™%  A¡¨¨1©Ð-Ð -؈ r)NréNNN)r
z str | bytesr zNImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | Noner r.rÚfloatrú
str | Nonerzlist[str] | NonerrfÚreturnÚNone)rgrh)rN)r rer!z _Ink | Nonergrh)rgr.)rKútuple[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^rc©rrrrsà„ð ØØØ $Ø%)Ø#ð6-àð6-ð ð    6-ðð6-ðð6-ðð6-ð#ð6-ðð6-ð
ó6-óp#ô óò4
ðluØ%ðuØ/9ðuØBEðuà    ;óuðr#)Ø!Øð    6à ð6ðð6ðð    6ð
 
+ô 6rrN)Ú
__future__rÚrÚ_typingrrrmrrú<module>rqsðÝ"åÝ÷wòwr