Исправлена кодировка кириллицы в PDF (шрифт DejaVuSans)
This commit is contained in:
1 parent
f13e91be8c
commit
dfbdc05516
3 files changed
+461
-82
No files matched your search
+22
-7
@@ -184,36 +184,51 @@ def build_docx():
|
||||
|
||||
|
||||
def build_pdf():
|
||||
# Register Cyrillic-capable fonts (Helvetica does not support Cyrillic)
|
||||
from reportlab.pdfbase import pdfmetrics
|
||||
from reportlab.pdfbase.ttfonts import TTFont
|
||||
pdfmetrics.registerFont(TTFont("DejaVuSans", r"C:\Windows\Fonts\DejaVuSans.ttf"))
|
||||
pdfmetrics.registerFont(TTFont("DejaVuSans-Bold", r"C:\Windows\Fonts\DejaVuSans-Bold.ttf"))
|
||||
pdfmetrics.registerFont(TTFont("DejaVuSans-Oblique", r"C:\Windows\Fonts\DejaVuSans-Oblique.ttf"))
|
||||
pdfmetrics.registerFont(TTFont("DejaVuSans-BoldOblique", r"C:\Windows\Fonts\DejaVuSans-BoldOblique.ttf"))
|
||||
pdfmetrics.registerFontFamily(
|
||||
"DejaVuSans",
|
||||
normal="DejaVuSans",
|
||||
bold="DejaVuSans-Bold",
|
||||
italic="DejaVuSans-Oblique",
|
||||
boldItalic="DejaVuSans-BoldOblique",
|
||||
)
|
||||
|
||||
styles = getSampleStyleSheet()
|
||||
|
||||
title_style = ParagraphStyle(
|
||||
"TitleRU", parent=styles["Title"], fontName="Helvetica-Bold",
|
||||
"TitleRU", parent=styles["Title"], fontName="DejaVuSans-Bold",
|
||||
fontSize=22, leading=26, textColor=ACCENT_HEX, alignment=TA_CENTER, spaceAfter=4,
|
||||
)
|
||||
pos_style = ParagraphStyle(
|
||||
"PosRU", parent=styles["Normal"], fontName="Helvetica-Bold",
|
||||
"PosRU", parent=styles["Normal"], fontName="DejaVuSans-Bold",
|
||||
fontSize=13, leading=16, textColor=ACCENT_HEX, alignment=TA_CENTER, spaceAfter=14,
|
||||
)
|
||||
heading_style = ParagraphStyle(
|
||||
"HeadingRU", parent=styles["Heading1"], fontName="Helvetica-Bold",
|
||||
"HeadingRU", parent=styles["Heading1"], fontName="DejaVuSans-Bold",
|
||||
fontSize=14, leading=18, textColor=ACCENT_HEX, spaceBefore=12, spaceAfter=4,
|
||||
)
|
||||
body_style = ParagraphStyle(
|
||||
"BodyRU", parent=styles["Normal"], fontName="Helvetica",
|
||||
"BodyRU", parent=styles["Normal"], fontName="DejaVuSans",
|
||||
fontSize=11, leading=15, spaceAfter=4,
|
||||
)
|
||||
bullet_style = ParagraphStyle(
|
||||
"BulletRU", parent=body_style, leftIndent=14, bulletIndent=4, spaceAfter=2,
|
||||
)
|
||||
job_style = ParagraphStyle(
|
||||
"JobRU", parent=body_style, fontName="Helvetica-Bold", fontSize=12, leading=15, spaceBefore=6,
|
||||
"JobRU", parent=body_style, fontName="DejaVuSans-Bold", fontSize=12, leading=15, spaceBefore=6,
|
||||
)
|
||||
period_style = ParagraphStyle(
|
||||
"PeriodRU", parent=body_style, fontName="Helvetica-Oblique",
|
||||
"PeriodRU", parent=body_style, fontName="DejaVuSans-Oblique",
|
||||
fontSize=10, leading=13, textColor="#606060",
|
||||
)
|
||||
link_style = ParagraphStyle(
|
||||
"LinkRU", parent=body_style, fontName="Helvetica", fontSize=10, leading=13,
|
||||
"LinkRU", parent=body_style, fontName="DejaVuSans", fontSize=10, leading=13,
|
||||
textColor="#0563C1",
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user