-
Notifications
You must be signed in to change notification settings - Fork 232
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
Generate an empty line if one long line begin with some spaces #649
Comments
Thank you for opening this issue @CY-Qiu 😃 However, I'm not sure that this is really a bug with Users can call pdf.multi_cell(w=150, txt=text.strip(), border=1, fill=False, split_only=False) |
The reason I add some spaces is I need indentation. |
Oh OK, I initially misunderstood... Ping @gmischler as I think you have more expertise regarding this than myself 😃 Do you think that |
An interesting case! The reason for the current behaviour is in the "line wrapping by word" algorithm, which assumes that words are seperated by space characters. In our case here, the supplied "word" does not fit on one line, so The most correct solution would be for fpdf2 to offer an alternative "line wrapping by character" algorithm. I don't think that would be very hard to implement (just skip the space and hyphen hinting), but we need to think a bit about what the best API for that would be.
Of course it should. The task of fpdf2 is to render the characters supplied by the client code, and not to alter them (unless explicitly specified). And that is exactly what happens here too: Those space characters are represented by the initial empty line. If the rest of the text was short enough to fit that line, it would continue right after that indent as expected. On the other hand: Is ist a good idea to use space characters for a first-line indent? |
Error details
![image](https://user-images.githubusercontent.com/23075447/209785612-28622b57-9bf1-44e6-b52e-ebbc6dbba2d7.png)
![image](https://user-images.githubusercontent.com/23075447/209785817-951806c8-844e-4281-b205-52b74841cb70.png)
Generate an empty line if one long line begin with some spaces.
This is the current output:
This is what we want:
Minimal code
Environment
fpdf2
version used: 2.6.0I checked the code, it seems that
line_break.py
needs some changes to make the spaces in the beginning of one line being ignored.The text was updated successfully, but these errors were encountered: