Upload 49 files
Browse files- DEPLOYMENT_GUIDE.md +14 -8
- Dockerfile +2 -7
- setup_fonts.py +74 -36
- test_font_setup.py +52 -0
DEPLOYMENT_GUIDE.md
CHANGED
|
@@ -62,7 +62,7 @@ python test_conversion.py
|
|
| 62 |
|
| 63 |
### 2. اختبار الخطوط العربية:
|
| 64 |
```bash
|
| 65 |
-
fc-list | grep -i "amiri\|noto.*arabic"
|
| 66 |
```
|
| 67 |
|
| 68 |
### 3. اختبار LibreOffice:
|
|
@@ -86,7 +86,7 @@ sudo apt-get install libreoffice libreoffice-writer libreoffice-java-common
|
|
| 86 |
### مشكلة: الخطوط العربية مفقودة
|
| 87 |
**الحل:**
|
| 88 |
```bash
|
| 89 |
-
# تثبيت خطوط إضافية يتم تنزيلها عبر
|
| 90 |
# تحديث cache
|
| 91 |
sudo fc-cache -fv
|
| 92 |
|
|
@@ -143,10 +143,16 @@ tail -f /var/log/syslog
|
|
| 143 |
- راقب استخدام الموارد
|
| 144 |
- احتفظ بنسخ احتياطية من الإعدادات
|
| 145 |
|
| 146 |
-
##
|
| 147 |
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
### 2. اختبار الخطوط العربية:
|
| 64 |
```bash
|
| 65 |
+
fc-list | grep -i "amiri\|scheherazade\|noto.*arabic\|arial"
|
| 66 |
```
|
| 67 |
|
| 68 |
### 3. اختبار LibreOffice:
|
|
|
|
| 86 |
### مشكلة: الخطوط العربية مفقودة
|
| 87 |
**الحل:**
|
| 88 |
```bash
|
| 89 |
+
# تثبيت خطوط إضافية يتم تنزيلها عبر setup_fonts.py
|
| 90 |
# تحديث cache
|
| 91 |
sudo fc-cache -fv
|
| 92 |
|
|
|
|
| 143 |
- راقب استخدام الموارد
|
| 144 |
- احتفظ بنسخ احتياطية من الإعدادات
|
| 145 |
|
| 146 |
+
## 🔄 التحديثات
|
| 147 |
|
| 148 |
+
### تحديث الخطوط:
|
| 149 |
+
لتحديث الخطوط العربية، قم بتشغيل:
|
| 150 |
+
```bash
|
| 151 |
+
python setup_fonts.py
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
### تحديث التبعيات:
|
| 155 |
+
لتحديث التبعيات، قم بتعديل requirements.txt ثم:
|
| 156 |
+
```bash
|
| 157 |
+
pip install -r requirements.txt --upgrade
|
| 158 |
+
```
|
Dockerfile
CHANGED
|
@@ -60,13 +60,8 @@ RUN mkdir -p static
|
|
| 60 |
# Copy all remaining files
|
| 61 |
COPY . .
|
| 62 |
|
| 63 |
-
# Setup additional Arabic fonts
|
| 64 |
-
RUN
|
| 65 |
-
chmod +x arabic_fonts_setup.sh && \
|
| 66 |
-
./arabic_fonts_setup.sh; \
|
| 67 |
-
else \
|
| 68 |
-
echo "arabic_fonts_setup.sh not found, skipping font setup"; \
|
| 69 |
-
fi
|
| 70 |
|
| 71 |
# Pre-initialize LibreOffice to avoid first-run errors
|
| 72 |
RUN libreoffice --headless --version || true
|
|
|
|
| 60 |
# Copy all remaining files
|
| 61 |
COPY . .
|
| 62 |
|
| 63 |
+
# Setup additional Arabic fonts using Python script instead of shell script
|
| 64 |
+
RUN python3 setup_fonts.py || echo "Font setup failed, continuing with default fonts..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# Pre-initialize LibreOffice to avoid first-run errors
|
| 67 |
RUN libreoffice --headless --version || true
|
setup_fonts.py
CHANGED
|
@@ -25,6 +25,7 @@ def download_and_extract(url, extract_to):
|
|
| 25 |
"""Download a zip file and extract it"""
|
| 26 |
try:
|
| 27 |
with tempfile.NamedTemporaryFile(suffix='.zip', delete=False) as tmp_file:
|
|
|
|
| 28 |
urllib.request.urlretrieve(url, tmp_file.name)
|
| 29 |
|
| 30 |
with zipfile.ZipFile(tmp_file.name, 'r') as zip_ref:
|
|
@@ -44,56 +45,93 @@ def setup_arabic_fonts():
|
|
| 44 |
fonts_dir = "/usr/share/fonts/truetype/arabic-enhanced"
|
| 45 |
os.makedirs(fonts_dir, exist_ok=True)
|
| 46 |
|
| 47 |
-
#
|
| 48 |
print("📥 Installing Amiri font...")
|
|
|
|
| 49 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
else:
|
| 62 |
-
print("❌
|
| 63 |
-
|
| 64 |
-
print("❌
|
| 65 |
|
| 66 |
-
#
|
| 67 |
print("📥 Installing Scheherazade New font...")
|
|
|
|
| 68 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
else:
|
| 81 |
-
print("❌ Scheherazade New font
|
| 82 |
-
|
| 83 |
-
print("❌
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
# Update font cache
|
| 86 |
print("🔄 Updating font cache...")
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
# Verify installation
|
| 90 |
print("✅ Verifying Arabic fonts installation...")
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
print("🎯 Arabic fonts setup completed!")
|
| 97 |
|
| 98 |
if __name__ == "__main__":
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
"""Download a zip file and extract it"""
|
| 26 |
try:
|
| 27 |
with tempfile.NamedTemporaryFile(suffix='.zip', delete=False) as tmp_file:
|
| 28 |
+
print(f"Downloading {url}...")
|
| 29 |
urllib.request.urlretrieve(url, tmp_file.name)
|
| 30 |
|
| 31 |
with zipfile.ZipFile(tmp_file.name, 'r') as zip_ref:
|
|
|
|
| 45 |
fonts_dir = "/usr/share/fonts/truetype/arabic-enhanced"
|
| 46 |
os.makedirs(fonts_dir, exist_ok=True)
|
| 47 |
|
| 48 |
+
# Try to download and install Amiri font
|
| 49 |
print("📥 Installing Amiri font...")
|
| 50 |
+
amiri_installed = False
|
| 51 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 52 |
+
try:
|
| 53 |
+
amiri_url = "https://github.com/aliftype/amiri/releases/download/0.117/Amiri-0.117.zip"
|
| 54 |
+
if download_and_extract(amiri_url, tmp_dir):
|
| 55 |
+
amiri_dir = os.path.join(tmp_dir, "Amiri-0.117")
|
| 56 |
+
if os.path.exists(amiri_dir):
|
| 57 |
+
for file in os.listdir(amiri_dir):
|
| 58 |
+
if file.endswith('.ttf'):
|
| 59 |
+
src = os.path.join(amiri_dir, file)
|
| 60 |
+
dst = os.path.join(fonts_dir, file)
|
| 61 |
+
shutil.copy2(src, dst)
|
| 62 |
+
os.chmod(dst, 0o644)
|
| 63 |
+
print("✅ Amiri font installed successfully")
|
| 64 |
+
amiri_installed = True
|
| 65 |
+
else:
|
| 66 |
+
print("❌ Amiri font directory not found")
|
| 67 |
else:
|
| 68 |
+
print("❌ Failed to download Amiri font")
|
| 69 |
+
except Exception as e:
|
| 70 |
+
print(f"❌ Error installing Amiri font: {e}")
|
| 71 |
|
| 72 |
+
# Try to download and install Scheherazade New font
|
| 73 |
print("📥 Installing Scheherazade New font...")
|
| 74 |
+
scheherazade_installed = False
|
| 75 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 76 |
+
try:
|
| 77 |
+
scheherazade_url = "https://github.com/silnrsi/font-scheherazade/releases/download/v3.300/ScheherazadeNew-3.300.zip"
|
| 78 |
+
if download_and_extract(scheherazade_url, tmp_dir):
|
| 79 |
+
scheherazade_dir = os.path.join(tmp_dir, "ScheherazadeNew-3.300")
|
| 80 |
+
if os.path.exists(scheherazade_dir):
|
| 81 |
+
for file in os.listdir(scheherazade_dir):
|
| 82 |
+
if file.endswith('.ttf'):
|
| 83 |
+
src = os.path.join(scheherazade_dir, file)
|
| 84 |
+
dst = os.path.join(fonts_dir, file)
|
| 85 |
+
shutil.copy2(src, dst)
|
| 86 |
+
os.chmod(dst, 0o644)
|
| 87 |
+
print("✅ Scheherazade New font installed successfully")
|
| 88 |
+
scheherazade_installed = True
|
| 89 |
+
else:
|
| 90 |
+
print("❌ Scheherazade New font directory not found")
|
| 91 |
else:
|
| 92 |
+
print("❌ Failed to download Scheherazade New font")
|
| 93 |
+
except Exception as e:
|
| 94 |
+
print(f"❌ Error installing Scheherazade New font: {e}")
|
| 95 |
+
|
| 96 |
+
# If both fonts failed to install, try to copy local Arial font
|
| 97 |
+
if not amiri_installed and not scheherazade_installed:
|
| 98 |
+
print("📥 Copying local Arial font as fallback...")
|
| 99 |
+
try:
|
| 100 |
+
if os.path.exists("arial.ttf"):
|
| 101 |
+
dst = os.path.join(fonts_dir, "arial.ttf")
|
| 102 |
+
shutil.copy2("arial.ttf", dst)
|
| 103 |
+
os.chmod(dst, 0o644)
|
| 104 |
+
print("✅ Arial font copied successfully")
|
| 105 |
+
else:
|
| 106 |
+
print("❌ Local Arial font not found")
|
| 107 |
+
except Exception as e:
|
| 108 |
+
print(f"❌ Error copying Arial font: {e}")
|
| 109 |
|
| 110 |
# Update font cache
|
| 111 |
print("🔄 Updating font cache...")
|
| 112 |
+
try:
|
| 113 |
+
run_command("fc-cache -fv")
|
| 114 |
+
print("✅ Font cache updated successfully")
|
| 115 |
+
except Exception as e:
|
| 116 |
+
print(f"❌ Error updating font cache: {e}")
|
| 117 |
|
| 118 |
# Verify installation
|
| 119 |
print("✅ Verifying Arabic fonts installation...")
|
| 120 |
+
try:
|
| 121 |
+
result = run_command("fc-list | grep -i 'amiri\\|scheherazade\\|noto.*arabic\\|arial' | head -10")
|
| 122 |
+
if result:
|
| 123 |
+
print("Available Arabic fonts:")
|
| 124 |
+
print(result)
|
| 125 |
+
else:
|
| 126 |
+
print("No Arabic fonts found in font list")
|
| 127 |
+
except Exception as e:
|
| 128 |
+
print(f"❌ Error verifying font installation: {e}")
|
| 129 |
|
| 130 |
print("🎯 Arabic fonts setup completed!")
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
| 133 |
+
try:
|
| 134 |
+
setup_arabic_fonts()
|
| 135 |
+
except Exception as e:
|
| 136 |
+
print(f"❌ Font setup failed with error: {e}")
|
| 137 |
+
print("Continuing with default system fonts...")
|
test_font_setup.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Test script to verify font setup functionality
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import sys
|
| 8 |
+
import subprocess
|
| 9 |
+
|
| 10 |
+
def test_font_setup():
|
| 11 |
+
"""Test that font setup works correctly"""
|
| 12 |
+
print("Testing font setup...")
|
| 13 |
+
|
| 14 |
+
# Test that setup_fonts.py exists
|
| 15 |
+
if not os.path.exists("setup_fonts.py"):
|
| 16 |
+
print("❌ setup_fonts.py not found")
|
| 17 |
+
return False
|
| 18 |
+
|
| 19 |
+
# Test that arial.ttf exists
|
| 20 |
+
if not os.path.exists("arial.ttf"):
|
| 21 |
+
print("❌ arial.ttf not found")
|
| 22 |
+
return False
|
| 23 |
+
|
| 24 |
+
# Test that Dockerfile references setup_fonts.py
|
| 25 |
+
if os.path.exists("Dockerfile"):
|
| 26 |
+
with open("Dockerfile", "r", encoding="utf-8") as f:
|
| 27 |
+
dockerfile_content = f.read()
|
| 28 |
+
if "setup_fonts.py" not in dockerfile_content:
|
| 29 |
+
print("❌ Dockerfile does not reference setup_fonts.py")
|
| 30 |
+
return False
|
| 31 |
+
else:
|
| 32 |
+
print("❌ Dockerfile not found")
|
| 33 |
+
return False
|
| 34 |
+
|
| 35 |
+
# Test that the Python script is executable
|
| 36 |
+
try:
|
| 37 |
+
result = subprocess.run(["python3", "setup_fonts.py", "--help"],
|
| 38 |
+
capture_output=True, text=True, timeout=10)
|
| 39 |
+
# It's okay if it doesn't have a --help flag, we just want to verify it can run
|
| 40 |
+
print("✅ setup_fonts.py is executable")
|
| 41 |
+
except subprocess.TimeoutExpired:
|
| 42 |
+
print("✅ setup_fonts.py is executable (timed out as expected)")
|
| 43 |
+
except Exception as e:
|
| 44 |
+
print(f"❌ Error testing setup_fonts.py: {e}")
|
| 45 |
+
return False
|
| 46 |
+
|
| 47 |
+
print("✅ All font setup tests passed")
|
| 48 |
+
return True
|
| 49 |
+
|
| 50 |
+
if __name__ == "__main__":
|
| 51 |
+
success = test_font_setup()
|
| 52 |
+
sys.exit(0 if success else 1)
|