Skip to content

Commit

Permalink
drop write_to method
Browse files Browse the repository at this point in the history
  • Loading branch information
fcurella committed Aug 21, 2023
1 parent 1467746 commit 1a0a421
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ with open("fonts/MyFont.ttf") as fh:
- [`subset`](#subset)
- [`to_sliced_variable`](#to_sliced_variable)
- [`to_static`](#to_static)
- [`write_to`](#write_to)

#### `clone`
```python
Expand Down Expand Up @@ -697,15 +696,6 @@ If coordinates are not specified each axis will be pinned at its default value.
"""
font.to_static(coordinates=None, **options)
```
#### `write_to`
```python
"""
Writes the font to a file-like object.
:param fileobject: A file-like object to write to.
"""
font.write_to(fh)
```

## Testing
```bash
Expand Down
12 changes: 2 additions & 10 deletions fontbro/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,15 +1096,6 @@ def save_as_woff2(self, filepath=None, overwrite=True):
flavor=self.FORMAT_WOFF2, filepath=filepath, overwrite=overwrite
)

def write_to(self, fileobject):
"""
Writes the font to a file-like object.
:param fileobject: A file-like object to write to.
"""
font = self.get_ttfont()
font.save(fileobject)

def save_to_fileobject(self, fileobject=None):
"""
Writes the font to a file-like object. If no file-object is passed, an
Expand All @@ -1115,9 +1106,10 @@ def save_to_fileobject(self, fileobject=None):
instance.
:rtype: typing.io.IO
"""
font = self.get_ttfont()
if fileobject is None:
fileobject = BytesIO()
self.write_to(fileobject)
font.save(fileobject)
return fileobject

def set_name(self, key, value):
Expand Down
9 changes: 0 additions & 9 deletions tests/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ def test_save_fileobject_error(self):
with self.assertRaises(ValueError):
font.save()

def test_write_to(self):
font = self._get_font("/Roboto_Mono/static/RobotoMono-Regular.ttf")
buf = BytesIO()
font.write_to(buf)
buf.seek(0)
content = buf.read()
# 00 01 00 00 00 is the file signature for TrueType fonts
self.assertEqual(content[:5], b"\x00\x01\x00\x00\x00")

def test_save_to_fileobject(self):
font = self._get_font("/Roboto_Mono/static/RobotoMono-Regular.ttf")
buf = BytesIO()
Expand Down

0 comments on commit 1a0a421

Please sign in to comment.