Tuesday, July 2, 2019

Inkscape for cartography: fill the background of a text


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.




Answer



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.


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...