-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Try out visibility:inherit default for text #990
Conversation
@@ -91,7 +91,7 @@ exports.convertToTspans = function(_context, _callback) { | |||
} | |||
_context.text('') | |||
.style({ | |||
visibility: 'visible', | |||
visibility: 'inherit', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitively the first step to take. 👍
My only concern here is possible incompatibilities in Illustrator and svg conversion tools (e.g. Batik).
To avoid any rolling 🎲 , I'm thinking about adding a few lines to the toSVG
routine making sure all exported images get visibility: 'visible'
as opposed to inherit
while interactive graphs would get 'inherit'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know about. That's the sort of obscure possibility for interaction that I thought maybe could exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to pull this fix wherever you need or redo it elsewhere. I won't worry further about it.
with *visibility: inherit* on SVG export
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good to me. I assume tspans
never have visibility set. I'm also assuming that there aren't other corner cases or obscure features that would cause potential issues.
var txt = d3.select(this); | ||
|
||
// hidden text is pre-formatting mathjax, | ||
// the browser ignores it but it can still confuse batik |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to make sense 👍
if(txt.style('visibility') === 'hidden') { | ||
txt.remove(); | ||
return; | ||
} | ||
else { | ||
// force other visibility value to export as visible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also makes sense. Presumably it overwrites visibility: inherit
(or anything that's not hidden
, for that matter), with visible
. Which seems correct.
textElements = svgDOM.getElementsByTagName('text'); | ||
|
||
for(var i = 0; i < textElements.length; i++) { | ||
expect(textElements[i].style.visibility).toEqual('visible'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good check. 👍
Kinda transferred ownership of this PR. Feel free to merge if you're content, otherwise let me know if further action is required. |
Thanks! |
See #984
The goal of this PR is to get circle-ci to see what happens if the visibility default on text is
visibility: inherit
instead ofvisibility: visible
.visible
hard-codes it and is difficult to override. I had an ominous feeling about this change leading to a rabbit hole of related fixes and compensations, but let's see what happens…