mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
update
This commit is contained in:
parent
fd7a675de6
commit
e07a254ed9
|
@ -202,9 +202,11 @@ class ImageDraw(object):
|
||||||
|
|
||||||
return text.split(split_character)
|
return text.split(split_character)
|
||||||
|
|
||||||
def text(self, xy, text, fill=None, font=None, anchor=None, *args, **kwargs):
|
def text(self, xy, text, fill=None, font=None, anchor=None,
|
||||||
|
*args, **kwargs):
|
||||||
if self._multiline_check(text):
|
if self._multiline_check(text):
|
||||||
return self.multiline_text(xy, text, fill, font, anchor, *args, **kwargs)
|
return self.multiline_text(xy, text, fill, font, anchor,
|
||||||
|
*args, **kwargs)
|
||||||
ink, fill = self._getink(fill)
|
ink, fill = self._getink(fill)
|
||||||
if font is None:
|
if font is None:
|
||||||
font = self.getfont()
|
font = self.getfont()
|
||||||
|
|
|
@ -5,7 +5,6 @@ modules = {
|
||||||
"tkinter": "PIL._tkinter_finder",
|
"tkinter": "PIL._tkinter_finder",
|
||||||
"freetype2": "PIL._imagingft",
|
"freetype2": "PIL._imagingft",
|
||||||
"littlecms2": "PIL._imagingcms",
|
"littlecms2": "PIL._imagingcms",
|
||||||
"raqm": "PIL._imagingft",
|
|
||||||
"webp": "PIL._webp",
|
"webp": "PIL._webp",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from helper import unittest, PillowTestCase
|
from helper import unittest, PillowTestCase
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import ImageDraw
|
from PIL import ImageDraw, ImageFont
|
||||||
|
|
||||||
|
#check if raqm installed
|
||||||
|
have_raqm = ImageFont.core.have_raqm
|
||||||
|
|
||||||
FONT_SIZE = 20
|
FONT_SIZE = 20
|
||||||
FONT_PATH = "Tests/fonts/DejaVuSans.ttf"
|
FONT_PATH = "Tests/fonts/DejaVuSans.ttf"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PIL import ImageFont
|
from PIL import ImageFont
|
||||||
|
|
||||||
# check if raqm is available
|
|
||||||
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||||
im = Image.new(mode='RGB', size=(300, 100))
|
im = Image.new(mode='RGB', size=(300, 100))
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
draw.text((0, 0), 'TEST', font=ttf, fill=500, direction='ltr')
|
draw.text((0, 0), 'TEST', font=ttf, fill=500, direction='ltr')
|
||||||
|
@unittest.skipIf(not have_raqm, "Raqm Library is not installed !")
|
||||||
class TestImagecomplextext(PillowTestCase):
|
class TestImagecomplextext(PillowTestCase):
|
||||||
|
|
||||||
def test_complex_text(self):
|
def test_complex_text(self):
|
||||||
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||||
|
|
||||||
|
|
16
_imagingft.c
16
_imagingft.c
|
@ -43,14 +43,6 @@
|
||||||
#define FT_ERROR_END_LIST { 0, 0 } };
|
#define FT_ERROR_END_LIST { 0, 0 } };
|
||||||
#ifdef HAVE_RAQM
|
#ifdef HAVE_RAQM
|
||||||
#include <raqm.h>
|
#include <raqm.h>
|
||||||
#else
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
RAQM_DIRECTION_DEFAULT,
|
|
||||||
RAQM_DIRECTION_RTL,
|
|
||||||
RAQM_DIRECTION_LTR,
|
|
||||||
RAQM_DIRECTION_TTB
|
|
||||||
} raqm_direction_t;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -830,6 +822,14 @@ setup_module(PyObject* m) {
|
||||||
#endif
|
#endif
|
||||||
PyDict_SetItemString(d, "freetype2_version", v);
|
PyDict_SetItemString(d, "freetype2_version", v);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_RAQM
|
||||||
|
v = PyBool_FromLong(1);
|
||||||
|
#else
|
||||||
|
v = PyBool_FromLong(0);
|
||||||
|
#endif
|
||||||
|
PyDict_SetItemString(d, "have_raqm", v);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,16 @@ Many of Pillow's features require external libraries:
|
||||||
* Windows support: Libimagequant requires VS2013/MSVC 18 to compile,
|
* Windows support: Libimagequant requires VS2013/MSVC 18 to compile,
|
||||||
so it is unlikely to work with any Python prior to 3.5 on Windows.
|
so it is unlikely to work with any Python prior to 3.5 on Windows.
|
||||||
|
|
||||||
|
* **libraqm** provides complex text layout support.
|
||||||
|
|
||||||
|
* libraqm provides bidirectional text support (using FriBiDi),
|
||||||
|
shaping (using HarfBuzz), and proper script itemization. As a
|
||||||
|
result, Raqm can support most writing systems covered by Unicode.
|
||||||
|
* libraqm depends on the following libraries: FreeType, HarfBuzz,
|
||||||
|
FriBiDi, make sure that install them before install libraqm if not
|
||||||
|
available as package in your system.
|
||||||
|
* setting text direction or font features is not supported without libraqm.
|
||||||
|
|
||||||
Once you have installed the prerequisites, run::
|
Once you have installed the prerequisites, run::
|
||||||
|
|
||||||
$ pip install Pillow
|
$ pip install Pillow
|
||||||
|
@ -201,14 +211,16 @@ Build Options
|
||||||
* Build flags: ``--disable-zlib``, ``--disable-jpeg``,
|
* Build flags: ``--disable-zlib``, ``--disable-jpeg``,
|
||||||
``--disable-tiff``, ``--disable-freetype``, ``--disable-tcl``,
|
``--disable-tiff``, ``--disable-freetype``, ``--disable-tcl``,
|
||||||
``--disable-tk``, ``--disable-lcms``, ``--disable-webp``,
|
``--disable-tk``, ``--disable-lcms``, ``--disable-webp``,
|
||||||
``--disable-webpmux``, ``--disable-jpeg2000``, ``--disable-imagequant``.
|
``--disable-webpmux``, ``--disable-jpeg2000``,
|
||||||
|
``--disable-imagequant``, ``--disable-raqm``.
|
||||||
Disable building the corresponding feature even if the development
|
Disable building the corresponding feature even if the development
|
||||||
libraries are present on the building machine.
|
libraries are present on the building machine.
|
||||||
|
|
||||||
* Build flags: ``--enable-zlib``, ``--enable-jpeg``,
|
* Build flags: ``--enable-zlib``, ``--enable-jpeg``,
|
||||||
``--enable-tiff``, ``--enable-freetype``, ``--enable-tcl``,
|
``--enable-tiff``, ``--enable-freetype``, ``--enable-tcl``,
|
||||||
``--enable-tk``, ``--enable-lcms``, ``--enable-webp``,
|
``--enable-tk``, ``--enable-lcms``, ``--enable-webp``,
|
||||||
``--enable-webpmux``, ``--enable-jpeg2000``, ``--enable-imagequant``.
|
``--enable-webpmux``, ``--enable-jpeg2000``,
|
||||||
|
``--enable-imagequant``, ``--enable-raqm``.
|
||||||
Require that the corresponding feature is built. The build will raise
|
Require that the corresponding feature is built. The build will raise
|
||||||
an exception if the libraries are not found. Webpmux (WebP metadata)
|
an exception if the libraries are not found. Webpmux (WebP metadata)
|
||||||
relies on WebP support. Tcl and Tk also must be used together.
|
relies on WebP support. Tcl and Tk also must be used together.
|
||||||
|
@ -247,7 +259,16 @@ The easiest way to install external libraries is via `Homebrew
|
||||||
|
|
||||||
$ brew install libtiff libjpeg webp little-cms2
|
$ brew install libtiff libjpeg webp little-cms2
|
||||||
|
|
||||||
Install Pillow with::
|
To install libraqm on MaxOS use Homebrew::
|
||||||
|
$ brew install freetype harfbuzz fribidi
|
||||||
|
Once you have `libraqm source code <https://github.com/HOST-Oman/libraqm>`_ and the dependencies , run the customary sequence of commands in the source code
|
||||||
|
directory::
|
||||||
|
|
||||||
|
$ ./configure
|
||||||
|
$ make
|
||||||
|
$ make install
|
||||||
|
|
||||||
|
Now install Pillow with::
|
||||||
|
|
||||||
$ pip install Pillow
|
$ pip install Pillow
|
||||||
|
|
||||||
|
@ -277,7 +298,7 @@ Or for Python 3::
|
||||||
|
|
||||||
Prerequisites are installed on **FreeBSD 10 or 11** with::
|
Prerequisites are installed on **FreeBSD 10 or 11** with::
|
||||||
|
|
||||||
$ sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg
|
$ sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg harfbuzz fribidi
|
||||||
|
|
||||||
|
|
||||||
Building on Linux
|
Building on Linux
|
||||||
|
|
|
@ -240,12 +240,13 @@ Methods
|
||||||
the number of pixels between lines.
|
the number of pixels between lines.
|
||||||
:param align: If the text is passed on to multiline_text(),
|
:param align: If the text is passed on to multiline_text(),
|
||||||
"left", "center" or "right".
|
"left", "center" or "right".
|
||||||
:param direction: Direction of the text. It can be 'rtl', 'ltr', 'ttb' or 'btt'.
|
:param direction: Direction of the text. It can be 'rtl', 'ltr', 'ttb' or 'btt'. Requires libraqm
|
||||||
:param features: A list of font feature to be used during text layout.
|
:param features: A list of font feature to be used during text layout.
|
||||||
This is usually used to turn on optional font features that are not enabled by
|
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
|
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.
|
font features for example '-liga' to disable ligatures or '-kern' to disable kerning.
|
||||||
To get all supported features, see https://www.microsoft.com/typography/otspec/featurelist.htm
|
To get all supported features, see https://www.microsoft.com/typography/otspec/featurelist.htm
|
||||||
|
Requires libraqm.
|
||||||
|
|
||||||
.. py:method:: PIL.ImageDraw.Draw.multiline_text(xy, text, fill=None, font=None, anchor=None, spacing=0, align="left",
|
.. py:method:: PIL.ImageDraw.Draw.multiline_text(xy, text, fill=None, font=None, anchor=None, spacing=0, align="left",
|
||||||
direction=None, features=[])
|
direction=None, features=[])
|
||||||
|
@ -258,12 +259,13 @@ Methods
|
||||||
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
|
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
|
||||||
:param spacing: The number of pixels between lines.
|
:param spacing: The number of pixels between lines.
|
||||||
:param align: "left", "center" or "right".
|
:param align: "left", "center" or "right".
|
||||||
:param direction: Direction of the text. It can be 'rtl', 'ltr', 'ttb' or 'btt'.
|
:param direction: Direction of the text. It can be 'rtl', 'ltr', 'ttb' or 'btt'. Requires libraqm.
|
||||||
:param features: A list of font feature to be used during text layout.
|
:param features: A list of font feature to be used during text layout.
|
||||||
This is usually used to turn on optional font features that are not enabled by
|
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
|
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.
|
font features for example '-liga' to disable ligatures or '-kern' to disable kerning.
|
||||||
To get all supported features, see https://www.microsoft.com/typography/otspec/featurelist.htm
|
To get all supported features, see https://www.microsoft.com/typography/otspec/featurelist.htm
|
||||||
|
Requires libraqm.
|
||||||
|
|
||||||
.. py:method:: PIL.ImageDraw.Draw.textsize(text, font=None, spacing=0)
|
.. py:method:: PIL.ImageDraw.Draw.textsize(text, font=None, spacing=0)
|
||||||
|
|
||||||
|
|
|
@ -63,12 +63,13 @@ Methods
|
||||||
driver prefers; if empty, the renderer may return either
|
driver prefers; if empty, the renderer may return either
|
||||||
mode. Note that the mode is always a string, to simplify
|
mode. Note that the mode is always a string, to simplify
|
||||||
C-level implementations.
|
C-level implementations.
|
||||||
:param direction: Direction of the text. It can be 'rtl', 'ltr', 'ttb' or 'btt'.
|
:param direction: Direction of the text. It can be 'rtl', 'ltr', 'ttb' or 'btt'. Requires libraqm
|
||||||
:param features: A list of font feature to be used during text layout. This is
|
:param features: A list of font feature to be used during text layout. This is
|
||||||
usually used to turn on optional font features that are not enabled by default,
|
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
|
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.
|
features for example '-liga' to disable ligatures or '-kern' to disable kerning.
|
||||||
To get all supported features, see https://www.microsoft.com/typography/otspec/featurelist.htm
|
To get all supported features, see https://www.microsoft.com/typography/otspec/featurelist.htm
|
||||||
|
Requires libraqm
|
||||||
|
|
||||||
.. versionadded:: 1.1.5
|
.. versionadded:: 1.1.5
|
||||||
:return: An internal PIL storage memory instance as defined by the
|
:return: An internal PIL storage memory instance as defined by the
|
||||||
|
|
Loading…
Reference in New Issue
Block a user