mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-03 11:35:52 +03:00
Handle pathlib.Path in FreeTypeFont
This commit is contained in:
parent
f9c7bd8611
commit
ae7958fa8d
|
@ -4,6 +4,7 @@ import re
|
|||
import shutil
|
||||
import sys
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from packaging.version import parse as parse_version
|
||||
|
@ -76,8 +77,9 @@ def _render(font, layout_engine):
|
|||
return img
|
||||
|
||||
|
||||
def test_font_with_name(layout_engine):
|
||||
_render(FONT_PATH, layout_engine)
|
||||
@pytest.mark.parametrize("font", (FONT_PATH, Path(FONT_PATH)))
|
||||
def test_font_with_name(layout_engine, font):
|
||||
_render(font, layout_engine)
|
||||
|
||||
|
||||
def test_font_with_filelike(layout_engine):
|
||||
|
|
|
@ -31,6 +31,7 @@ import sys
|
|||
import warnings
|
||||
from enum import IntEnum
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
|
||||
from . import Image
|
||||
from ._util import is_directory, is_path
|
||||
|
@ -213,6 +214,8 @@ class FreeTypeFont:
|
|||
)
|
||||
|
||||
if is_path(font):
|
||||
if isinstance(font, Path):
|
||||
font = str(font)
|
||||
if sys.platform == "win32":
|
||||
font_bytes_path = font if isinstance(font, bytes) else font.encode()
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user