Can a layer of text be used as *clip mask*?

Asked by carmen fierro

I don't even know if my question makes sense,: please, be lenient!
My problem: I make a map or some other linear drawing, with my paths and objects arrayed in layers. On top, I add a text layer, with all the labels.
My question: is there some way to hide the parts of the underlaying layers that fall under the text objects (or, preferably, their bounding boxes)?
So far, I haven't found one--my last resource, to preserve transparency in the svg, being to break the paths and delete the segments under the text... which doesn't seem to be the thing.
Thanks!

Question information

Language:
English Edit question
Status:
Expired
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Hachmann (marenhachmann) said :
#1

Hi Carmen,

does this need to be a real cut-out (i.e. do you need this for cutting, plotting, exporting to vector pdf), or would a filter suffice (usage for export to png, web browsers that support the filter)?

For the filter version, there's this:
https://inkscape.org/sk/~jabiertxof/%E2%98%85eraser-layer

For cutting out multiple objects at once, I'd go with this:
https://gitlab.com/su-v/inx-pathops

Kind Regards,
 Maren

Revision history for this message
Hachmann (marenhachmann) said :
#2

And for creating the cookie-cutter shapes, I'd duplicate the texts, add a large stroke, convert text to path, ungroup, convert stroke to path, then do union.

You can select all text objects by right-clicking on one of them, then do 'Select same' -> 'Object type'.

Revision history for this message
Hachmann (marenhachmann) said :
#3

(You would only need to do this for the cutting out version. For the eraser layer, you could use clones of the texts with a large stroke. Then they will automatically adapt when you edit the text.)

Revision history for this message
carmen fierro (cfierrob) said :
#4

Thanks: looked at downloaded both extensions, although I suspect at first
sight they won't meet my need.
I chiefly use Inscape to edit maps, plans and diagrams for my (customized)
epubs:
- maps I usually export as optimized svg, and thus include in the
epub--wishing the map to be STRETCHABLE as far the viewer will allow,
- plans or drawings with less information, can get exported to png for
inclusion.
Any road, I like my Inkscape svg to be something like an xcf for Gimp,
i.e., chiefly to edit and export: thus, I would like the paths which I must
now cut out of the way of text, to be kept as originally drawn (in my
experience so far, a path cut between nodes and with same nodes relinked is
never the same--a bore when one has to modify). Thus, hide the segment--but
the only way I have found to do it is to actually paint something else on
top--maybe my own lack of understanding?
Thanks!

Carmen

2017-05-21 17:13 GMT+02:00 Hachmann <email address hidden>:

> Your question #633481 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/633481
>
> Status: Open => Answered
>
> Hachmann proposed the following answer:
> Hi Carmen,
>
> does this need to be a real cut-out (i.e. do you need this for cutting,
> plotting, exporting to vector pdf), or would a filter suffice (usage for
> export to png, web browsers that support the filter)?
>
> For the filter version, there's this:
> https://inkscape.org/sk/~jabiertxof/%E2%98%85eraser-layer
>
> For cutting out multiple objects at once, I'd go with this:
> https://gitlab.com/su-v/inx-pathops
>
> Kind Regards,
> Maren
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/inkscape/+question/633481/+
> confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/inkscape/+question/633481
>
> You received this question notification because you asked the question.
>

Revision history for this message
carmen fierro (cfierrob) said :
#5

By your last comment, maybe the eraser layer is JUST IT.
Thanks again.

Carmen

2017-05-21 17:23 GMT+02:00 Hachmann <email address hidden>:

> Your question #633481 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/633481
>
> Hachmann posted a new comment:
> (You would only need to do this for the cutting out version. For the
> eraser layer, you could use clones of the texts with a large stroke.
> Then they will automatically adapt when you edit the text.)
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
Hachmann (marenhachmann) said :
#6

You'll need to try it out, though. If the filter isn't supported by the renderers that will be used, it won't work.

Another option (with mask):

You could still try it with the clones, and use a group that they are in as a mask (could even be a clone, then you can still see and edit the original) - but these can cause issues, too....

See an example here:
(you can edit the contents of the text that is outside of the page area, but not the other texts' contents. Added background color, so you can see it's transparent)
 https://framadrive.org/s/Dg8wKn6IFJ46OGP

Revision history for this message
carmen fierro (cfierrob) said :
#7

