-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
loadSVGFromString issue with letter-spacing #5417
Comments
In my tests i get the following: - Since version 2.4.1 to 2.4.4:
In both cases we get NaN because we are doing maths with a variable fontSize that is a string. For this version i suggest changing to: - Since version 2.3.0 to 2.4.0:
|
Please note that i pointed Chrome as environment. |
The |
Now i'm not sure because i don't have access to my computer but I think that by doing console.log(fontSize) in normalizeValue() I Was getting 16px, which is fabric default in cases where fontSize is null, instead of 20px which is the value set in the svg. But maybe it happen in other case that i tried. I will confirm that.
Anyway, this situation doesn't happen in version 2.4.4.
However, in version 2.4.4 there is also a issue where using 'em' and the problem as to do with fontSize variable being a string instead of number.
No dia 08/12/2018, às 14:43, Andrea Bogazzi <notifications@github.com<mailto:notifications@github.com>> escreveu:
The px should be solved.
I'll take the reference of https://jsfiddle.net/rikkarv/98mc60ow/7/ (for version 2.4.4) and be sure is fixed.
I did not get exactly the comment about fontsie being 16 vs 20. Can you clarify more?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#5417 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AmlY_osLGsMG2YEOOm9jMxFupZeip3Zeks5u29AEgaJpZM4Y-9fe>.
|
I'm looking at changelog, and in version 2.4.1 there is commit 0a9466a that come from "fix letterspace parsing #5258" and i believe from issue #5192. |
that commit did fix svgs anyway, so probably the truth is in the middle. |
Thank you Andrea. Later or tomorrow i will see in detail your idea. However, i think the version before 2.4.1, was better. It seems that in those older versions the problem was not getting font-size when set inline in style attribute instead of font-size own attribute (like: style="font-size: 16px;"). Anyway, tomorrow i will you give notice of my tests in your pull request. Please note that in your pull request "fontSize = parseUnit(ownAttributes['font-size'], parentFontSize);" ignores parentFontSize if ownAttributes['font-size'] has 'px' unit (because it falls in default case) |
If it has I ll merge the code without publishing 2.4.5, let me know if you it still do not work. |
The picture above is some kind of output of the 'test/visual/assets/svg_text_letterspacing.svg' file? If so, you have to notice that the first text tag has font-size: 20px and letter-spacing: 20px which is equivalent to letter-spacing: 1em, right? So the letter-spacing of the first tag should be the double of the space compared to the second tag. In the third and fourth tag, the 'em' is relative to 16px default? Can you get the objects charSpacing property? |
well the visual test compares what fabric parse and render with what the browser rendered on the same svg, important is that match. |
I have already tested your changes and
is really doing his job. Now i have fontSize as a number instead of a string and the following maths doesn't break. Thank you very much for your effort |
so we are ready for 2.4.5
Il giorno lun 10 dic 2018 alle ore 14:20 Ricardo Carvalho <
notifications@github.com> ha scritto:
… I have already tested your changes and
ownAttributes['font-size'] = fontSize =
parseUnit(ownAttributes['font-size'], parentFontSize);
is really doing his job. Now i have fontSize as a number instead of a
string and the following maths doesn't break.
Thank you very much for your effort
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#5417 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABI4QJ_Y_34iKqcRWSjFwnDBFppFT42rks5u3l9_gaJpZM4Y-9fe>
.
|
Version
2.3.0 & 2.4.4
Test Case
https://jsfiddle.net/rikkarv/98mc60ow/8/ (for version 2.3.0)
https://jsfiddle.net/rikkarv/98mc60ow/7/ (for version 2.4.4)
Information about environment
chrome
Steps to reproduce
click on svg's (outline with dashed blue) and see output in fabric (outline with dashed red)
Expected Behavior
svg text should be imported to canvas with correct letter-spacing, despite the letter-spacing unit
Actual Behavior
If (fabric version 2.3.0) {
svg using letter-spacing value as "0.5em" works perfectly and outputs correct object.charSpacing value (500);
svg using letter-spacing value as "10" doesn't work and outputs a wrong object.charSpacing value (625);
} else if (fabric version 2.3.0) {
svg using letter-spacing value as "0.5em" doesn't work and outputs a wrong object.charSpacing value (0.5em);
svg using letter-spacing value as "10" doesn't work and outputs a wrong object.charSpacing value (10);
}
The text was updated successfully, but these errors were encountered: