comparison mupdf-source/scripts/makenoto.py @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 #!/usr/bin/env python3
2
3 import glob, os
4
5 scripts = []
6
7 for line in open("include/mupdf/ucdn.h").readlines():
8 if line.startswith("#define"):
9 name = line.split()[1]
10 if name.startswith("UCDN_SCRIPT_"):
11 scripts.append(name)
12
13 blacklist = [
14 "UCDN_SCRIPT_UNKNOWN",
15 "UCDN_SCRIPT_INHERITED",
16
17 "UCDN_SCRIPT_COMMON",
18 "UCDN_SCRIPT_LATIN",
19 "UCDN_SCRIPT_GREEK",
20 "UCDN_SCRIPT_CYRILLIC",
21 "UCDN_SCRIPT_HIRAGANA",
22 "UCDN_SCRIPT_KATAKANA",
23 "UCDN_SCRIPT_BOPOMOFO",
24 "UCDN_SCRIPT_HAN",
25 "UCDN_SCRIPT_HANGUL",
26
27 "UCDN_SCRIPT_BRAILLE",
28 "UCDN_SCRIPT_MEROITIC_CURSIVE",
29 "UCDN_SCRIPT_MEROITIC_HIEROGLYPHS",
30 "UCDN_SCRIPT_SYRIAC",
31 ]
32
33 for s in blacklist:
34 scripts.remove(s)
35
36 fonts = glob.glob("resources/fonts/noto/*.?tf")
37 #fonts.remove("resources/fonts/noto/NotoSans-Regular.otf")
38 #fonts.remove("resources/fonts/noto/NotoSerif-Regular.otf")
39 #fonts.remove("resources/fonts/noto/NotoSansSymbols-Regular.ttf")
40 #fonts.remove("resources/fonts/noto/NotoEmoji-Regular.ttf")
41
42 lower = {}
43 for f in fonts:
44 lower[f.lower()] = os.path.basename(f)
45 unused = list(lower.keys())
46 unused.sort()
47
48 def casefont(us, ss, n):
49 if n in lower:
50 nn = lower[n].replace('.','_').replace('-','_')
51 print("case %s: RETURN(noto_%s);" % (us,nn))
52 del lower[n]
53 return True
54 return False
55
56 for us in scripts:
57 ss = "".join([s.capitalize() for s in us.split("_")[2:]])
58 list = []
59 list.append("resources/fonts/noto/NotoSerif" + ss + "-Regular.otf")
60 list.append("resources/fonts/noto/NotoSans" + ss + "-Regular.otf")
61 list.append("resources/fonts/noto/NotoSerif" + ss + "-Regular.ttf")
62 list.append("resources/fonts/noto/NotoSans" + ss + "-Regular.ttf")
63 found = False
64 for font in list:
65 if casefont(us, ss, font.lower()):
66 found = True
67 break
68 if not found:
69 print("case %s: break;" % us)
70 for font in list:
71 if font.lower() in unused: unused.remove(font.lower())
72
73 for f in unused:
74 print("// unmapped font:", lower[f])
75
76 for f in lower:
77 if not f in unused:
78 print("// unused font file:", lower[f])