Thanks! Your example file has finally taught me how to make a mask--after
referring several times to the manual, I HADN'T CAUGHT ON THE ABSOLUTE NEED
TO ADD A WHITE BACKGROUND TO THE BLACK MASKING OBJECT. My fault!
About the masking text:
* Apparently, to give the text clones a nice thick border, the stroke must
be added to the original text, leaving stroke colour unset--at least, I
couldn't make any headway with my original settings of text: stroke unset
0px.
* I had some trouble with mask.svg: selecting a text clone and opening
Fill&Stroke tab to study your settings unset everything. Solution: make a
copy, and before trying the Fill&Stroke tab, change all text from its
ubuntu font to one installed in my system--Inkscape warned of a
substitution being made on opening, but that lead to aforesaid trouble.
* I have encountered other troubles with said automatic substitution of
fonts, i.e., working on my .svg file with 'font:sans-serif' (left to
renderer to choose), and changing to 'font:corbel' (installed) all the bits
in italics--automatically substitud from sans-serif to verdana--reverted to
normal.
* This leads to another question: IS THERE SOME WAY TO TELL INKSCAPE WHICH
FONT SHOULD BE USED INTERNALLY TO REPRESENT GENERIC 'sans-serif'? As of
now, it seems to pick 'system default', which I haven't been to determine
in this Windows version, but is apparently one of 'Microsoft
almost-monospace fonts' used mainly for system dialogs, without italics,
bold... Most of my installed programs with text-editing abilities (not the
Gimp, though!) allow you to choose a decent font as default
instead--WITHOUT usetting the generic 'font-family:sans-serif' in HTML
code. CAN SUCH BE MADE IN INKSCAPE, perhaps editing by hand some
configuration file?
Thanks again.

Carmen

2017-05-21 20:38 GMT+02:00 Hachmann <email address hidden>:

> Your question #633481 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/633481
>
> Hachmann posted a new comment:
> You'll need to try it out, though. If the filter isn't supported by the
> renderers that will be used, it won't work.
>
> Another option (with mask):
>
> You could still try it with the clones, and use a group that they are in
> as a mask (could even be a clone, then you can still see and edit the
> original) - but these can cause issues, too....
>
> See an example here:
> (you can edit the contents of the text that is outside of the page area,
> but not the other texts' contents. Added background color, so you can see
> it's transparent)
> https://framadrive.org/s/Dg8wKn6IFJ46OGP
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
Hachmann (marenhachmann) said :
#8

Hi Carmen,

ad 1.) yes, you got it! (unset stroke / fill on original, so it won't be inherited by its clones)

ad 2.) I cannot reproduce, even after editing the SVG to use an invalid font. I'm not sure what happened.... Would you like to investigate? Maybe do a step-by-step instruction?

ad 3.) This could be a bug, too. I take it that Corbel has an italic style variant? I was able to reproduce with a different font. Would you mind taking a look into the bug reports section (https://bugs.launchpad.net/inkscape)? Searching for 'font style' and 'change font', maybe? If you can't find a bug that describes the issue, you can create a new one. Don't forget to make sure you're subscribed to it, and also attach an example file and mention Inkscape version + Operating system. This will make it easier to investigate for the bug people.

ad 4.) No, there isn't, at the moment. This is being decided by the font backend, which decides it on the grounds of what the operating system tells it to use - just as you found out. However, as far as I know, this is a known issue, and there has already been some talk about it. I bet there's already a report for it.

Kind Regards,
 Maren

Revision history for this message
carmen fierro (cfierrob) said :
#9

For 2), the following steps launch the problem for me:
- open mask.svg AND GET WARNING ON FONT SUBSTITUTION
- select group of white rectangle and text clone on the
left-->control+click to select text clone + open Fill&Stroke tab:
everything normal so far *
- shift+d to jump to original text: STROKE OF CLONES DISAPPEARS EVERYWHERE
**.
- The undo history:
  [Unchanged]
  Update Document
+ Set stroke (I made no changes, only looked!--stroke width some 40px) *
        Set stroke (I made no changes, only looked!--stroke width some
1,6px) **
On (**) drawing changed; back to (*) changed back. Exit without saving: the
same problem on opening again.
Maybe is normal for clones to change this way? BUT same steps in my copy,
saved with font changed to corbel (no warnings on opening, neither 'Update
Document' in undo history, nor reports on changed strokes) doesn't
reproduce it...

It seems that unless one can make a generic family like 'sans-serif' work
without updating the document, Inkscape svg files won't be cross-system
portable...
I have attached in zip file both your mask.svg and my changed copy
mask1.svg, just in case it helps.
Kind regards,
Carmen

Carmen

2017-05-23 14:18 GMT+02:00 Hachmann <email address hidden>:

> Your question #633481 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/633481
>
> Hachmann posted a new comment:
> Hi Carmen,
>
> ad 1.) yes, you got it! (unset stroke / fill on original, so it won't be
> inherited by its clones)
>
> ad 2.) I cannot reproduce, even after editing the SVG to use an invalid
> font. I'm not sure what happened.... Would you like to investigate?
> Maybe do a step-by-step instruction?
>
> ad 3.) This could be a bug, too. I take it that Corbel has an italic
> style variant? I was able to reproduce with a different font. Would you
> mind taking a look into the bug reports section
> (https://bugs.launchpad.net/inkscape)? Searching for 'font style' and
> 'change font', maybe? If you can't find a bug that describes the issue,
> you can create a new one. Don't forget to make sure you're subscribed to
> it, and also attach an example file and mention Inkscape version +
> Operating system. This will make it easier to investigate for the bug
> people.
>
> ad 4.) No, there isn't, at the moment. This is being decided by the font
> backend, which decides it on the grounds of what the operating system
> tells it to use - just as you found out. However, as far as I know, this
> is a known issue, and there has already been some talk about it. I bet
> there's already a report for it.
>
> Kind Regards,
> Maren
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
Hachmann (marenhachmann) said :
#10

