sioyek-python-extensions icon indicating copy to clipboard operation
sioyek-python-extensions copied to clipboard

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

Open wenbopeng opened this issue 2 years ago • 6 comments

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

image

image

wenbopeng avatar Feb 11 '23 06:02 wenbopeng

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.

ahrm avatar Feb 18 '23 15:02 ahrm

Ok, wish add_text to be able to automatically wrap

wenbopeng avatar Feb 19 '23 01:02 wenbopeng

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

ahrm avatar Feb 19 '23 09:02 ahrm

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 avatar Mar 07 '23 03:03 wenbopeng

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 avatar Mar 07 '23 03:03 wenbopeng

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

wenbopeng avatar May 24 '23 08:05 wenbopeng