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.
Files changed (99) hide show
  1. {babeldoc-0.3.10 → babeldoc-0.3.12}/PKG-INFO +1 -1
  2. babeldoc-0.3.12/babeldoc/__init__.py +1 -0
  3. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/const.py +1 -1
  4. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/backend/pdf_creater.py +18 -7
  5. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/frontend/il_creater.py +298 -23
  6. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/typesetting.py +4 -0
  7. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/main.py +1 -1
  8. {babeldoc-0.3.10 → babeldoc-0.3.12}/pyproject.toml +2 -2
  9. {babeldoc-0.3.10 → babeldoc-0.3.12}/uv.lock +1 -1
  10. babeldoc-0.3.10/babeldoc/__init__.py +0 -1
  11. {babeldoc-0.3.10 → babeldoc-0.3.12}/.cursorignore +0 -0
  12. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
  13. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
  14. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/PULL_REQUEST_TEMPLATE/pr_form.yml +0 -0
  15. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/dependabot.yml +0 -0
  16. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/labels.yml +0 -0
  17. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/release-drafter.yml +0 -0
  18. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/codeql.yml +0 -0
  19. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/docs.yml +0 -0
  20. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/labeler.yml +0 -0
  21. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/publish-to-pypi.yml +0 -0
  22. {babeldoc-0.3.10 → babeldoc-0.3.12}/.github/workflows/test.yml +0 -0
  23. {babeldoc-0.3.10 → babeldoc-0.3.12}/.gitignore +0 -0
  24. {babeldoc-0.3.10 → babeldoc-0.3.12}/.pre-commit-config.yaml +0 -0
  25. {babeldoc-0.3.10 → babeldoc-0.3.12}/LICENSE +0 -0
  26. {babeldoc-0.3.10 → babeldoc-0.3.12}/README.md +0 -0
  27. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/assets/assets.py +0 -0
  28. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/assets/embedding_assets_metadata.py +0 -0
  29. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/asynchronize/__init__.py +0 -0
  30. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/converter.py +0 -0
  31. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/__init__.py +0 -0
  32. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/babeldoc_exception/BabelDOCException.py +0 -0
  33. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/backend/__init__.py +0 -0
  34. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/frontend/__init__.py +0 -0
  35. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/il_version_1.py +0 -0
  36. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/il_version_1.rnc +0 -0
  37. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/il_version_1.rng +0 -0
  38. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/il_version_1.xsd +0 -0
  39. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/__init__.py +0 -0
  40. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/add_debug_information.py +0 -0
  41. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/detect_scanned_file.py +0 -0
  42. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/il_translator.py +0 -0
  43. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/il_translator_llm_only.py +0 -0
  44. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/layout_parser.py +0 -0
  45. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
  46. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/remove_descent.py +0 -0
  47. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/styles_and_formulas.py +0 -0
  48. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/midend/table_parser.py +0 -0
  49. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/translator/__init__.py +0 -0
  50. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/translator/cache.py +0 -0
  51. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/translator/translator.py +0 -0
  52. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/atomic_integer.py +0 -0
  53. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/fontmap.py +0 -0
  54. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/layout_helper.py +0 -0
  55. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/priority_thread_pool_executor.py +0 -0
  56. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/utils/style_helper.py +0 -0
  57. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/document_il/xml_converter.py +0 -0
  58. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/README.md +0 -0
  59. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/__init__.py +0 -0
  60. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/doclayout.py +0 -0
  61. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/rpc_doclayout.py +0 -0
  62. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/docvision/table_detection/rapidocr.py +0 -0
  63. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/high_level.py +0 -0
  64. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/pdfinterp.py +0 -0
  65. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/progress_monitor.py +0 -0
  66. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/result_merger.py +0 -0
  67. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/split_manager.py +0 -0
  68. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/tools/generate_font_metadata.py +0 -0
  69. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/tools/italic_assistance.py +0 -0
  70. {babeldoc-0.3.10 → babeldoc-0.3.12}/babeldoc/translation_config.py +0 -0
  71. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/CODE_OF_CONDUCT.md +0 -0
  72. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/CONTRIBUTING.md +0 -0
  73. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/CONTRIBUTOR_REWARD.md +0 -0
  74. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +0 -0
  75. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
  76. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
  77. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
  78. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
  79. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/README.md +0 -0
  80. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
  81. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/ImplementationDetails/Typesetting/Typesetting.md +0 -0
  82. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/README.md +0 -0
  83. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/deploy.sh +0 -0
  84. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-banner.png +0 -0
  85. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.png +0 -0
  86. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.svg +0 -0
  87. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-with-transparent-background.png +0 -0
  88. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo-with-transparent-background.svg +0 -0
  89. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-big-logo.png +0 -0
  90. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-contributor_reward_example.png +0 -0
  91. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-preview.gif +0 -0
  92. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-small-logo-with-transparent-background.png +0 -0
  93. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-small-logo-with-transparent-background.svg +0 -0
  94. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/images/babeldoc-small-logo.png +0 -0
  95. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/index.md +0 -0
  96. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/intro-to-pdf-object.md +0 -0
  97. {babeldoc-0.3.10 → babeldoc-0.3.12}/docs/requirements.txt +0 -0
  98. {babeldoc-0.3.10 → babeldoc-0.3.12}/mkdocs.yml +0 -0
  99. {babeldoc-0.3.10 → babeldoc-0.3.12}/tests/test_translation_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: BabelDOC
