I have an SVG that was exported from ESRI ArcGIS Pro that has embedded fonts. I am trying to import it into Microsoft Word but the fonts are not rendering properly.
In Inkscape, is there a way to accomplish all of the following via the command line (headless)?
In an SVG with embedded woff fonts (fonts not installed locally),
For all text,
Duplicate text blocks as transparent (to make text searchable)
Convert objects to paths (to ensure correct rendering)
And re-save as SVG.
I have been able to hack together a script to do all of the above except "Duplicate text blocks as transparent".
I wasn't aware Inkscape 1.1 or 1.2 could access and display embedded fonts.
In order to correctly display the fonts they would have to be installed locally at least on your machine.
The only way I can think to do it, is to select by element : text, then duplicate, then convert that duplication to paths, then select by element : text again -
however at that point it's a bit difficult to change the visibilty of the text - and the text selection would not line up with the original text unless the target system has the font installed or you are using a browser which supports embedded fonts.
I've not actually tried calling an extension to act upon the current command line selection - that would allow the setting of the font fill ( and stroke if it has it ) to none.
The intent for the overlaid, invisible text is to make the SVG act like an OCR'd PDF file with searchable text. I am not overly concerned about the text not aligning perfectly.
To make all this work (with exception of invisible text) is overly convoluted. Roughly, the steps are
In SVG, extract embedded font-face data from styles into files [XML/CSS]
Extract font info from font data files [Python/fonttools]
In SVG, update font-family attribute to use extracted font family from above. Needed to keep font linkage. [XML/CSS]
Convert font file (e.g. woff) to the underlying type as needed (OpenText or TrueType) [Python/fonttools]
Create a temporary directory to be used for Inkscape profile. The avoids having fonts needing to be installed into the system.
Copy converted fonts into the temporary Inkscape profile\fonts directory.
Set environment variable INKSCAPE_PROFILE_DIR = temporary Inkscape profile directory
Execute Inkscape command line to convert SVG to SVG inkscape.com --export-filename EXPORT.SVG --export-type svg --export-plain-svg --export-text-to-path IMPORT.SVG
Hello all,
I have an SVG that was exported from ESRI ArcGIS Pro that has embedded fonts. I am trying to import it into Microsoft Word but the fonts are not rendering properly.
In Inkscape, is there a way to accomplish all of the following via the command line (headless)?
I have been able to hack together a script to do all of the above except "Duplicate text blocks as transparent".
Any pointers would be appreciated.
I wasn't aware Inkscape 1.1 or 1.2 could access and display embedded fonts.
In order to correctly display the fonts they would have to be installed locally at least on your machine.
The only way I can think to do it, is to select by element : text, then duplicate, then convert that duplication to paths, then select by element : text again -
however at that point it's a bit difficult to change the visibilty of the text - and the text selection would not line up with the original text unless the target system has the font installed or you are using a browser which supports embedded fonts.
I've not actually tried calling an extension to act upon the current command line selection - that would allow the setting of the font fill ( and stroke if it has it ) to none.
The intent for the overlaid, invisible text is to make the SVG act like an OCR'd PDF file with searchable text. I am not overly concerned about the text not aligning perfectly.
To make all this work (with exception of invisible text) is overly convoluted.
Roughly, the steps are
font-face
data from styles into files[XML/CSS]
[Python/fonttools]
font-family
attribute to use extracted font family from above. Needed to keep font linkage.[XML/CSS]
woff
) to the underlying type as needed (OpenText
orTrueType
)[Python/fonttools]
profile
. The avoids having fonts needing to be installed into the system.profile\fonts
directory.INKSCAPE_PROFILE_DIR
= temporary Inkscapeprofile
directoryinkscape.com --export-filename EXPORT.SVG --export-type svg --export-plain-svg --export-text-to-path IMPORT.SVG
If you are using Inkscape 1.1, it's not possible to call verbs headlessly.
If you are using Inkscape 1.2, verbs are now actions, so it can be done headlessly.
There is an action in 1.2 'paste-style'
So in 1.2 :
If you were to introduce a standard dummy element at the end of each svg using your script ( just before </svg>).
For example a 1px <rect> with style="fill:none;stroke;none" with a known id.
Then you could
select-by-id:rect_id
copy
select-by-element:text
paste-style
select-by-element:tspan ( this may not be required but allows for svgs with inline style on tspan )
paste-style
That would result in the none stroke and none fill being applied to all text and tspan elements
I probably should have explained, it's generally better to avoid using options ( unless there is no other option or it's just something simple )
It's better to use --actions="action1:value;action2:value" - as it allows control of the order
If you are using 1.2 - you can use
inkscape --action-list
to get a list of actions