Spaces:
Running
Running
Upload 15 files
Browse files- .gitattributes +13 -0
- fonts/Deng.ttf +3 -0
- fonts/Dengb.ttf +3 -0
- fonts/Dengl.ttf +3 -0
- fonts/SIMLI.TTF +3 -0
- fonts/SIMYOU.TTF +3 -0
- fonts/SourceHanSerif.ttc +3 -0
- fonts/msyh.ttc +3 -0
- fonts/msyhbd.ttc +3 -0
- fonts/msyhl.ttc +3 -0
- fonts/simfang.ttf +3 -0
- fonts/simhei.ttf +3 -0
- fonts/simkai.ttf +3 -0
- fonts/simsun.ttc +3 -0
- install_fonts.py +62 -0
- pptx2pdf_web_en.py +62 -0
.gitattributes
CHANGED
@@ -35,3 +35,16 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
PptxToPDF filter=lfs diff=lfs merge=lfs -text
|
37 |
libSkiaSharp.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
PptxToPDF filter=lfs diff=lfs merge=lfs -text
|
37 |
libSkiaSharp.so filter=lfs diff=lfs merge=lfs -text
|
38 |
+
fonts/Deng.ttf filter=lfs diff=lfs merge=lfs -text
|
39 |
+
fonts/Dengb.ttf filter=lfs diff=lfs merge=lfs -text
|
40 |
+
fonts/Dengl.ttf filter=lfs diff=lfs merge=lfs -text
|
41 |
+
fonts/msyh.ttc filter=lfs diff=lfs merge=lfs -text
|
42 |
+
fonts/msyhbd.ttc filter=lfs diff=lfs merge=lfs -text
|
43 |
+
fonts/msyhl.ttc filter=lfs diff=lfs merge=lfs -text
|
44 |
+
fonts/simfang.ttf filter=lfs diff=lfs merge=lfs -text
|
45 |
+
fonts/simhei.ttf filter=lfs diff=lfs merge=lfs -text
|
46 |
+
fonts/simkai.ttf filter=lfs diff=lfs merge=lfs -text
|
47 |
+
fonts/SIMLI.TTF filter=lfs diff=lfs merge=lfs -text
|
48 |
+
fonts/simsun.ttc filter=lfs diff=lfs merge=lfs -text
|
49 |
+
fonts/SIMYOU.TTF filter=lfs diff=lfs merge=lfs -text
|
50 |
+
fonts/SourceHanSerif.ttc filter=lfs diff=lfs merge=lfs -text
|
fonts/Deng.ttf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e051009b42b454352a90ae0c9b8adb58bbdbcd168768750b35bc3357510de141
|
3 |
+
size 16324168
|
fonts/Dengb.ttf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:236df24be867e527bdf810d00eb5c38f18244e776238a9f5ca937363267a9169
|
3 |
+
size 16450596
|
fonts/Dengl.ttf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3ae7cf364a29b9da69eff7333decb88e577c262c5847df2510e37695e25a8395
|
3 |
+
size 15437648
|
fonts/SIMLI.TTF
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e5a3a1e2e2cb6fee66d1e7f821b5c04f3ad7792f1e5b3cac545c2e52173e908d
|
3 |
+
size 9223160
|
fonts/SIMYOU.TTF
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e4440e07e02fa6b5a8f497da52fcab0aa711b399d43ff28a2ba246c603363930
|
3 |
+
size 6700204
|
fonts/SourceHanSerif.ttc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ec4bb0925499e1a71bc5829e8b5235ae14cbe7f956c1d9f3e9424f8f8d91820d
|
3 |
+
size 170495268
|
fonts/msyh.ttc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d79c55e68b1131eea0cc1c47be4f572d964f28c682e143db2ad09c1e4cb07a3f
|
3 |
+
size 19704352
|
fonts/msyhbd.ttc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4508821b3dffe01f0ef5e5326a3e60df705a44633858811f67b6982dce3f6ee6
|
3 |
+
size 16883552
|
fonts/msyhl.ttc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7e9bdf90bb5d3fe1b5975fc8ae31944b8fa674122261f92c28d4ec0b9c482fa1
|
3 |
+
size 12189612
|
fonts/simfang.ttf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3e2d44b01c9a248a61bedae4f15c8aae501328b1f7adfe6e111a5da5aa5c5104
|
3 |
+
size 10578152
|
fonts/simhei.ttf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:aa4560dd8fe5645745fed3ffa301c3ca4d6c03cbd738145b613303961ba733b8
|
3 |
+
size 9753388
|
fonts/simkai.ttf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9dd76f7ab430edd091db24c3f18e71410325c1414141aad5fe67947873ffba06
|
3 |
+
size 11787328
|
fonts/simsun.ttc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:120a51d2b14eb588700a21e15fc301f0ea55d7c1a4e1f3ae61db83b7c8d42cd6
|
3 |
+
size 18070492
|
install_fonts.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import shutil
|
3 |
+
import subprocess
|
4 |
+
from pathlib import Path
|
5 |
+
|
6 |
+
def install_fonts_from_repository():
|
7 |
+
"""
|
8 |
+
将仓库中的 fonts 目录下的所有字体文件复制到 ~/.fonts 目录,并刷新字体缓存。
|
9 |
+
"""
|
10 |
+
|
11 |
+
# 获取当前用户的主目录路径
|
12 |
+
home_dir = Path.home()
|
13 |
+
|
14 |
+
# 定义目标字体目录路径:~/.fonts
|
15 |
+
fonts_dir = home_dir / ".fonts"
|
16 |
+
|
17 |
+
# 如果 ~/.fonts 目录不存在,则创建该目录
|
18 |
+
if not fonts_dir.exists():
|
19 |
+
fonts_dir.mkdir(parents=True)
|
20 |
+
print(f"已创建字体目录:{fonts_dir}")
|
21 |
+
else:
|
22 |
+
print(f"字体目录已存在:{fonts_dir}")
|
23 |
+
|
24 |
+
# 定义仓库中的 fonts 目录路径
|
25 |
+
repo_fonts_dir = Path(__file__).parent / "fonts"
|
26 |
+
|
27 |
+
# 检查仓库中的 fonts 目录是否存在
|
28 |
+
if not repo_fonts_dir.exists():
|
29 |
+
print(f"错误:仓库中的 fonts 目录不存在:{repo_fonts_dir}")
|
30 |
+
return
|
31 |
+
|
32 |
+
# 支持的字体文件扩展名
|
33 |
+
font_extensions = [".ttf", ".otf"]
|
34 |
+
|
35 |
+
# 统计已复制的字体文件数量
|
36 |
+
copied_count = 0
|
37 |
+
|
38 |
+
# 遍历 fonts 目录中的所有文件
|
39 |
+
for font_file in repo_fonts_dir.iterdir():
|
40 |
+
if font_file.suffix.lower() in font_extensions:
|
41 |
+
destination = fonts_dir / font_file.name
|
42 |
+
try:
|
43 |
+
shutil.copy(font_file, destination)
|
44 |
+
print(f"已复制字体文件:{font_file.name} 到 {destination}")
|
45 |
+
copied_count += 1
|
46 |
+
except Exception as e:
|
47 |
+
print(f"复制字体文件时出错:{font_file.name},错误信息:{e}")
|
48 |
+
|
49 |
+
if copied_count == 0:
|
50 |
+
print("未找到任何可复制的字体文件。")
|
51 |
+
return
|
52 |
+
|
53 |
+
# 刷新字体缓存
|
54 |
+
try:
|
55 |
+
print("正在刷新字体缓存...")
|
56 |
+
subprocess.run(["fc-cache", "-f", "-v"], check=True)
|
57 |
+
print("字体缓存刷新完成。")
|
58 |
+
except subprocess.CalledProcessError as e:
|
59 |
+
print(f"刷新字体缓存时出错:{e}")
|
60 |
+
|
61 |
+
if __name__ == "__main__":
|
62 |
+
install_fonts_from_repository()
|
pptx2pdf_web_en.py
CHANGED
@@ -5,6 +5,7 @@ import subprocess
|
|
5 |
import sys
|
6 |
import tempfile
|
7 |
from zipfile import ZipFile
|
|
|
8 |
|
9 |
# 程序根目录
|
10 |
BASE_DIR = os.path.dirname(__file__)
|
@@ -23,6 +24,67 @@ except Exception as e:
|
|
23 |
# 如果权限设置失败,也无需中断,只要后续能调用即可
|
24 |
print(f"⚠️ 警告:设置执行权限失败:{e}")
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
def convert_pptx_to_pdf(pptx_path, output_dir):
|
27 |
# 检查可执行文件是否存在
|
28 |
if not os.path.exists(BINARY_PATH):
|
|
|
5 |
import sys
|
6 |
import tempfile
|
7 |
from zipfile import ZipFile
|
8 |
+
from pathlib import Path
|
9 |
|
10 |
# 程序根目录
|
11 |
BASE_DIR = os.path.dirname(__file__)
|
|
|
24 |
# 如果权限设置失败,也无需中断,只要后续能调用即可
|
25 |
print(f"⚠️ 警告:设置执行权限失败:{e}")
|
26 |
|
27 |
+
def install_fonts_from_repository():
|
28 |
+
"""
|
29 |
+
将仓库中的 fonts 目录下的所有字体文件复制到 ~/.fonts 目录,并刷新字体缓存。
|
30 |
+
"""
|
31 |
+
try:
|
32 |
+
# 获取当前用户的主目录路径
|
33 |
+
home_dir = Path.home()
|
34 |
+
|
35 |
+
# 定义目标字体目录路径:~/.fonts
|
36 |
+
fonts_dir = home_dir / ".fonts"
|
37 |
+
|
38 |
+
# 如果 ~/.fonts 目录不存在,则创建该目录
|
39 |
+
if not fonts_dir.exists():
|
40 |
+
fonts_dir.mkdir(parents=True)
|
41 |
+
print(f"已创建字体目录:{fonts_dir}")
|
42 |
+
else:
|
43 |
+
print(f"字体目录已存在:{fonts_dir}")
|
44 |
+
|
45 |
+
# 定义仓库中的 fonts 目录路径
|
46 |
+
repo_fonts_dir = Path(__file__).parent / "fonts"
|
47 |
+
|
48 |
+
# 检查仓库中的 fonts 目录是否存在
|
49 |
+
if not repo_fonts_dir.exists():
|
50 |
+
print(f"错误:仓库中的 fonts 目录不存在:{repo_fonts_dir}")
|
51 |
+
return
|
52 |
+
|
53 |
+
# 支持的字体文件扩展名
|
54 |
+
font_extensions = [".ttf", ".otf", ".ttc"]
|
55 |
+
|
56 |
+
# 统计已复制的字体文件数量
|
57 |
+
copied_count = 0
|
58 |
+
|
59 |
+
# 遍历 fonts 目录中的所有文件
|
60 |
+
for font_file in repo_fonts_dir.iterdir():
|
61 |
+
if font_file.suffix.lower() in font_extensions:
|
62 |
+
destination = fonts_dir / font_file.name
|
63 |
+
try:
|
64 |
+
shutil.copy(font_file, destination)
|
65 |
+
print(f"已复制字体文件:{font_file.name} 到 {destination}")
|
66 |
+
copied_count += 1
|
67 |
+
except Exception as e:
|
68 |
+
print(f"复制字体文件时出错:{font_file.name},错误信息:{e}")
|
69 |
+
|
70 |
+
if copied_count == 0:
|
71 |
+
print("未找到任何可复制的字体文件。")
|
72 |
+
return
|
73 |
+
|
74 |
+
# 刷新字体缓存(仅在 Linux/Mac 下)
|
75 |
+
if not sys.platform.startswith('win'):
|
76 |
+
try:
|
77 |
+
print("正在刷新字体缓存...")
|
78 |
+
subprocess.run(["fc-cache", "-f", "-v"], check=True)
|
79 |
+
print("字体缓存刷新完成。")
|
80 |
+
except subprocess.CalledProcessError as e:
|
81 |
+
print(f"刷新字体缓存时出错:{e}")
|
82 |
+
except Exception as e:
|
83 |
+
print(f"安装字体时出错:{e}")
|
84 |
+
|
85 |
+
# 启动时安装字体
|
86 |
+
install_fonts_from_repository()
|
87 |
+
|
88 |
def convert_pptx_to_pdf(pptx_path, output_dir):
|
89 |
# 检查可执行文件是否存在
|
90 |
if not os.path.exists(BINARY_PATH):
|