Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reformatting #13

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/styles/underline_core.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from wizard import *
from textual.validation import *

from wizard import TextQuestion, SelectQuestion
from textual.validation import Number
from utils import font_list, color_scheme_names, FONTS_DIR, color_schemes, os, get_font_height, get_text_size
from PIL import Image, ImageDraw, ImageFont, ImageColor

import sys

sys.path.append("..")

from utils import *

questions = [
SelectQuestion("font", "Select a font", [(font, font) for font in font_list], "Iosevka-Nerd-Font-Complete.ttf"),
Expand All @@ -20,10 +19,11 @@

active = False


def get_image(answers, type):
if not type in ['all', 'first_letter']:
if type not in ['all', 'first_letter']:
raise ValueError("Invalid type")

# Load the selected font
font_size = 500
font = ImageFont.truetype(os.path.join(FONTS_DIR, answers["font"]), font_size)
Expand Down Expand Up @@ -63,8 +63,13 @@ def get_image(answers, type):

# The end of the underline depends on the type
# If the type is 'all', the underline will go from the start of the first letter to the end of the text
# If the type is 'first_letter', the underline will go from the start of the first letter to the end of the first letter
underline_end_x = int(answers['additionnal_bar_width']) + (first_letter_bbox[2] if type == 'first_letter' else int(answers['padding_x']) + text_width)
# If the type is 'first_letter', the underline will go
# from the start of the first letter to the end of the first letter
if type == 'first_letter':
underline_end_x = int(answers['additionnal_bar_width']) + (first_letter_bbox[2])
else:
underline_end_x = int(int(answers['padding_x']) + text_width)

underline_end_y = underline_start_y + int(answers['bar_size'])

underline_start = (underline_start_x, underline_start_y)
Expand All @@ -75,7 +80,6 @@ def get_image(answers, type):
# Underline the first letter
draw.rectangle(underline_pos, fill=accent, width=answers['bar_size'])


# Draw the text
draw.text(
anchor_pos,
Expand All @@ -93,5 +97,5 @@ def get_image(answers, type):
fill=accent,
anchor=anchor_type,
)

return image