Skip to content

Commit

Permalink
Added title fonts to package, changed default to open-source Montserrat
Browse files Browse the repository at this point in the history
  • Loading branch information
beveradb committed Dec 21, 2023
1 parent 90297bd commit fe6b89b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
22 changes: 12 additions & 10 deletions karaoke_prep/karaoke_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import lyricsgenius
import tempfile
import importlib.resources as pkg_resources
from PIL import Image, ImageDraw, ImageFont


Expand All @@ -28,7 +29,7 @@ def __init__(
create_track_subfolders=False,
intro_background_color="#000000",
intro_background_image=None,
intro_font="AvenirNext-Bold.ttf",
intro_font="Montserrat-Bold.ttf",
intro_artist_color="#ffffff",
intro_title_color="#ff7acc",
):
Expand Down Expand Up @@ -71,8 +72,7 @@ def __init__(
self.title_format = {
"background_color": intro_background_color,
"background_image": intro_background_image,
"artist_font": intro_font,
"title_font": intro_font,
"intro_font": intro_font,
"artist_color": intro_artist_color,
"title_color": intro_title_color,
}
Expand Down Expand Up @@ -400,13 +400,15 @@ def create_title_video(self, artist, title, format, output_image_filepath, outpu

draw = ImageDraw.Draw(background)

# Calculate positions and sizes for title and artist
title_font, _ = self.calculate_text_size_and_position(
draw, title, format["title_font"], initial_font_size, resolution, title_padding
)
artist_font, _ = self.calculate_text_size_and_position(
draw, artist, format["artist_font"], initial_font_size, resolution, artist_padding
)
# Accessing the font file from the package resources
with pkg_resources.path('karaoke_prep.resources', format['intro_font']) as font_path:
# Calculate positions and sizes for title and artist
title_font, _ = self.calculate_text_size_and_position(
draw, title, str(font_path), initial_font_size, resolution, title_padding
)
artist_font, _ = self.calculate_text_size_and_position(
draw, artist, str(font_path), initial_font_size, resolution, artist_padding
)

# Calculate vertical positions with consistent gap
title_text_position, title_height = self.calculate_text_position(draw, title, title_font, resolution, top_padding)
Expand Down
File renamed without changes.
Binary file added karaoke_prep/resources/Montserrat-Bold.ttf
Binary file not shown.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "karaoke-prep"
version = "0.7.1"
version = "0.8.0"
description = "Prepare for karaoke video creation, by downloading audio and lyrics for a specified song or youtube playlist and separatung audio stems, then finalise the video with a title screen after manual syncing!"
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
license = "MIT"
Expand All @@ -9,6 +9,7 @@ packages = [{include = "karaoke_prep"}]
homepage = "https://github.com/karaokenerds/karaoke-prep"
repository = "https://github.com/karaokenerds/karaoke-prep"
documentation = "https://github.com/karaokenerds/karaoke-prep/blob/main/README.md"
include = ["resources"]

[tool.poetry.dependencies]
python = ">=3.9"
Expand Down
4 changes: 2 additions & 2 deletions utils/prep_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def main():

parser.add_argument(
"--intro_font",
default="AvenirNext-Bold.ttf",
help="Optional: Font file for intro video (default: Avenir-Next-Bold). Example: --intro_font=AvenirNext-Bold.ttf",
default="Montserrat-Bold.ttf",
help="Optional: Font file for intro video (default: Montserrat-Bold.ttf). Example: --intro_font=AvenirNext-Bold.ttf",
)

parser.add_argument(
Expand Down

0 comments on commit fe6b89b

Please sign in to comment.