-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(agrf) Manage
resources/
directory with pkgutils as well
- Loading branch information
Showing
4 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import io | ||
import pkgutil | ||
from PIL import Image | ||
from PIL import Image, ImageFont | ||
|
||
|
||
def load_third_party_image(path): | ||
content = pkgutil.get_data("agrf", path) | ||
f = io.BytesIO(content) | ||
return Image.open(f) | ||
|
||
|
||
def load_font(path, size): | ||
content = pkgutil.get_data("agrf", path) | ||
f = io.BytesIO(content) | ||
return ImageFont.truetype(f, size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from . import load_font | ||
|
||
|
||
def test_font(): | ||
assert load_font("resources/AntaeusConsoleNumbers.otf", 12) is not None |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters