insert_text insert_textbox and annotation's insert_free_text both hit a space, and the next word goes out of the area and breaks the line, but Chinese has no spaces, which leads to a single space, and then a sentence following it is treated as a word. #3372
-
Description of the bugsample: result: How to reproduce the bugWhat is actually expected is: PyMuPDF version1.24.1 Operating systemMacOS Python version3.10 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Whether to consider an additional parameter or option, whether to hit a space for a newline |
Beta Was this translation helpful? Give feedback.
-
This is no issue, but a Discussionsitem. |
Beta Was this translation helpful? Give feedback.
-
Well, why do you say the separation should happen as you indicate? There either is a space in the text or not. You must become active here:
|
Beta Was this translation helpful? Give feedback.
Well, why do you say the separation should happen as you indicate? There either is a space in the text or not.
If there is, then it will be used for line breaks when necessary.
Otherwise, the text is treated like a word with a length exceeding the rectangle width and it will be split as required at an arbitrary point.
There is no way to avoid this.
You must become active here:
insert_textbox
is not usable for, then useinsert_text
instead, based on your knowing better when to start a new line. UseFont.tength_length
to find the length of a given string. As Chinese text is monospaced, you should easily be able to compute the right spots where to start a new line.