Skip to content
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

Idea: Create font to match PDF font's width #1914

Closed
jviereck opened this issue Jul 20, 2012 · 5 comments
Closed

Idea: Create font to match PDF font's width #1914

jviereck opened this issue Jul 20, 2012 · 5 comments
Assignees
Labels

Comments

@jviereck
Copy link
Contributor

Problem: Right now, the text layer doesn't use the same font as the font we use for rendering the actual text. To make sure the text selection goes more or less the right way, we make sure the width of the total text in the div layer matches the width of the text that is rendered to the canvas. However, as the fonts use different spaces for characters, there is some miss-alignment for selection in the middle of the font.

Idea: If I understood it right, the font width is specified in the font-table somewhere. Could we use some open-source font, load it and replace the default font-width table by exactly the same widths used for the font that is printed.

The problem here might be, that there are multiple glyphs for a single character. In this case, we might want to use the average of the two glyphs widths for the corresponding character in the text-div font.

Also, the text-div font is never visible. Therefore, it could be a "very simple font", that has only a single line for each character. This makes the overhead to load an extra font for each font loaded in the PDF maybe not that much dramatic. Also, we wouldn't have to adjust the div layer anymore in the case we recognize that the glyphs used only have a direct mapping between glyph <-> character. If there are two glyphs mapping to the same character, the width might still need to be adjusted.

What do you think?

@yurydelendik
Copy link
Contributor

Is it still an issue or right way to solve a problem?

@jviereck
Copy link
Contributor Author

There are still cases where the text in the textLayer doesn't match with the rendered text. Therefore, I think the core problem I try to solve with this idea still exists.

Is this the right way to solve the problem? I don't know. We could also create more divs for cases where we detect a mismatch between the rendered font and the textLayer font. However, detect this mismatch, calculate new slits and get it right especially in an RTL context might be tricky.

@ghost ghost assigned jviereck Nov 10, 2012
@waddlesplash
Copy link
Contributor

Since you convert the font to WOFF to use it in the PDF, why not have the textLayer use the same font?

@jviereck
Copy link
Contributor Author

Since you convert the font to WOFF to use it in the PDF, why not have the textLayer use the same font?

The font might have two glyphs for the same characters. E.g. the character "A" might be represented twice inside a font. This is common for arabic fonts. There are also other issues as well.

@Snuffleupagus
Copy link
Collaborator

Given that no work has happened on this for almost nine years, let's close it as WONTFIX for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants