Substitute for flowImage to inline images in text from extension

Discussion about writing code for Inkscape.
pelle
Posts: 46
Joined: Wed Mar 05, 2008 8:23 am

Substitute for flowImage to inline images in text from extension

Postby pelle » Wed Oct 26, 2016 5:59 pm

I want my extension (https://github.com/lifelike/countersheetsextension) to be able to insert images in flowing text. SVG 1.2 supports this by using flowImage elements together with flowPara. Inkscape however only supports flowPara. I googled and all I could find was a bug report for this from 2005 (https://bugs.launchpad.net/inkscape/+bug/171049).

It is probably not a trivial thing to add, so I am thinking of workarounds. One thing that might work is to insert a small flowPara with just a single glyph where I want the Image to be, write out the SVG to a temporary file, and then call "inkscape --query-id" on the temporary file to get the coordinates that glyph was rendered to, then insert the image there. That would probably work and I have been known to make more hideous hacks than that, but I hope there is something slightly better. Maybe if I can set a image pattern fill on a glyph and there is a good square-shaped glyph to use that could be inserted in the text and would look like an inserted image? But I tried to set a fill pattern on a flowPara and could not get it to work (Inkscape just deletes my fill-attribute, so I guess it is not supported and perhaps not allowed in SVG).

Other ideas?

User avatar
prkos
Posts: 1623
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Substitute for flowImage to inline images in text from extension

Postby prkos » Wed Oct 26, 2016 8:30 pm

Is it also in SVG 2?

Here is some more information about SVG support in Inkscape (scroll down to How does Inkscape implement SVG?)

Sounds like a very nice feature, to have flowed objects within text. Maybe a discussion on the developer mailing list would be more lively, have you tried there? Or the Inkscape IRC chat?
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

pelle
Posts: 46
Joined: Wed Mar 05, 2008 8:23 am

Re: Substitute for flowImage to inline images in text from extension

Postby pelle » Thu Oct 27, 2016 6:09 am

Yes, flow layout in SVG sounds useful (and Inkscape has at least partial support). Here is the description for SVG 1.2: https://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html. But no I can't find a mention for what the plan is for 2.0. Seems like flowImage is not included, or any of the other flow elements (including those used by Inkscape already)?

There is already the old bug report and I don't really have anything to add other than "me too". But I could use a workaround while waiting (no real plans to try to help out with Inkscape development at the moment).

pelle
Posts: 46
Joined: Wed Mar 05, 2008 8:23 am

Re: Substitute for flowImage to inline images in text from extension

Postby pelle » Thu Oct 27, 2016 6:13 am

OK, SVG 2.0 uses CSS to layout text in various shapes with automatic line-breaks. Looks better than the old flow-hacks, but unfortunately I do not see any mentions of support for inlining images there.

https://www.w3.org/TR/SVG2/text.html#Te ... ontentArea

User avatar
prkos
Posts: 1623
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Substitute for flowImage to inline images in text from extension

Postby prkos » Thu Oct 27, 2016 8:56 pm

That sounds good too.

But you'll get better information on the dev list, especially Tav who is on the SVG working group ;)
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

pelle
Posts: 46
Joined: Wed Mar 05, 2008 8:23 am

Re: Substitute for flowImage to inline images in text from extension

Postby pelle » Thu Mar 08, 2018 7:10 pm

I managed to come up with a work-around for this (less than two years after posting the original question!) by inserting a square unicode character in a tspan, then launch inkscape --queary-all to get the positions of all elements and look at what coordinates (and in what size) those squares ended up, and overlaying them with images.

It fails of course if the text is rotated. It also does not work for flowing text because for some reason flowSpans are not possible to query using inkscape. It works for single-line text-objects though, and that is better than nothing, even if it means I have to manually split up long text into multiple lines when I want to insert images.

https://www.boardgamegeek.com/article/28438456#28438456

Image

As you can see it is not perfect. The kerning looks a bit wrong in some places, and the exact vertical position can be improved to make them line up better with the text (I'm thinking of adding a way for the user to manually adjust that for each icon, because I do not think it will be possible to make it perfect automatically).

User avatar
prkos
Posts: 1623
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Substitute for flowImage to inline images in text from extension

Postby prkos » Fri Mar 09, 2018 12:21 am

Thank you for the update!

Can your extension be used for text editing or is it an overkill?

It would be nice to have some screenshots of the interface on your GitHub, it's hard to understand what it does by description alone, even if it is so detailed.
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

pelle
Posts: 46
Joined: Wed Mar 05, 2008 8:23 am

Re: Substitute for flowImage to inline images in text from extension

Postby pelle » Fri Mar 09, 2018 5:30 pm

I am not so good with presentation (marketing?) unfortunately.

Also need a video. Showing how to do a few things would help. Many struggle with just copying the two files into the Inkscape extensions folder. And then that they need to figure out the full path of the CSV file. After that it is easy enough to use, but the roadblocks comes first

I am better at just piling on new features. Since last night you can now use swatch names for fill and stroke colors (the extension looks them up in the SVG and creates the ugly url-things required) and front and backs of sheets can be generated together on the same layers ("pages").

Text edit I doubt. It can do bold and italics and inline images.

User avatar
prkos
Posts: 1623
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Substitute for flowImage to inline images in text from extension

Postby prkos » Sat Mar 10, 2018 1:42 am

Have you tried asking on GitHub and elsewhere for anyone who is into that subject to help out?

I don't think any of our Vectors Team people is familiar with countersheets and what it's supposed to do.

If you do catch some free time to do more work, put the "text centered in object" on your list :mrgreen:
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

pelle
Posts: 46
Joined: Wed Mar 05, 2008 8:23 am

Re: Substitute for flowImage to inline images in text from extension

Postby pelle » Sat Mar 10, 2018 8:38 am

Yes, finding someone else is a good idea. I understand how the text does not explain very well at all what it does.

Added scaling text to fit some other element to my TODO list for 2.2. I think one way is to add it as a keyword in the CSV header cell, and if enabled it will scale it to fit the boundaries of a surrounding group (so the text can be grouped with a circle for instance, to make the text fit inside of the bounding box of the circle... some margins have to be added of course). Oh well, there are a few more things I want to add before I start worrying too much about the details for that.

User avatar
prkos
Posts: 1623
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Substitute for flowImage to inline images in text from extension

Postby prkos » Sun Mar 11, 2018 7:15 am

Post here when you start working on it, I'd love to help with testing or concept if you need it and if I have time.

It would be great if this could be done as a separate extension, not related to csv. Then maybe you can use that extension as a dependency for your countersheets extension? But I don't know the insides, you'll know better.
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest