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

IText.toSVG() does not fully support NUM_FRACTION_DIGITS #4656

Closed
willKo opened this issue Jan 30, 2018 · 0 comments · Fixed by #4674
Closed

IText.toSVG() does not fully support NUM_FRACTION_DIGITS #4656

willKo opened this issue Jan 30, 2018 · 0 comments · Fixed by #4674
Labels

Comments

@willKo
Copy link

willKo commented Jan 30, 2018

Version

1.7.14 and 1.7.20
(tested)

Problem Description

fabric.Object.NUM_FRACTION_DIGITS = *;
Does not apply to all Coordinates in generated SVG.
An IText Object loses precision on the level of character distances.

Is there another way to specifiy the fraction precision for Characters?

Generally it is not a big problem, but the precision could be higher.

JSFIDDLE

https://jsfiddle.net/u7z36378/7/

Steps to reproduce

Click toSVG button?

Expected Behavior

Precision of Character positions is is high as fabric.Object.NUM_FRACTION_DIGITS

Actual Behavior

Precision for Characters is always 2.
Higher precision could mean less difference between the browsers, when gernerating the svg.
Examples below (only the frist 3 characters)

Output Chrome:

<g transform="translate(146.57421875 23.1)">
<text xml:space="preserve" font-family="Times New Roman" font-size="40" font-weight="normal" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1; white-space: pre;" >
<tspan x="-146.07" y="12.6" font-size="20" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: ; opacity: 1; white-space: pre;">
M</tspan>
<tspan x="-128.29" y="12.6" font-size="28" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: ; opacity: 1; white-space: pre;">
y</tspan>
<tspan x="-114.29" y="12.6" font-size="28" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: ; opacity: 1; white-space: pre;">
G</tspan>

Output Firefox:

<g transform="translate(146.566665172577 23.1)">
<text xml:space="preserve" font-family="Times New Roman" font-size="40" font-weight="normal" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1; white-space: pre;" >
<tspan x="-146.07" y="12.6" font-size="20" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: ; opacity: 1; white-space: pre;">
M</tspan>
<tspan x="-128.28" y="12.6" font-size="28" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: ; opacity: 1; white-space: pre;">
y</tspan>
<tspan x="-114.28" y="12.6" font-size="28" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: ; opacity: 1; white-space: pre;">
G</tspan>

The different coordinates can be seen in the translate of the groups, as well as the position of some Characters.

Frist wrongly created in https://github.com/kangax/fabricjs.com/issues/203

@asturur asturur added the bug label Feb 4, 2018
@asturur asturur mentioned this issue Feb 4, 2018
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