fix: card creation fix

This commit is contained in:
2025-05-12 17:56:25 +04:00
parent 4f08019d85
commit 329616bcd3
6 changed files with 62 additions and 18 deletions

View File

@@ -15,10 +15,15 @@ class BasePdfCardGenerator:
self._session = session
assets_folder = os.path.join(APP_PATH, 'assets')
fonts_folder = os.path.join(assets_folder, 'fonts')
font_file_path = os.path.join(fonts_folder, 'DejaVuSans.ttf')
dejavu_font_file_path = os.path.join(fonts_folder, 'DejaVuSans.ttf')
pdfmetrics.registerFont(TTFont('DejaVuSans', dejavu_font_file_path))
arial_font_file_path = os.path.join(fonts_folder, 'Arial Nova Cond.ttf')
pdfmetrics.registerFont(TTFont('Arial Nova Cond', arial_font_file_path))
self.page_width = 58 * mm
self.page_height = 40 * mm
pdfmetrics.registerFont(TTFont('DejaVuSans', font_file_path))
self.styles = getSampleStyleSheet()
self._set_small_paragraph_styles()
@@ -64,11 +69,9 @@ class BasePdfCardGenerator:
bottomMargin=1
)
def _get_paragraph_style(self, font_size: int):
def _get_paragraph_style(self, font_size: int, font_name: str = "Arial Nova Cond"):
common_paragraph_style = {
"parent": self.styles['Normal'],
"fontName": "DejaVuSans",
"spaceAfter": 4,
"fontName": font_name,
"fontSize": font_size,
}
return ParagraphStyle(