mirror of
https://github.com/ralsina/tapita.git
synced 2025-06-07 12:10:24 -03:00
Refactor font
This commit is contained in:
parent
ef6135ffdc
commit
c20c5915ef
@ -3,6 +3,7 @@ import urllib
|
|||||||
import urllib.parse
|
import urllib.parse
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from PIL import Image, ImageColor, ImageDraw, ImageFont
|
from PIL import Image, ImageColor, ImageDraw, ImageFont
|
||||||
|
|
||||||
@ -47,6 +48,9 @@ class Cover:
|
|||||||
(0, 0, self.cover_width, self.cover_height), fill=self.background
|
(0, 0, self.cover_width, self.cover_height), fill=self.background
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _getFont(self, size):
|
||||||
|
return ImageFont.truetype(str(Path(__file__).parent / "HackNerdFont-Regular.ttf"), int(size))
|
||||||
|
|
||||||
def _drawArtwork(self):
|
def _drawArtwork(self):
|
||||||
artwork_start_x = 0
|
artwork_start_x = 0
|
||||||
artwork_start_y = self.cover_height - self.cover_width
|
artwork_start_y = self.cover_height - self.cover_width
|
||||||
@ -62,15 +66,9 @@ class Cover:
|
|||||||
|
|
||||||
# Allocate fonts for the title and the author, and draw the text.
|
# Allocate fonts for the title and the author, and draw the text.
|
||||||
def _drawText(self):
|
def _drawText(self):
|
||||||
title_font_size = int(self.cover_width * 0.08)
|
title_font = self._getFont(self.cover_width * 0.08)
|
||||||
subtitle_font_size = int(self.cover_width * 0.05)
|
subtitle_font = self._getFont(self.cover_width * 0.05)
|
||||||
author_font_size = int(self.cover_width * 0.06)
|
author_font = self._getFont(self.cover_width * 0.06)
|
||||||
|
|
||||||
title_font = ImageFont.truetype("HackNerdFont-Regular.ttf", title_font_size)
|
|
||||||
subtitle_font = ImageFont.truetype(
|
|
||||||
"HackNerdFont-Regular.ttf", subtitle_font_size
|
|
||||||
)
|
|
||||||
author_font = ImageFont.truetype("HackNerdFont-Regular.ttf", author_font_size)
|
|
||||||
|
|
||||||
# Just a fancy way to say "near the top"
|
# Just a fancy way to say "near the top"
|
||||||
title_height = (
|
title_height = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user