mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Add font Inter-Regular.ttf to installed assets (#4775)
## What type of PR is this? (check all applicable) - [X] Bug Fix ## Have you discussed this change with the InvokeAI team? - [X] Yes ## Have you updated all relevant documentation? - [ ] Yes - [X] No ## Description This PR causes the font "Inter-Regular.ttf", which is needed by the facetools Face Identifier node, to be installed along with other assets in the virtual environment. It also fixes the font path resolution logic in the invocation to work with both package and editable installs. ## Related Tickets & Documents Closes #4771
This commit is contained in:
commit
4bda7d7df5
@ -1,5 +1,4 @@
|
|||||||
import math
|
import math
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, TypedDict
|
from typing import Optional, TypedDict
|
||||||
@ -11,6 +10,7 @@ from PIL import Image, ImageDraw, ImageFilter, ImageFont, ImageOps
|
|||||||
from PIL.Image import Image as ImageType
|
from PIL.Image import Image as ImageType
|
||||||
from pydantic import validator
|
from pydantic import validator
|
||||||
|
|
||||||
|
import invokeai.assets.fonts as font_assets
|
||||||
from invokeai.app.invocations.baseinvocation import (
|
from invokeai.app.invocations.baseinvocation import (
|
||||||
BaseInvocation,
|
BaseInvocation,
|
||||||
InputField,
|
InputField,
|
||||||
@ -641,9 +641,9 @@ class FaceIdentifierInvocation(BaseInvocation):
|
|||||||
draw_mesh=False,
|
draw_mesh=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
path = Path(__file__).resolve().parent.parent.parent
|
# 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 = os.path.abspath(path / "assets/fonts/inter/Inter-Regular.ttf")
|
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, FONT_SIZE)
|
font = ImageFont.truetype(font_path[0].as_posix(), FONT_SIZE)
|
||||||
|
|
||||||
# Paste face IDs on the output image
|
# Paste face IDs on the output image
|
||||||
draw = ImageDraw.Draw(image)
|
draw = ImageDraw.Draw(image)
|
||||||
|
@ -161,16 +161,16 @@ version = { attr = "invokeai.version.__version__" }
|
|||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
"where" = ["."]
|
"where" = ["."]
|
||||||
"include" = [
|
"include" = [
|
||||||
"invokeai.assets.web*","invokeai.version*",
|
"invokeai.assets.fonts*","invokeai.version*",
|
||||||
"invokeai.generator*","invokeai.backend*",
|
"invokeai.generator*","invokeai.backend*",
|
||||||
"invokeai.frontend*", "invokeai.frontend.web.dist*",
|
"invokeai.frontend*", "invokeai.frontend.web.dist*",
|
||||||
"invokeai.frontend.web.static*",
|
"invokeai.frontend.web.static*",
|
||||||
"invokeai.configs*",
|
"invokeai.configs*",
|
||||||
"invokeai.app*","ldm*",
|
"invokeai.app*",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools.package-data]
|
[tool.setuptools.package-data]
|
||||||
"invokeai.assets.web" = ["**.png","**.js","**.woff2","**.css"]
|
"invokeai.assets.fonts" = ["**/*.ttf"]
|
||||||
"invokeai.backend" = ["**.png"]
|
"invokeai.backend" = ["**.png"]
|
||||||
"invokeai.configs" = ["*.example", "**/*.yaml", "*.txt"]
|
"invokeai.configs" = ["*.example", "**/*.yaml", "*.txt"]
|
||||||
"invokeai.frontend.web.dist" = ["**"]
|
"invokeai.frontend.web.dist" = ["**"]
|
||||||
|
Loading…
Reference in New Issue
Block a user