Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.8.9 Runtime error in fontTools: KeyError: 'post' #492

Open
aik2mlj opened this issue Jan 19, 2025 · 10 comments
Open

v1.8.9 Runtime error in fontTools: KeyError: 'post' #492

aik2mlj opened this issue Jan 19, 2025 · 10 comments
Labels
bug Something isn't working

Comments

@aik2mlj
Copy link

aik2mlj commented Jan 19, 2025

问题描述

我用uv安装了最新版的pdf2zh

uv python install 3.12
uv tool install pdf2zh -p 3.12

在翻译特定文档时,虽然生成了翻译的pdf,但有报错显示:

../../../../../.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/pymupdf/__init__.py:276:exception_info(): exception_info:
../../../../../.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/pymupdf/__init__.py:277:exception_info(): Traceback (most recent call last):
  File "~/.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/pymupdf/utils.py", line 5698, in build_subset
    fts.main(args)
  File "~/.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/fontTools/misc/loggingTools.py", line 375, in wrapper
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "~/.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/fontTools/subset/__init__.py", line 3786, in main
    font = load_font(
           ^^^^^^^^^^
  File "~/.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/fontTools/misc/loggingTools.py", line 375, in wrapper
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "~/.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/fontTools/subset/__init__.py", line 3628, in load_font
    f = font["post"]
        ~~~~^^^^^^^^
  File "~/.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/fontTools/ttLib/ttFont.py", line 461, in __getitem__
    table = self._readTable(tag)
            ^^^^^^^^^^^^^^^^^^^^
  File "~/.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/fontTools/ttLib/ttFont.py", line 468, in _readTable
    data = self.reader[tag]
           ~~~~~~~~~~~^^^^^
  File "~/.local/share/uv/tools/pdf2zh/lib/python3.12/site-packages/fontTools/ttLib/sfnt.py", line 109, in __getitem__
    entry = self.tables[Tag(tag)]
            ~~~~~~~~~~~^^^^^^^^^^
KeyError: 'post'

测试文档

Schnupp Chapter 2 The Ear.pdf

@aik2mlj aik2mlj added the bug Something isn't working label Jan 19, 2025
@hellofinch
Copy link
Contributor

Image
我这里倒是能翻译没什么问题,除了figure好像是有些错位而已。

Schnupp.Chapter.2.The.Ear-mono.pdf
我这里只翻译了前五页。

@aik2mlj
Copy link
Author

aik2mlj commented Jan 20, 2025

是的,可以生成翻译文档,不过命令行使用有这个报错。

另一个相同报错案例:

pdf2zh https://arxiv.org/pdf/2307.10304

@hellofinch
Copy link
Contributor

是的,可以生成翻译文档,不过命令行使用有这个报错。

命令行使用什么?不太明白。

@aik2mlj
Copy link
Author

aik2mlj commented Jan 20, 2025

就是在终端使用pdf2zh,如:

pdf2zh "Schnupp Chapter 2 The Ear.pdf"

运行会有报错。
我尝试了在网页GUI中翻译,运行了pdf2zh -i的终端也会有相同报错。

@hellofinch
Copy link
Contributor

报错的话,为什么还能生成文档?

是的,可以生成翻译文档,不过命令行使用有这个报错。

@aik2mlj
Copy link
Author

aik2mlj commented Jan 20, 2025

这就不清楚了,也许可以忽略?您那边可以复现吗?

@hellofinch
Copy link
Contributor

我这没用过uv,不太清楚。

@hellofinch
Copy link
Contributor

@aik2mlj 你使用的操作系统是什么?MAC吗?

@aik2mlj
Copy link
Author

aik2mlj commented Jan 21, 2025

我用的是archlinux

@hellofinch
Copy link
Contributor

hellofinch commented Jan 21, 2025

我使用你提供的文档在windows下确实能够复现,但是没搞明白是为什么。
@timelic 需要帮助。
#499 应该也是相同的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants