BabelDOC 0.3.10__tar.gz → 0.3.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {babeldoc-0.3.10 → babeldoc-0.3.12}/PKG-INFO +1 -1
- babeldoc-0.3.12/babeldoc/__init__.py +1 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/const.py +1 -1
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/backend/pdf_creater.py +18 -7
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/frontend/il_creater.py +298 -23
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/typesetting.py +4 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/main.py +1 -1
- {babeldoc-0.3.10 → babeldoc-0.3.12}/pyproject.toml +2 -2
- {babeldoc-0.3.10 → babeldoc-0.3.12}/uv.lock +1 -1
- babeldoc-0.3.10/babeldoc/__init__.py +0 -1
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.cursorignore +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/PULL_REQUEST_TEMPLATE/pr_form.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/dependabot.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/labels.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/release-drafter.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/codeql.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/docs.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/labeler.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/publish-to-pypi.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/test.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.gitignore +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/.pre-commit-config.yaml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/LICENSE +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/README.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/assets/assets.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/assets/embedding_assets_metadata.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/asynchronize/__init__.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/converter.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/__init__.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/babeldoc_exception/BabelDOCException.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/backend/__init__.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/frontend/__init__.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/il_version_1.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/il_version_1.rnc +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/il_version_1.rng +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/il_version_1.xsd +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/__init__.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/add_debug_information.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/detect_scanned_file.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/il_translator.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/il_translator_llm_only.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/layout_parser.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/remove_descent.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/styles_and_formulas.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/table_parser.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/translator/__init__.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/translator/cache.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/translator/translator.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/atomic_integer.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/fontmap.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/layout_helper.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/priority_thread_pool_executor.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/style_helper.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/xml_converter.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/README.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/__init__.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/doclayout.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/rpc_doclayout.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/table_detection/rapidocr.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/high_level.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/pdfinterp.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/progress_monitor.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/result_merger.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/split_manager.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/tools/generate_font_metadata.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/tools/italic_assistance.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/translation_config.py +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/CODE_OF_CONDUCT.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/CONTRIBUTING.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/CONTRIBUTOR_REWARD.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/README.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/Typesetting/Typesetting.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/README.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/deploy.sh +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-banner.png +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.png +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.svg +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-with-transparent-background.png +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-with-transparent-background.svg +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo.png +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-contributor_reward_example.png +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-preview.gif +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-small-logo-with-transparent-background.png +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-small-logo-with-transparent-background.svg +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-small-logo.png +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/index.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/intro-to-pdf-object.md +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/requirements.txt +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/mkdocs.yml +0 -0
- {babeldoc-0.3.10 → babeldoc-0.3.12}/tests/test_translation_config.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.12"
|
|
@@ -668,6 +668,10 @@ class PDFCreater:
|
|
|
668
668
|
xobj_draw_ops = {}
|
|
669
669
|
xobj_encoding_length_map = {}
|
|
670
670
|
available_font_list = self.get_available_font_list(pdf, page)
|
|
671
|
+
page_encoding_length_map = {
|
|
672
|
+
f.font_id: f.encoding_length for f in page.pdf_font
|
|
673
|
+
}
|
|
674
|
+
all_encoding_length_map = page_encoding_length_map.copy()
|
|
671
675
|
|
|
672
676
|
for xobj in page.pdf_xobject:
|
|
673
677
|
xobj_available_fonts[xobj.xobj_id] = available_font_list.copy()
|
|
@@ -680,12 +684,16 @@ class PDFCreater:
|
|
|
680
684
|
xobj_encoding_length_map[xobj.xobj_id] = {
|
|
681
685
|
f.font_id: f.encoding_length for f in xobj.pdf_font
|
|
682
686
|
}
|
|
687
|
+
all_encoding_length_map.update(
|
|
688
|
+
xobj_encoding_length_map[xobj.xobj_id]
|
|
689
|
+
)
|
|
690
|
+
xobj_encoding_length_map[xobj.xobj_id].update(
|
|
691
|
+
page_encoding_length_map
|
|
692
|
+
)
|
|
683
693
|
xobj_op = BitStream()
|
|
684
694
|
xobj_op.append(xobj.base_operations.value.encode())
|
|
685
695
|
xobj_draw_ops[xobj.xobj_id] = xobj_op
|
|
686
|
-
|
|
687
|
-
f.font_id: f.encoding_length for f in page.pdf_font
|
|
688
|
-
}
|
|
696
|
+
|
|
689
697
|
page_op = BitStream()
|
|
690
698
|
# q {ops_base}Q 1 0 0 1 {x0} {y0} cm {ops_new}
|
|
691
699
|
# page_op.append(b"q ")
|
|
@@ -740,10 +748,13 @@ class PDFCreater:
|
|
|
740
748
|
|
|
741
749
|
encoding_length = encoding_length_map.get(font_id, None)
|
|
742
750
|
if encoding_length is None:
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
751
|
+
if font_id in all_encoding_length_map:
|
|
752
|
+
encoding_length = all_encoding_length_map[font_id]
|
|
753
|
+
else:
|
|
754
|
+
logger.debug(
|
|
755
|
+
f"Font {font_id} not found in encoding length map for page {page.page_number}"
|
|
756
|
+
)
|
|
757
|
+
continue
|
|
747
758
|
# pdf32000-2008 page14:
|
|
748
759
|
# As hexadecimal data enclosed in angle brackets < >
|
|
749
760
|
# see 7.3.4.3, "Hexadecimal Strings."
|
|
@@ -78,7 +78,267 @@ def get_name_cbox(face, name):
|
|
|
78
78
|
return get_glyph_cbox(face, g)
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
WinAnsiEncoding = [
|
|
82
|
+
0,
|
|
83
|
+
1,
|
|
84
|
+
2,
|
|
85
|
+
3,
|
|
86
|
+
4,
|
|
87
|
+
5,
|
|
88
|
+
6,
|
|
89
|
+
7,
|
|
90
|
+
8,
|
|
91
|
+
9,
|
|
92
|
+
10,
|
|
93
|
+
11,
|
|
94
|
+
12,
|
|
95
|
+
13,
|
|
96
|
+
14,
|
|
97
|
+
15,
|
|
98
|
+
16,
|
|
99
|
+
17,
|
|
100
|
+
18,
|
|
101
|
+
19,
|
|
102
|
+
20,
|
|
103
|
+
21,
|
|
104
|
+
22,
|
|
105
|
+
23,
|
|
106
|
+
24,
|
|
107
|
+
25,
|
|
108
|
+
26,
|
|
109
|
+
27,
|
|
110
|
+
28,
|
|
111
|
+
29,
|
|
112
|
+
30,
|
|
113
|
+
31,
|
|
114
|
+
32,
|
|
115
|
+
33,
|
|
116
|
+
34,
|
|
117
|
+
35,
|
|
118
|
+
36,
|
|
119
|
+
37,
|
|
120
|
+
38,
|
|
121
|
+
39,
|
|
122
|
+
40,
|
|
123
|
+
41,
|
|
124
|
+
42,
|
|
125
|
+
43,
|
|
126
|
+
44,
|
|
127
|
+
45,
|
|
128
|
+
46,
|
|
129
|
+
47,
|
|
130
|
+
48,
|
|
131
|
+
49,
|
|
132
|
+
50,
|
|
133
|
+
51,
|
|
134
|
+
52,
|
|
135
|
+
53,
|
|
136
|
+
54,
|
|
137
|
+
55,
|
|
138
|
+
56,
|
|
139
|
+
57,
|
|
140
|
+
58,
|
|
141
|
+
59,
|
|
142
|
+
60,
|
|
143
|
+
61,
|
|
144
|
+
62,
|
|
145
|
+
63,
|
|
146
|
+
64,
|
|
147
|
+
65,
|
|
148
|
+
66,
|
|
149
|
+
67,
|
|
150
|
+
68,
|
|
151
|
+
69,
|
|
152
|
+
70,
|
|
153
|
+
71,
|
|
154
|
+
72,
|
|
155
|
+
73,
|
|
156
|
+
74,
|
|
157
|
+
75,
|
|
158
|
+
76,
|
|
159
|
+
77,
|
|
160
|
+
78,
|
|
161
|
+
79,
|
|
162
|
+
80,
|
|
163
|
+
81,
|
|
164
|
+
82,
|
|
165
|
+
83,
|
|
166
|
+
84,
|
|
167
|
+
85,
|
|
168
|
+
86,
|
|
169
|
+
87,
|
|
170
|
+
88,
|
|
171
|
+
89,
|
|
172
|
+
90,
|
|
173
|
+
91,
|
|
174
|
+
92,
|
|
175
|
+
93,
|
|
176
|
+
94,
|
|
177
|
+
95,
|
|
178
|
+
96,
|
|
179
|
+
97,
|
|
180
|
+
98,
|
|
181
|
+
99,
|
|
182
|
+
100,
|
|
183
|
+
101,
|
|
184
|
+
102,
|
|
185
|
+
103,
|
|
186
|
+
104,
|
|
187
|
+
105,
|
|
188
|
+
106,
|
|
189
|
+
107,
|
|
190
|
+
108,
|
|
191
|
+
109,
|
|
192
|
+
110,
|
|
193
|
+
111,
|
|
194
|
+
112,
|
|
195
|
+
113,
|
|
196
|
+
114,
|
|
197
|
+
115,
|
|
198
|
+
116,
|
|
199
|
+
117,
|
|
200
|
+
118,
|
|
201
|
+
119,
|
|
202
|
+
120,
|
|
203
|
+
121,
|
|
204
|
+
122,
|
|
205
|
+
123,
|
|
206
|
+
124,
|
|
207
|
+
125,
|
|
208
|
+
126,
|
|
209
|
+
127,
|
|
210
|
+
8364,
|
|
211
|
+
0,
|
|
212
|
+
8218,
|
|
213
|
+
402,
|
|
214
|
+
8222,
|
|
215
|
+
8230,
|
|
216
|
+
8224,
|
|
217
|
+
8225,
|
|
218
|
+
710,
|
|
219
|
+
8240,
|
|
220
|
+
352,
|
|
221
|
+
8249,
|
|
222
|
+
338,
|
|
223
|
+
0,
|
|
224
|
+
381,
|
|
225
|
+
0,
|
|
226
|
+
0,
|
|
227
|
+
8216,
|
|
228
|
+
8217,
|
|
229
|
+
8220,
|
|
230
|
+
8221,
|
|
231
|
+
8226,
|
|
232
|
+
8211,
|
|
233
|
+
8212,
|
|
234
|
+
732,
|
|
235
|
+
8482,
|
|
236
|
+
353,
|
|
237
|
+
8250,
|
|
238
|
+
339,
|
|
239
|
+
0,
|
|
240
|
+
382,
|
|
241
|
+
376,
|
|
242
|
+
160,
|
|
243
|
+
161,
|
|
244
|
+
162,
|
|
245
|
+
163,
|
|
246
|
+
164,
|
|
247
|
+
165,
|
|
248
|
+
166,
|
|
249
|
+
167,
|
|
250
|
+
168,
|
|
251
|
+
169,
|
|
252
|
+
170,
|
|
253
|
+
171,
|
|
254
|
+
172,
|
|
255
|
+
173,
|
|
256
|
+
174,
|
|
257
|
+
175,
|
|
258
|
+
176,
|
|
259
|
+
177,
|
|
260
|
+
178,
|
|
261
|
+
179,
|
|
262
|
+
180,
|
|
263
|
+
181,
|
|
264
|
+
182,
|
|
265
|
+
183,
|
|
266
|
+
184,
|
|
267
|
+
185,
|
|
268
|
+
186,
|
|
269
|
+
187,
|
|
270
|
+
188,
|
|
271
|
+
189,
|
|
272
|
+
190,
|
|
273
|
+
191,
|
|
274
|
+
192,
|
|
275
|
+
193,
|
|
276
|
+
194,
|
|
277
|
+
195,
|
|
278
|
+
196,
|
|
279
|
+
197,
|
|
280
|
+
198,
|
|
281
|
+
199,
|
|
282
|
+
200,
|
|
283
|
+
201,
|
|
284
|
+
202,
|
|
285
|
+
203,
|
|
286
|
+
204,
|
|
287
|
+
205,
|
|
288
|
+
206,
|
|
289
|
+
207,
|
|
290
|
+
208,
|
|
291
|
+
209,
|
|
292
|
+
210,
|
|
293
|
+
211,
|
|
294
|
+
212,
|
|
295
|
+
213,
|
|
296
|
+
214,
|
|
297
|
+
215,
|
|
298
|
+
216,
|
|
299
|
+
217,
|
|
300
|
+
218,
|
|
301
|
+
219,
|
|
302
|
+
220,
|
|
303
|
+
221,
|
|
304
|
+
222,
|
|
305
|
+
223,
|
|
306
|
+
224,
|
|
307
|
+
225,
|
|
308
|
+
226,
|
|
309
|
+
227,
|
|
310
|
+
228,
|
|
311
|
+
229,
|
|
312
|
+
230,
|
|
313
|
+
231,
|
|
314
|
+
232,
|
|
315
|
+
233,
|
|
316
|
+
234,
|
|
317
|
+
235,
|
|
318
|
+
236,
|
|
319
|
+
237,
|
|
320
|
+
238,
|
|
321
|
+
239,
|
|
322
|
+
240,
|
|
323
|
+
241,
|
|
324
|
+
242,
|
|
325
|
+
243,
|
|
326
|
+
244,
|
|
327
|
+
245,
|
|
328
|
+
246,
|
|
329
|
+
247,
|
|
330
|
+
248,
|
|
331
|
+
249,
|
|
332
|
+
250,
|
|
333
|
+
251,
|
|
334
|
+
252,
|
|
335
|
+
253,
|
|
336
|
+
254,
|
|
337
|
+
255,
|
|
338
|
+
]
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def parse_font_file(doc, idx, encoding, differences):
|
|
82
342
|
bbox_list = []
|
|
83
343
|
data = doc.xref_stream(idx)
|
|
84
344
|
face = freetype.Face(BytesIO(data))
|
|
@@ -86,9 +346,9 @@ def parse_font_file(doc, idx, encoding):
|
|
|
86
346
|
if charmap.encoding_name == "FT_ENCODING_ADOBE_CUSTOM":
|
|
87
347
|
face.select_charmap(freetype.FT_ENCODING_ADOBE_CUSTOM)
|
|
88
348
|
break
|
|
89
|
-
bbox_list = [get_char_cbox(face, x) for x in
|
|
90
|
-
if
|
|
91
|
-
for code, name in
|
|
349
|
+
bbox_list = [get_char_cbox(face, x) for x in encoding]
|
|
350
|
+
if differences:
|
|
351
|
+
for code, name in differences:
|
|
92
352
|
bbox_list[code] = get_name_cbox(face, name.encode("U8"))
|
|
93
353
|
return bbox_list
|
|
94
354
|
|
|
@@ -112,18 +372,23 @@ def parse_encoding(obj_str):
|
|
|
112
372
|
def parse_mapping(text):
|
|
113
373
|
mapping = []
|
|
114
374
|
for x in re.finditer(r"<(?P<num>[a-fA-F0-9]+)>", text):
|
|
115
|
-
mapping.append(
|
|
375
|
+
mapping.append(x.group("num"))
|
|
116
376
|
return mapping
|
|
117
377
|
|
|
118
378
|
|
|
119
379
|
def update_cmap_pair(cmap, data):
|
|
120
|
-
for
|
|
380
|
+
for start_str, stop_str, value_str in batched(data, 3):
|
|
381
|
+
start = int(start_str, 16)
|
|
382
|
+
stop = int(stop_str, 16)
|
|
383
|
+
value = base64.b16decode(value_str).decode("UTF-16-BE")
|
|
121
384
|
for code in range(start, stop + 1):
|
|
122
385
|
cmap[code] = value
|
|
123
386
|
|
|
124
387
|
|
|
125
388
|
def update_cmap_code(cmap, data):
|
|
126
|
-
for
|
|
389
|
+
for code_str, value_str in batched(data, 2):
|
|
390
|
+
code = int(code_str, 16)
|
|
391
|
+
value = base64.b16decode(value_str).decode("UTF-16-BE")
|
|
127
392
|
cmap[code] = value
|
|
128
393
|
|
|
129
394
|
|
|
@@ -354,16 +619,21 @@ class ILCreater:
|
|
|
354
619
|
encoding_length = 1
|
|
355
620
|
else:
|
|
356
621
|
_, to_unicode_id = self.mupdf.xref_get_key(xref_id, "ToUnicode")
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
622
|
+
if to_unicode_id is not None:
|
|
623
|
+
to_unicode_bytes = self.mupdf.xref_stream(
|
|
624
|
+
int(to_unicode_id.split(" ")[0]),
|
|
625
|
+
)
|
|
626
|
+
code_range = re.search(
|
|
627
|
+
b"begincodespacerange\n?.*<(\\d+?)>.*",
|
|
628
|
+
to_unicode_bytes,
|
|
629
|
+
).group(1)
|
|
630
|
+
encoding_length = len(code_range) // 2
|
|
365
631
|
except Exception:
|
|
366
|
-
if
|
|
632
|
+
if (
|
|
633
|
+
font.unicode_map
|
|
634
|
+
and font.unicode_map.cid2unichr
|
|
635
|
+
and max(font.unicode_map.cid2unichr.keys()) > 255
|
|
636
|
+
):
|
|
367
637
|
encoding_length = 2
|
|
368
638
|
else:
|
|
369
639
|
encoding_length = 1
|
|
@@ -451,14 +721,19 @@ class ILCreater:
|
|
|
451
721
|
self.current_page.pdf_font.append(il_font_metadata)
|
|
452
722
|
|
|
453
723
|
def parse_font_xobj_id(self, xobj_id: int):
|
|
454
|
-
encoding = []
|
|
455
|
-
font_encoding = self.mupdf.xref_get_key(xobj_id, "Encoding/Differences")
|
|
456
|
-
if font_encoding:
|
|
457
|
-
encoding = parse_encoding(font_encoding[1])
|
|
458
724
|
bbox_list = []
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
725
|
+
encoding = list(range(256))
|
|
726
|
+
font_encoding = self.mupdf.xref_get_key(xobj_id, "Encoding")
|
|
727
|
+
if font_encoding[1] == "/WinAnsiEncoding":
|
|
728
|
+
encoding = WinAnsiEncoding
|
|
729
|
+
differences = []
|
|
730
|
+
font_differences = self.mupdf.xref_get_key(xobj_id, "Encoding/Differences")
|
|
731
|
+
if font_differences:
|
|
732
|
+
differences = parse_encoding(font_differences[1])
|
|
733
|
+
for file_key in ["FontFile", "FontFile2", "FontFile3"]:
|
|
734
|
+
font_file = self.mupdf.xref_get_key(xobj_id, f"FontDescriptor/{file_key}")
|
|
735
|
+
if file_idx := indirect(font_file):
|
|
736
|
+
bbox_list = parse_font_file(self.mupdf, file_idx, encoding, differences)
|
|
462
737
|
cmap = {}
|
|
463
738
|
to_unicode = self.mupdf.xref_get_key(xobj_id, "ToUnicode")
|
|
464
739
|
if to_unicode_idx := indirect(to_unicode):
|
|
@@ -277,6 +277,8 @@ class TypesettingUnit:
|
|
|
277
277
|
@property
|
|
278
278
|
def box(self):
|
|
279
279
|
if self.char:
|
|
280
|
+
if self.char.visual_bbox and self.char.visual_bbox.box:
|
|
281
|
+
return self.char.visual_bbox.box
|
|
280
282
|
return self.char.box
|
|
281
283
|
elif self.formular:
|
|
282
284
|
return self.formular.box
|
|
@@ -325,6 +327,7 @@ class TypesettingUnit:
|
|
|
325
327
|
vertical=self.char.vertical,
|
|
326
328
|
advance=self.char.advance * scale if self.char.advance else None,
|
|
327
329
|
debug_info=self.debug_info,
|
|
330
|
+
xobj_id=self.char.xobj_id,
|
|
328
331
|
)
|
|
329
332
|
return TypesettingUnit(char=new_char)
|
|
330
333
|
|
|
@@ -384,6 +387,7 @@ class TypesettingUnit:
|
|
|
384
387
|
scale=scale,
|
|
385
388
|
vertical=char.vertical,
|
|
386
389
|
advance=char.advance * scale if char.advance else None,
|
|
390
|
+
xobj_id=char.xobj_id,
|
|
387
391
|
)
|
|
388
392
|
new_chars.append(new_char)
|
|
389
393
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "BabelDOC"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.12"
|
|
4
4
|
description = "Yet Another Document Translator"
|
|
5
5
|
license = "AGPL-3.0"
|
|
6
6
|
readme = "README.md"
|
|
@@ -148,7 +148,7 @@ pythonpath = [".", "src"]
|
|
|
148
148
|
testpaths = ["tests"]
|
|
149
149
|
|
|
150
150
|
[bumpver]
|
|
151
|
-
current_version = "0.3.
|
|
151
|
+
current_version = "0.3.12"
|
|
152
152
|
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
|
153
153
|
|
|
154
154
|
[bumpver.file_patterns]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.10"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/babeldoc_exception/BabelDOCException.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/priority_thread_pool_executor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-with-transparent-background.png
RENAMED
|
File without changes
|
{babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-with-transparent-background.svg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-small-logo-with-transparent-background.png
RENAMED
|
File without changes
|
{babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-small-logo-with-transparent-background.svg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|