-
-
Notifications
You must be signed in to change notification settings - Fork 634
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
page.drawText() inserts spaces when using Thai font #1010
Comments
I also face this problem. I guess the bug is in UnicodeLayoutEngine class in @pdf-lib/fontkit lib. |
for me the same with many fonts |
@tudor-sandu, is this the issue you guys are experiencing? |
same here with |
(for Thai font) the issue can be resolved when we use |
The effect in the first post is some bytes added to text outside of valid space for the charset. In PDF if there is no character for that byte-sequence (utf8 is multi-byte with variable length), a reader renders it as a space. While when you copy the text, the actual data with the added bytes is copied and when you paste it in a program that renders non-valid/non-printable "chars" as those "glyphs" (the squares in first post), displaying the data as hex (for example 10F0C1), instead of rendered a space. Also all the examples and my case does not seem like the font just does not have proper glyph for a character. I also excluded, that some non-printable bytes in the source beforehand. Its being added when rendering the pdf. https://unicode-table.com/en/search/?q=10F0C1 https://www.unicode.org/charts/PDF/U100000.pdf
|
This solution is work for font Khmer also. |
Try the following It definitely is a bug and in my opinion is an issue that should be fixed: #490 |
This solution also works for Calibri fonts |
What were you trying to do?
I am trying to use the page.drawText() function to render text in the Thai language
Why were you trying to do this?
To build an application that creates PDF files containing text written in the Thai language
How did you attempt to do it?
The steps I followed are:
See code example provided in reproduction steps section below.
What actually happened?
The PDF file was successfully created but it seems some large spaces have been inserted into the Thai text in the PDF.
I've copied the text from the PDF and pasted below, notice the strange block characters which have been inserted.
Those strange characters appear visually as large blank spaces in the PDF e.g like this:
What did you expect to happen?
I expected the Thai text to be rendered as one continuous string without any strange characters or spaces inserted:
How can we reproduce the issue?
node index.js
which will create the PDF file containing some Thai textVersion
1.16.0
What environment are you running pdf-lib in?
Node
Required Reading
Additional Notes
No response
The text was updated successfully, but these errors were encountered: