-
Notifications
You must be signed in to change notification settings - Fork 12
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
Made text elements optionally allowed #289
Conversation
src/picosvg/svg.py
Outdated
|
||
self._update_etree() | ||
|
||
for el in self.xpath("//*[name()='text']"): |
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.
I don't understand why SVGs don't allow me to use xpath to find "//text", but according to random bloggers on the web this is the way to do it instead.
maybe we don't need to add a self.allow_text attribute, how about just add an also, maybe the command line tool could have an additional flag to control that. It's defined in this module |
In general, I think we both agree that by default picosvg should not silently drop text elements but raise an error if these are present and the user didn't explicitly request to drop them. And then, it could have an optional mode where one decides to intentionally |
the title "Added optional support for text elements" may be misunderstood as saying 'picosvg can now simplify/convert text elements to paths' but actually here we are additing support for dropping them, I suggest you reword the PR title accordingly |
actually wait... I got a bit confused. I think what you want for your use case (from our private conversation) is to retain the text elements as they are, so you just need a way to tell picosvg to not raise an error if they are there. You don't need/want to remove them, and neither we do want to simply remove them. Eventually, one day we may wish to add support for transforming the text to outlines. So I think we don't need to have a remove_text method at all. We only need a way to allow the text in (with a parameter to |
technically we could also add support for removing text elements as in deleting them (not in the good sense of converting them to path which we haven't implemented yet), but what purpose would that serve, I'm not sure of its utility. Unlinke comments or other metadata, the text elements are proper data and picosvg in general doesn't offer ways to "remove this or that". It tries to retain the essence/visual appearance of the original svg while simplifying it's formatting. |
Alright, I believe the best suggestion is to just pass an I updated the PR. WDYT? |
Note that I still kept the |
ok, thanks, looks good that way. |
also please edit the first message (PR description) as it's no longer in sync with the changes, thanks! |
- Added `allow_text` options to both `topicosvg()` and `checkpicosvg()` to enable simplifying SVGs with text elements. Note that the text elements will not be converted to paths, they will only pass through. - Added an `allow_text` boolean flag to the command line tool to control this behaviour.
Ah, good catch, thanks. Also, I updated the command line tool. |
Thanks |
allow_text
options to bothtopicosvg()
andcheckpicosvg()
to enable simplifying SVGs with text elements. Note that the text elements will not be converted to paths, they will only pass through.allow_text
boolean flag to the command line tool to control this behaviour.