Skip to content

Commit 932f94e

Browse files
committed
Fix non-latin languages processing when generating PDF files
1 parent 70ad1a6 commit 932f94e

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

youtubevideotranscriptbot/Dockerfile_template

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
1-
# This is Dockerfile
21
# Use an official Python runtime as a parent image
32
FROM python:3.10-slim
43

4+
# Install system dependencies for WeasyPrint and fonts
5+
RUN apt-get update && apt-get install -y \
6+
# WeasyPrint dependencies
7+
libpango-1.0-0 \
8+
libharfbuzz0b \
9+
libpangoft2-1.0-0 \
10+
libfontconfig1 \
11+
libcairo2 \
12+
libgdk-pixbuf2.0-0 \
13+
libgtk-3-0 \
14+
# Font packages for emoji support
15+
fonts-dejavu-core \
16+
fonts-dejavu-extra \
17+
fonts-noto-core \
18+
fonts-noto-cjk \
19+
fonts-noto-color-emoji \
20+
fonts-noto-extra \
21+
fonts-liberation \
22+
fontconfig \
23+
# Clean up
24+
&& apt-get clean \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Update font cache
28+
RUN fc-cache -fv
29+
530
# Set the working directory in the container
631
WORKDIR /app
732

@@ -28,4 +53,6 @@ RUN python3 -c "import config; import os; " \
2853
"print('Environment variables set from config.py')"
2954

3055
# Run the bot
31-
CMD ["python", "telegram_bot.py"]
56+
CMD ["python", "telegram_bot.py"]
57+
58+

youtubevideotranscriptbot/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ def create_emoji_friendly_pdf_with_weasyprint(html_content, output_filename=None
117117
}
118118
119119
body {
120-
font-family: "DejaVu Sans", sans-serif;
120+
font-family: "Noto Sans","DejaVu Sans", sans-serif;
121121
font-size: 12pt;
122122
line-height: 1.5;
123123
color: #333;
124124
}
125125
126126
h1, h2, h3 {
127-
font-family: "DejaVu Sans", sans-serif;
127+
font-family: "Noto Sans","DejaVu Sans", sans-serif;
128128
color: #222;
129129
}
130130

0 commit comments

Comments
 (0)