ahrm / sioyek-python-extensions

Python wrapper and simple addons for sioyek PDF viewer
GNU General Public License v3.0
164 stars 7 forks source link

[Bug]-add_text: Some characters will be hidden if using Simplified Chinese, but it is normal to use Traditional Chinese #5

Open wenbopeng opened 1 year ago

wenbopeng commented 1 year ago

If you use Simplified Chinese, some characters will be hidden(fig1), but it is normal to use Traditional Chinese(fig2)

image

image

ahrm commented 1 year ago

I am not familiar enough with Chinese to know what the problem is exactly, but I assume the issue is with add_freetext_annot which is a pymupdf function. I can't really fix that.

wenbopeng commented 1 year ago

Ok, wish add_text to be able to automatically wrap

ahrm commented 1 year ago

It can (at least for english text), again, it is not something that I imlemented. It is part of add_freetext_annot.

wenbopeng commented 1 year ago

I upgraded Windows and solved the problem. I suspected it was a font issue. Now everything is perfect. Thank you. I will close this issue.

wenbopeng commented 1 year ago

It can (at least for english text), again, it is not something that I imlemented. It is part of .add_freetext_annot

PyMuPDF-Utilities/freetext-annot-lang.py at master · pymupdf/PyMuPDF-Utilities, 2023-03-07 11:34

Might be helpful to fix fonts and text wrap in different languages

wenbopeng commented 1 year ago

It can (at least for english text), again, it is not something that I imlemented. It is part of add_freetext_annot.

Here are the commands for the sioyek add-text extension:

new_command _add_red_text python -m sioyek.add_text "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" "%{selected_rect}" "%{command_text}" fontsize=12 text_color=255,0,0

This is the add_freetext_annot function that sets the font , see Page - PyMuPDF 1.22.3 documentation :

add_freetext_annot(rect, text, fontsize=12, fontname='helv', border_color=None, text_color=0, fill_color=1, rotate=0, align=TEXT_ALIGN_LEFT)

Can you refer to this function and add a fontname command for the add-text extension? It supports Chinese, see Does it support inserting Chinese text? · Issue #329 · pymupdf/PyMuPDF