From 4ce00a32f4a8a11ac942e5b031d71b1dd584d461 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 3 Oct 2023 08:48:50 -0400 Subject: [PATCH] add font Inter-Regular.ttf to installed assets --- invokeai/app/invocations/facetools.py | 7 ++++--- pyproject.toml | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/invokeai/app/invocations/facetools.py b/invokeai/app/invocations/facetools.py index f02e4d476a..53b4602a5b 100644 --- a/invokeai/app/invocations/facetools.py +++ b/invokeai/app/invocations/facetools.py @@ -11,6 +11,7 @@ from PIL import Image, ImageDraw, ImageFilter, ImageFont, ImageOps from PIL.Image import Image as ImageType from pydantic import validator +import invokeai.assets.fonts as font_assets from invokeai.app.invocations.baseinvocation import ( BaseInvocation, InputField, @@ -641,9 +642,9 @@ class FaceIdentifierInvocation(BaseInvocation): draw_mesh=False, ) - path = Path(__file__).resolve().parent.parent.parent - font_path = os.path.abspath(path / "assets/fonts/inter/Inter-Regular.ttf") - font = ImageFont.truetype(font_path, FONT_SIZE) + # Note - font may be found either in the repo if running an editable install, or in the venv if running a package install + font_path = [x for x in [Path(y, "inter/Inter-Regular.ttf") for y in font_assets.__path__] if x.exists()] + font = ImageFont.truetype(font_path[0].as_posix(), FONT_SIZE) # Paste face IDs on the output image draw = ImageDraw.Draw(image) diff --git a/pyproject.toml b/pyproject.toml index 21cda5eebd..da9dccd71d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -161,16 +161,16 @@ version = { attr = "invokeai.version.__version__" } [tool.setuptools.packages.find] "where" = ["."] "include" = [ - "invokeai.assets.web*","invokeai.version*", + "invokeai.assets.fonts*","invokeai.version*", "invokeai.generator*","invokeai.backend*", "invokeai.frontend*", "invokeai.frontend.web.dist*", "invokeai.frontend.web.static*", "invokeai.configs*", - "invokeai.app*","ldm*", + "invokeai.app*", ] [tool.setuptools.package-data] -"invokeai.assets.web" = ["**.png","**.js","**.woff2","**.css"] +"invokeai.assets.fonts" = ["**/*.ttf"] "invokeai.backend" = ["**.png"] "invokeai.configs" = ["*.example", "**/*.yaml", "*.txt"] "invokeai.frontend.web.dist" = ["**"]