I want to produce a geographic map with Inkscape. I have cities with names. I mean I have dozens of city names. I want to fill the background of cities names with a semi transparent background so that texts are readable despite colors and lines etc. on the map.


Since there is no background attribute in a text object in SVG, you'd need to use another method, such as drawing a filled rectangle under the text, however as you say that's inconvenient as you'd have to resize the rectangle every time you type a name that's shorter or longer.

One method is to use an SVG filter applied to some text to create a box around the text which you can then fill. In this example, I used the Cutout Glow filter, and modified the settings of the filter using the Filter Editor.

Here are the steps for setting it up.

  1. Type some text, and make sure the text object is selected
  2. Click Filters > Shadows and Glows > Cutout Glow Filter
  3. Click Filters > Filter Editor and change the settings as follows:

Offset: Set Delta X and Y to -100

Gaussian Blur: 0.01 (this is the lowest possible setting)

Flood: select any colour and opacity as required

Composite - Operator: Destination over

You can also adjust the positioning of the text within and the size of the box by going back into the Offset settings, and click on the Filter General Settings tab, where you can change the Co-ordinates and Dimensions as required.

To use it on your map, copy (Ctrl+C) the filtered text object and paste (Ctrl+V) where every city should be, and then simply edit the text for each. The box will fit to the text automatically.

enter image description here

Note: You can change the text colour itself as you normally would by highlighting the text with the text tool, and changing the fill colour of the text object in the Fill and Stroke panel.

  • Obviously the screen capture would have been better if I had spelt Newcastle properly (one word, not two)! – Billy Kerr Feb 12 '19 at 10:43
  • 1
    when you type a very long text with this produces a very large box, much too large, what is the parameter to adjust for a more adjusted box? – the world is not flat Feb 13 '19 at 11:29
  • @theworldisnotflat I already mentioned how to change the box dimensions in my answer. – Billy Kerr Feb 13 '19 at 11:31
  • Sorry, but if a word has 1 letter and another has 10 letters when for longer word box stretches far to the right and applying your method makes both boxes increase proportionally. – Yola Jun 28 '19 at 6:56
  • Maybe I'm doing something wrong, but for me this changes the colour of the text not the background – Tom Jan 8 at 15:00

You can draw a rectangle with your semi-transparent fill color. Then you select the text plus the rectangle, and go to Text -> Flow into frame (Alt-W).

This will place your text inside the rectangle (or whatever shape you like).

Manual here.

  • Ok tried but not convenient because (1) frame has to be adjusted manually to text length, and (2) the adjustement must be repeated for each city name – the world is not flat Feb 12 '19 at 0:18
  • ... and 3.) flowed text only shows up in Inkscape (currently). – Moini Feb 12 '19 at 14:57

This is a good start, but works better if you disable all except Flood and Composite. Composite->Filter General Settings will adjust the location and size of the box in relation to the text. Composite->Effect Parameters set to Destination Over will ensure your text color isn't messed with by the background color you choose.

This is great and all, but totally fails if you need to rotate the text.

  • 1
    are you adding an answer or is this a comment to one of the other answers? Check the tour if you have any doubts – Luciano Jan 24 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.