I’ve talked about it before. People who make SVG images do not correctly enter their text in their SVG editor. Result: The text does not appear or in the wrong place (Figure 1). If you then analyze the problem in the Inkscape program, you will see how bad the text has been entered (Figure 2).
That’s no problem at all if an image contains 4 text objects. But if there are 32 text objects in the text, re-typing all of this text in Inkscape will be far too much work. However, the text is already in the code. Only the code is incorrect so the text is displayed incorrectly.
I have been looking for a solution to this problem for quite some time. The problem can be divided into two sub-issues:
1. A method of extracting text quickly from an XML file.
2. A method to put this text as a whole into the old file, but embedded in the correct code. This text will appear in Inkscape, but not in the correct place. This should then be dragged to the right place and then aligned.
With the text editor Vim, you can quickly extract text from an XML file. This can be done using a macro. I will not discuss it here.
I’ve solved problem 2 with some Perl code. See below:
After running perl script.pl, 32 text objects are created using the for loop (line 17). One for each element from the $a array (line 9) This text can then be copied and thereafter be pasted into the SVG file, as I have already described above. Also note line 27. The style of the text object must be right (good font type, good font size, etc.)
Using scripts can save some time when you want to make changes to images. See below for the result:
Link to image: https://commons.wikimedia.org/wiki/File:County1860.svg