mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
update
This commit is contained in:
parent
fd7a675de6
commit
e07a254ed9
|
@ -202,9 +202,11 @@ class ImageDraw(object):
|
|||
|
||||
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):
|
||||
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)
|
||||
if font is None:
|
||||
font = self.getfont()
|
||||
|
|
|
@ -5,7 +5,6 @@ modules = {
|
|||
"tkinter": "PIL._tkinter_finder",
|
||||
"freetype2": "PIL._imagingft",
|
||||
"littlecms2": "PIL._imagingcms",
|
||||
"raqm": "PIL._imagingft",
|
||||
"webp": "PIL._webp",
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from helper import unittest, PillowTestCase
|
||||
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_PATH = "Tests/fonts/DejaVuSans.ttf"
|
||||
|
||||
try:
|
||||
from PIL import ImageFont
|
||||
|
||||
# check if raqm is available
|
||||
|
||||
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
im = Image.new(mode='RGB', size=(300, 100))
|
||||
draw = ImageDraw.Draw(im)
|
||||
draw.text((0, 0), 'TEST', font=ttf, fill=500, direction='ltr')
|
||||
|
||||
@unittest.skipIf(not have_raqm, "Raqm Library is not installed !")
|
||||
class TestImagecomplextext(PillowTestCase):
|
||||
|
||||
def test_complex_text(self):
|
||||
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
|
||||
|
|
16
_imagingft.c
16
_imagingft.c
|
@ -43,14 +43,6 @@
|
|||
#define FT_ERROR_END_LIST { 0, 0 } };
|
||||
#ifdef HAVE_RAQM
|
||||
#include <raqm.h>
|
||||
#else
|
||||
typedef enum
|
||||
{
|
||||
RAQM_DIRECTION_DEFAULT,
|
||||
RAQM_DIRECTION_RTL,
|
||||
RAQM_DIRECTION_LTR,
|
||||
RAQM_DIRECTION_TTB
|
||||
} raqm_direction_t;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
|
@ -830,6 +822,14 @@ setup_module(PyObject* m) {
|
|||
#endif
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,16 @@ Many of Pillow's features require external libraries:
|
|||
* Windows support: Libimagequant requires VS2013/MSVC 18 to compile,
|
||||
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::
|
||||
|
||||
$ pip install Pillow
|
||||
|
@ -201,14 +211,16 @@ Build Options
|
|||
* Build flags: ``--disable-zlib``, ``--disable-jpeg``,
|
||||
``--disable-tiff``, ``--disable-freetype``, ``--disable-tcl``,
|
||||
``--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
|
||||
libraries are present on the building machine.
|
||||
|
||||
* Build flags: ``--enable-zlib``, ``--enable-jpeg``,
|
||||
``--enable-tiff``, ``--enable-freetype``, ``--enable-tcl``,
|
||||
``--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
|
||||
an exception if the libraries are not found. Webpmux (WebP metadata)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
@ -277,7 +298,7 @@ Or for Python 3::
|
|||
|
||||
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
|
||||
|
|
|
@ -240,12 +240,13 @@ Methods
|
|||
the number of pixels between lines.
|
||||
:param align: If the text is passed on to multiline_text(),
|
||||
"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.
|
||||
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 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",
|
||||
direction=None, features=[])
|
||||
|
@ -258,12 +259,13 @@ Methods
|
|||
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
|
||||
:param spacing: The number of pixels between lines.
|
||||
: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.
|
||||
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 https://www.microsoft.com/typography/otspec/featurelist.htm
|
||||
Requires libraqm.
|
||||
|
||||
.. 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
|
||||
mode. Note that the mode is always a string, to simplify
|
||||
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
|
||||
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 https://www.microsoft.com/typography/otspec/featurelist.htm
|
||||
Requires libraqm
|
||||
|
||||
.. versionadded:: 1.1.5
|
||||
:return: An internal PIL storage memory instance as defined by the
|
||||
|
|
Loading…
Reference in New Issue
Block a user