3
- Version: 0.3.10
3
+ Version: 0.3.12
4
4
  Summary: Yet Another Document Translator
5
5
  Project-URL: Homepage, https://github.com/funstory-ai/BabelDOC
6
6
  Project-URL: Issues, https://github.com/funstory-ai/BabelDOC/issues
@@ -0,0 +1 @@
1
+ __version__ = "0.3.12"
@@ -3,7 +3,7 @@ import shutil
3
3
  import subprocess
4
4
  from pathlib import Path
5
5
 
6
- __version__ = "0.3.10"
6
+ __version__ = "0.3.12"
7
7
 
8
8
  CACHE_FOLDER = Path.home() / ".cache" / "babeldoc"
9
9
 
@@ -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
- page_encoding_length_map = {
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
- logger.debug(
744
- f"Font {font_id} not found in encoding length map for page {page.page_number}"
745
- )
746
- continue
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
- def parse_font_file(doc, idx, encoding):
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 range(0, 256)]
90
- if encoding:
91
- for code, name in encoding:
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(int(x.group("num"), 16))
375
+ mapping.append(x.group("num"))
116
376
  return mapping
117
377
 
118
378
 
119
379
  def update_cmap_pair(cmap, data):
120
- for start, stop, value in batched(data, 3):
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 code, value in batched(data, 2):
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
- to_unicode_bytes = self.mupdf.xref_stream(
358
- int(to_unicode_id.split(" ")[0]),
359
- )
360
- code_range = re.search(
361
- b"begincodespacerange\n?.*<(\\d+?)>.*",
362
- to_unicode_bytes,
363
- ).group(1)
364
- encoding_length = len(code_range) // 2
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 max(font.unicode_map.cid2unichr.keys()) > 255:
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
- font_file = self.mupdf.xref_get_key(xobj_id, "FontDescriptor/FontFile")
460
- if file_idx := indirect(font_file):
461
- bbox_list = parse_font_file(self.mupdf, file_idx, encoding)
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
 
@@ -23,7 +23,7 @@ from babeldoc.translation_config import TranslationConfig
23
23
  from babeldoc.translation_config import WatermarkOutputMode
24
24
 
25
25
  logger = logging.getLogger(__name__)
26
- __version__ = "0.3.10"
26
+ __version__ = "0.3.12"
27
27
 
28
28
 
29
29
  def create_parser():
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "BabelDOC"
3
- version = "0.3.10"
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.10"
151
+ current_version = "0.3.12"
152
152
  version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
153
153
 
154
154
  [bumpver.file_patterns]
@@ -48,7 +48,7 @@ wheels = [
48
48
 
49
49
  [[package]]
50
50
  name = "babeldoc"
51
- version = "0.3.10"
51
+ version = "0.3.12"
52
52
  source = { editable = "." }
53
53
  dependencies = [
54
54
  { name = "bitstring" },
@@ -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