Hi Carmen,

attachments do not work here, you need to upload to a file hoster or some other online service and post a link.

I kind of was able to reproduce this. But it required a click into the 'width' field in the Fill and Stroke dialog, stroke tab. If I don't click there, this will not happen.

The reason is then, that the 'Shift+d' is entered into the 'width' field as 'D' - and this is an invalid value. Invalid values are interpreted as '1'.
Then it becomes 1.067, because of the unit change in Inkscape 0.92.
(Btw. are the texts all vertical for you, too?... I created this file in 0.91, and upon opening with 0.92.1, text is turned around by 90°... :-/).

Are you sure you did not click into the width field in the Fill+Stroke dialog?

Kind Regards,
 Maren

Revision history for this message
carmen fierro (cfierrob) said :
#11

Hi, Maren
* No, I have just reproduced the effect as follows:
 - Open file with warning: all texts in ubuntu selected--i.e., all
 - Click somewhwere to deselect them
 - Click on example mask on left, CTRL+click on text text clone
 - SHIFT+d to select original text
 - Open Fill&Stroke, select Stroke style tab: width said 0px (nothing done
but look)
 - Now swich to Stroke paint ... AND STROKES DISAPPEARED
 - Undo History tells me that I have changed stroke style--which I haven't,
by any act of my own--though it has changed to 1.067px...??
 - In other contexts, I have meet system/program-dependent quirks with
things getting selected ONFOCUS versus ONCLICK--used to be one of the mayor
browser-compatibilty issues...
 * All texts are vertical for me, sure enough--it kept me wondering for a
reason why (-;
 * However, with the original text still selected, I have opened Text&Font,
and in the Font tab, I find the icon for 'vertical text' chosen. I thought
of this because in 0.91 I once pressed it, thinking that it would rotate
text--which it didn't. In fact, it appeared to do nothing at all--which
some time later created some problem or other (rotated text in svg wieved
in browser, I think), because I had left it pressed, and when using the
text tool, it usually disappears at the right end of my toolbar, having to
press 'more...' to see it...
Regards
Carmen

Carmen

2017-05-25 19:47 GMT+02:00 Hachmann <email address hidden>:

> Your question #633481 on Inkscape changed:
> https://answers.launchpad.net/inkscape/+question/633481
>
> Hachmann posted a new comment:
> Hi Carmen,
>
> attachments do not work here, you need to upload to a file hoster or
> some other online service and post a link.
>
> I kind of was able to reproduce this. But it required a click into the
> 'width' field in the Fill and Stroke dialog, stroke tab. If I don't
> click there, this will not happen.
>
> The reason is then, that the 'Shift+d' is entered into the 'width' field
> as 'D' - and this is an invalid value. Invalid values are interpreted as
> '1'.
> Then it becomes 1.067, because of the unit change in Inkscape 0.92.
> (Btw. are the texts all vertical for you, too?... I created this file in
> 0.91, and upon opening with 0.92.1, text is turned around by 90°... :-/).
>
> Are you sure you did not click into the width field in the Fill+Stroke
> dialog?
>
> Kind Regards,
> Maren
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
Hachmann (marenhachmann) said :
#12

Hi Carmen,

sorry about not getting back to you sooner. I think you've really discovered a bug here, and also made a very good description of it (the order in which I did things was different before).

I just tested with Inkscape development version (rev 15698), and it reproduces there, too.
I was not able to create another file that exposes the issue (but another one, maybe related, with the strokes of the clone resizing strangely when resizing the original... :-/).

It also happens when you resize the original text. It doesn't matter then whether the fill+stroke dialog is open.

A (very quick) search among the known bugs didn't reveal that this is a known issue.

Would you like to file a bug report yourself? You can attach my example image.

Kind Regards,
 Maren

Revision history for this message
Launchpad Janitor (janitor) said :
#13

This question was expired because it remained in the 'Open' state without activity for the last 15 days.