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

Fix char spacing bug in SVG mode #8340

Merged
merged 1 commit into from
May 5, 2017

Conversation

ydfzgyj
Copy link
Contributor

@ydfzgyj ydfzgyj commented Apr 27, 2017

When use svg mode, a word which first char is blank won't get accurate position. Because canvas mode renders well, I compared code between them and found some code in svg mode was too old. I just modify the code which make my pdf looks bad, but I'm not sure there's any other bugs in other condition like font.vertical = true. Nevertheless, this PR won't trigger any new problems.

Here's my example

  • Former
    former
  • After
    after

@yurydelendik
Copy link
Contributor

We need a test case or sample pdf to investigate and confirm the fix.

@ydfzgyj
Copy link
Contributor Author

ydfzgyj commented May 1, 2017

@yurydelendik
Copy link
Contributor

It's hard to understand the fix. Can you explain it in terms of SVG and PDF32000 specs?

@@ -689,14 +689,16 @@ SVGGraphics = (function SVGGraphicsClosure() {
x += -glyph * fontSize * 0.001;
continue;
}
current.xcoords.push(current.x + x * textHScale);
var character = glyph.fontChar;
if (character !== ' ') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if character == ' ' it does not mean it's "empty", glyph can still display something.

@ydfzgyj
Copy link
Contributor Author

ydfzgyj commented May 4, 2017

@yurydelendik I was just thinking that these blanks had no effect on the display... minify svg should actually be done in my own project rather than in pdf.js, I have removed this part of code

@timvandermeij
Copy link
Contributor

Looks better. Could you squash the two commits into one (see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits)?

@ydfzgyj ydfzgyj force-pushed the fix-svg-spacing branch from 93231fe to d58040a Compare May 5, 2017 04:14
@yurydelendik yurydelendik merged commit c3cfcbe into mozilla:master May 5, 2017
@yurydelendik
Copy link
Contributor

Thank you for the patch.

@ydfzgyj ydfzgyj deleted the fix-svg-spacing branch May 8, 2017 05:10
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants