summarylogtreecommitdiffstats
path: root/0002-pymupdf.patch
blob: 8498b386cff689c6c8ace3e140356485c8f00f7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
diff -ru mupdf-1.18.0-source-orig/include/mupdf/fitz/config.h mupdf-1.18.0-source/include/mupdf/fitz/config.h
--- mupdf-1.18.0-source-orig/include/mupdf/fitz/config.h	2020-10-07 18:35:03.000000000 +0800
+++ mupdf-1.18.0-source/include/mupdf/fitz/config.h	2020-10-13 00:08:32.729025714 +0800
@@ -35,7 +35,7 @@
 /**
 	Choose whether to enable ICC color profiles.
 */
-/* #define FZ_ENABLE_ICC 1 */
+#define FZ_ENABLE_ICC 1
 
 /**
 	Choose whether to enable JPEG2000 decoding.
@@ -61,7 +61,7 @@
 	unwanted fonts.
 */
 /* To avoid all noto fonts except CJK, enable: */
-/* #define TOFU */
+#define TOFU // <=== PyMuPDF: not the complete NOTO!
 
 /* To skip the CJK font, enable: (this implicitly enables TOFU_CJK_EXT
  * and TOFU_CJK_LANG) */
@@ -69,22 +69,22 @@
 
 /* To skip CJK Extension A, enable: (this implicitly enables
  * TOFU_CJK_LANG) */
-/* #define TOFU_CJK_EXT */
+#define TOFU_CJK_EXT // <=== PyMuPDF: causes 1.5 MB extra size
 
 /* To skip CJK language specific fonts, enable: */
-/* #define TOFU_CJK_LANG */
+#define TOFU_CJK_LANG // <=== PyMuPDF
 
 /* To skip the Emoji font, enable: */
-/* #define TOFU_EMOJI */
+#define TOFU_EMOJI // <=== PyMuPDF
 
 /* To skip the ancient/historic scripts, enable: */
-/* #define TOFU_HISTORIC */
+#define TOFU_HISTORIC // <=== PyMuPDF
 
 /* To skip the symbol font, enable: */
-/* #define TOFU_SYMBOL */
+#define TOFU_SYMBOL // <=== PyMuPDF
 
 /* To skip the SIL fonts, enable: */
-/* #define TOFU_SIL */
+// #define TOFU_SIL // <=== PyMuPDF: ok to have it, only small fonts
 
 /* To skip the Base14 fonts, enable: */
 /* #define TOFU_BASE14 */
diff -ru mupdf-1.18.0-source-orig/source/pdf/pdf-font-add.c mupdf-1.18.0-source/source/pdf/pdf-font-add.c
--- mupdf-1.18.0-source-orig/source/pdf/pdf-font-add.c	2020-10-07 18:35:03.000000000 +0800
+++ mupdf-1.18.0-source/source/pdf/pdf-font-add.c	2020-10-13 00:08:32.729025714 +0800
@@ -778,3 +778,20 @@
 
 	return fref;
 }
+void jm_valid_chars(fz_context *ctx, fz_font *font, void *arr)
+{
+	FT_Face face = font->ft_face;
+	FT_ULong ucs;
+	FT_UInt gid;
+	long *table = (long *)arr;
+	fz_lock(ctx, FZ_LOCK_FREETYPE);
+	ucs = FT_Get_First_Char(face, &gid);
+	while (gid > 0)
+	{
+		if (gid < (FT_ULong)face->num_glyphs && face->num_glyphs > 0)
+			table[gid] = (long)ucs;
+		ucs = FT_Get_Next_Char(face, ucs, &gid);
+	}
+	fz_unlock(ctx, FZ_LOCK_FREETYPE);
+	return;
+}