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

SVG Export for Textbox loses style on the 2nd line, and other issues #2829

Closed
jtweku opened this issue Mar 11, 2016 · 7 comments · Fixed by #2853
Closed

SVG Export for Textbox loses style on the 2nd line, and other issues #2829

jtweku opened this issue Mar 11, 2016 · 7 comments · Fixed by #2853
Assignees
Labels

Comments

@jtweku
Copy link

jtweku commented Mar 11, 2016

Version

1.6.0

Test Case

http://jsfiddle.net/jtweku/cdjth9k4/2/

there are 3 issues all with the second textbox,

  1. the second textbox lost the formatting after the first line when exporting to SVG.
  2. space should not be there on the first beginning of the second line.
  3. did you notice that the last character ('x') on the second line is not Bold, I use selectAll when applying style, unless Im not doing it right.

Expected Behavior

I have a fix for the svg export, remove the commented line of the code to see the correct behaviour
_setSVGTextLineChars in the IText class should use the _getStyleDeclaration (because it is overridden in the Textbox class)

@asturur
Copy link
Member

asturur commented Mar 11, 2016

Case 1 has been solved by a recent PR. Case 2 has been reported already .

Case 3 we are going to check what is happening.

@jtweku
Copy link
Author

jtweku commented Mar 11, 2016

@asturur, do you have the PR number ?
I don't see the PR for fixing the _setSVGTextLineText to use the internal _styleMap in the textbox class. or it might be fix somewhere else ?

Thanks

@asturur
Copy link
Member

asturur commented Mar 12, 2016

#2780 and pr #2790 correct me if i m wrong

@jtweku
Copy link
Author

jtweku commented Mar 12, 2016

Don't you still need to override the _setSVGTextLineText because the text is auto wrap and the _lines still have 1 length and not 2? Otherwise it will use default the styles for the textbox.

https://jsfiddle.net/jtweku/cdjth9k4/1/

Maybe another solution is to create a private method _hasStyle(linenumber) to indicate if line has style in IText and override in Textbox class and use it in checking if the line has any styling in _setSVGTextLineText ?

@asturur
Copy link
Member

asturur commented Mar 12, 2016

Ok i thought it was same issue. I will check also this one then.

@asturur asturur self-assigned this Mar 15, 2016
@asturur
Copy link
Member

asturur commented Mar 26, 2016

case 2 solved

@asturur asturur added the text label Mar 26, 2016
@asturur asturur mentioned this issue Mar 26, 2016
@asturur
Copy link
Member

asturur commented Mar 26, 2016

@jtweku check solution proposed in #2853, it should fix the issue.

About your proposed solution:
checking "this._styleMap[lineIndex]" with the iText class should produce an error ( did not test ) because iText does not have _styleMap.
Putting "this._styleMap && this._styleMap[lineIndex]" would not save us because iText does not have styleMap but can have styles[lineIndex].

It should be something like

this.styles[lineIndex] || (this._styleMap && this._styleMap[lineIndex]) that reads less nicely over this.hasStyleOnLine(lineIndex) in my opinion.

If you are experimenting with styled textboxes i would like you to test this solution because currently i do not have time.

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

Successfully merging a pull request may close this issue.

2 participants