- Add NotoSansKR and NotoSansThai fonts for Korean and Thai language support - Update download_fonts.sh to download all required fonts - Add LANGUAGE_FONT_MAP for language-to-font mapping in pdf_generator_service.py - Add get_font_for_language() method to select appropriate font based on target language - Update _get_reflow_styles() to accept target_lang parameter - Pass target_lang through generate_translated_pdf() to PDF generation methods - Fix garbled characters (亂碼) issue for Korean and Thai translations Supported languages: - Chinese (zh-CN/zh-TW), Japanese (ja): NotoSansSC - Korean (ko): NotoSansKR - Thai (th): NotoSansThai - Russian, Vietnamese, Latin languages: NotoSansSC 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
1.7 KiB
Bash
Executable File
57 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# Download Noto Sans fonts for multilingual PDF generation
|
|
# Supports: CJK (Chinese, Japanese, Korean), Thai, Vietnamese, Russian, etc.
|
|
|
|
set -e
|
|
|
|
FONT_DIR="backend/fonts"
|
|
|
|
echo "🔤 Downloading fonts for multilingual PDF generation..."
|
|
|
|
# Create font directory
|
|
mkdir -p "$FONT_DIR"
|
|
|
|
# Function to download font
|
|
download_font() {
|
|
local url="$1"
|
|
local file="$2"
|
|
local desc="$3"
|
|
|
|
if [ -f "$FONT_DIR/$file" ]; then
|
|
echo "✓ $desc already exists"
|
|
else
|
|
echo "Downloading $desc..."
|
|
if wget -q "$url" -O "$FONT_DIR/$file"; then
|
|
SIZE=$(du -h "$FONT_DIR/$file" | cut -f1)
|
|
echo "✓ $desc downloaded: $SIZE"
|
|
else
|
|
echo "✗ Failed to download $desc"
|
|
return 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# NotoSansSC - Chinese (Simplified), also covers Japanese and basic CJK
|
|
download_font \
|
|
"https://github.com/notofonts/noto-cjk/raw/main/Sans/Variable/TTF/Subset/NotoSansSC-VF.ttf" \
|
|
"NotoSansSC-Regular.ttf" \
|
|
"Noto Sans SC (Chinese/Japanese)"
|
|
|
|
# NotoSansKR - Korean
|
|
download_font \
|
|
"https://github.com/notofonts/noto-cjk/raw/main/Sans/Variable/TTF/Subset/NotoSansKR-VF.ttf" \
|
|
"NotoSansKR-Regular.ttf" \
|
|
"Noto Sans KR (Korean)"
|
|
|
|
# NotoSansThai - Thai
|
|
download_font \
|
|
"https://github.com/notofonts/noto-fonts/raw/main/hinted/ttf/NotoSansThai/NotoSansThai-Regular.ttf" \
|
|
"NotoSansThai-Regular.ttf" \
|
|
"Noto Sans Thai"
|
|
|
|
echo ""
|
|
echo "✅ Font setup complete!"
|
|
echo "Supported languages: Chinese (zh-CN/zh-TW), Japanese (ja), Korean (ko),"
|
|
echo " Thai (th), Russian (ru), Vietnamese (vi),"
|
|
echo " and all Latin-based languages (en, de, fr, es, etc.)"
|