mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
moved 'language' parameter to last parameter in relevant functions
This commit is contained in:
parent
c174c90ac1
commit
d5bbf01254
|
@ -326,7 +326,7 @@ Methods
|
|||
|
||||
.. versionadded:: 4.2.0
|
||||
|
||||
.. py:method:: PIL.ImageDraw.ImageDraw.textsize(text, font=None, spacing=4, direction=None, language=None, features=None)
|
||||
.. py:method:: PIL.ImageDraw.ImageDraw.textsize(text, font=None, spacing=4, direction=None, features=None, language=None)
|
||||
|
||||
Return the size of the given string, in pixels.
|
||||
|
||||
|
@ -340,15 +340,6 @@ Methods
|
|||
Requires libraqm.
|
||||
|
||||
.. versionadded:: 4.2.0
|
||||
: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 `BCP47 language code
|
||||
<https://www.w3.org/International/articles/language-tags/>`
|
||||
Requires libraqm.
|
||||
|
||||
.. versionadded:: 6.0.0
|
||||
: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,
|
||||
|
@ -361,6 +352,15 @@ Methods
|
|||
Requires libraqm.
|
||||
|
||||
.. versionadded:: 4.2.0
|
||||
: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 `BCP47 language code
|
||||
<https://www.w3.org/International/articles/language-tags/>`
|
||||
Requires libraqm.
|
||||
|
||||
.. versionadded:: 6.0.0
|
||||
|
||||
.. py:method:: PIL.ImageDraw.ImageDraw.multiline_textsize(text, font=None, spacing=4, direction=None, features=None)
|
||||
|
||||
|
|
|
@ -47,11 +47,11 @@ Functions
|
|||
Methods
|
||||
-------
|
||||
|
||||
.. py:method:: PIL.ImageFont.ImageFont.getsize(text, direction=None, language=None, features=[])
|
||||
.. py:method:: PIL.ImageFont.ImageFont.getsize(text, direction=None, features=[], language=None)
|
||||
|
||||
:return: (width, height)
|
||||
|
||||
.. py:method:: PIL.ImageFont.ImageFont.getmask(text, mode='', direction=None, language=None, features=[])
|
||||
.. py:method:: PIL.ImageFont.ImageFont.getmask(text, mode='', direction=None, features=[], language=None)
|
||||
|
||||
Create a bitmap for the text.
|
||||
|
||||
|
@ -72,16 +72,6 @@ Methods
|
|||
|
||||
.. versionadded:: 4.2.0
|
||||
|
||||
: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 `BCP47 language code
|
||||
<https://www.w3.org/International/articles/language-tags/>`
|
||||
Requires libraqm.
|
||||
|
||||
.. versionadded:: 6.0.0
|
||||
|
||||
: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,
|
||||
|
@ -95,5 +85,15 @@ Methods
|
|||
|
||||
.. versionadded:: 4.2.0
|
||||
|
||||
: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 `BCP47 language code
|
||||
<https://www.w3.org/International/articles/language-tags/>`
|
||||
Requires libraqm.
|
||||
|
||||
.. versionadded:: 6.0.0
|
||||
|
||||
:return: An internal PIL storage memory instance as defined by the
|
||||
:py:mod:`PIL.Image.core` interface module.
|
||||
|
|
|
@ -158,17 +158,17 @@ class FreeTypeFont(object):
|
|||
def getmetrics(self):
|
||||
return self.font.ascent, self.font.descent
|
||||
|
||||
def getsize(self, text, direction=None, language=None, features=None):
|
||||
size, offset = self.font.getsize(text, direction, language, features)
|
||||
def getsize(self, text, direction=None, features=None, language=None):
|
||||
size, offset = self.font.getsize(text, direction, features, language)
|
||||
return (size[0] + offset[0], size[1] + offset[1])
|
||||
|
||||
def getsize_multiline(self, text, direction=None, language=None,
|
||||
spacing=4, features=None):
|
||||
def getsize_multiline(self, text, direction=None, spacing=4,
|
||||
features=None, language=None):
|
||||
max_width = 0
|
||||
lines = self._multiline_split(text)
|
||||
line_spacing = self.getsize('A')[1] + spacing
|
||||
for line in lines:
|
||||
line_width, line_height = self.getsize(line, direction, language, features)
|
||||
line_width, line_height = self.getsize(line, direction, features, language)
|
||||
max_width = max(max_width, line_width)
|
||||
|
||||
return max_width, len(lines)*line_spacing - spacing
|
||||
|
@ -176,15 +176,15 @@ class FreeTypeFont(object):
|
|||
def getoffset(self, text):
|
||||
return self.font.getsize(text)[1]
|
||||
|
||||
def getmask(self, text, mode="", direction=None, language=None, features=None):
|
||||
return self.getmask2(text, mode, direction=direction, language=language,
|
||||
features=features)[0]
|
||||
def getmask(self, text, mode="", direction=None, features=None, language=None):
|
||||
return self.getmask2(text, mode, direction=direction, features=features,
|
||||
language=language)[0]
|
||||
|
||||
def getmask2(self, text, mode="", fill=Image.core.fill, direction=None,
|
||||
language=None, features=None, *args, **kwargs):
|
||||
size, offset = self.font.getsize(text, direction, language, features)
|
||||
features=None, language=None, *args, **kwargs):
|
||||
size, offset = self.font.getsize(text, direction, features, language)
|
||||
im = fill("L", size, 0)
|
||||
self.font.render(text, im.id, mode == "1", direction, language, features)
|
||||
self.font.render(text, im.id, mode == "1", direction, features, language)
|
||||
return im, offset
|
||||
|
||||
def font_variant(self, font=None, size=None, index=None, encoding=None,
|
||||
|
|
|
@ -341,8 +341,8 @@ font_getchar(PyObject* string, int index, FT_ULong* char_out)
|
|||
}
|
||||
|
||||
static size_t
|
||||
text_layout_raqm(PyObject* string, FontObject* self, const char* dir, const char* lang,
|
||||
PyObject *features ,GlyphInfo **glyph_info, int mask)
|
||||
text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *features,
|
||||
const char* lang, GlyphInfo **glyph_info, int mask)
|
||||
{
|
||||
int i = 0;
|
||||
raqm_t *rq;
|
||||
|
@ -521,8 +521,8 @@ failed:
|
|||
}
|
||||
|
||||
static size_t
|
||||
text_layout_fallback(PyObject* string, FontObject* self, const char* dir, const char* lang,
|
||||
PyObject *features ,GlyphInfo **glyph_info, int mask)
|
||||
text_layout_fallback(PyObject* string, FontObject* self, const char* dir, PyObject *features,
|
||||
const char* lang, GlyphInfo **glyph_info, int mask)
|
||||
{
|
||||
int error, load_flags;
|
||||
FT_ULong ch;
|
||||
|
@ -587,15 +587,15 @@ text_layout_fallback(PyObject* string, FontObject* self, const char* dir, const
|
|||
}
|
||||
|
||||
static size_t
|
||||
text_layout(PyObject* string, FontObject* self, const char* dir, const char* lang,
|
||||
PyObject *features, GlyphInfo **glyph_info, int mask)
|
||||
text_layout(PyObject* string, FontObject* self, const char* dir, PyObject *features,
|
||||
const char* lang, GlyphInfo **glyph_info, int mask)
|
||||
{
|
||||
size_t count;
|
||||
|
||||
if (p_raqm.raqm && self->layout_engine == LAYOUT_RAQM) {
|
||||
count = text_layout_raqm(string, self, dir, lang, features, glyph_info, mask);
|
||||
count = text_layout_raqm(string, self, dir, features, lang, glyph_info, mask);
|
||||
} else {
|
||||
count = text_layout_fallback(string, self, dir, lang, features, glyph_info, mask);
|
||||
count = text_layout_fallback(string, self, dir, features, lang, glyph_info, mask);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
@ -615,14 +615,14 @@ font_getsize(FontObject* self, PyObject* args)
|
|||
/* calculate size and bearing for a given string */
|
||||
|
||||
PyObject* string;
|
||||
if (!PyArg_ParseTuple(args, "O|zzO:getsize", &string, &dir, &lang, &features))
|
||||
if (!PyArg_ParseTuple(args, "O|zOz:getsize", &string, &dir, &features, &lang))
|
||||
return NULL;
|
||||
|
||||
face = NULL;
|
||||
xoffset = yoffset = 0;
|
||||
y_max = y_min = 0;
|
||||
|
||||
count = text_layout(string, self, dir, lang, features, &glyph_info, 0);
|
||||
count = text_layout(string, self, dir, features, lang, &glyph_info, 0);
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -720,12 +720,12 @@ font_render(FontObject* self, PyObject* args)
|
|||
GlyphInfo *glyph_info;
|
||||
PyObject *features = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "On|izzO:render", &string, &id, &mask, &dir, &lang, &features)) {
|
||||
if (!PyArg_ParseTuple(args, "On|izOz:render", &string, &id, &mask, &dir, &features, &lang)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
glyph_info = NULL;
|
||||
count = text_layout(string, self, dir, lang, features, &glyph_info, mask);
|
||||
count = text_layout(string, self, dir, features, lang, &glyph_info, mask);
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user