mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
If font is file-like object, do not re-read from object to get variant
This commit is contained in:
parent
de1ba373e1
commit
a40c7a6bea
|
@ -65,9 +65,12 @@ class TestImageFont:
|
|||
return font_bytes
|
||||
|
||||
def test_font_with_filelike(self):
|
||||
ImageFont.truetype(
|
||||
ttf = ImageFont.truetype(
|
||||
self._font_as_bytes(), FONT_SIZE, layout_engine=self.LAYOUT_ENGINE
|
||||
)
|
||||
ttf_copy = ttf.font_variant()
|
||||
assert ttf_copy.font_bytes == ttf.font_bytes
|
||||
|
||||
self._render(self._font_as_bytes())
|
||||
# Usage note: making two fonts from the same buffer fails.
|
||||
# shared_bytes = self._font_as_bytes()
|
||||
|
|
|
@ -711,8 +711,13 @@ class FreeTypeFont:
|
|||
|
||||
:return: A FreeTypeFont object.
|
||||
"""
|
||||
if font is None:
|
||||
try:
|
||||
font = BytesIO(self.font_bytes)
|
||||
except AttributeError:
|
||||
font = self.path
|
||||
return FreeTypeFont(
|
||||
font=self.path if font is None else font,
|
||||
font=font,
|
||||
size=self.size if size is None else size,
|
||||
index=self.index if index is None else index,
|
||||
encoding=self.encoding if encoding is None else encoding,
|
||||
|
|
Loading…
Reference in New Issue
Block a user