I am trying to convert a set of eps (or svg) files to a custom pgfornament library to add to some elements from Vectorian, the default set. The package documentation suggests that this is possible going from Inkscape -> save as LaTex/Pstricks, however I cannot follow the next step, converting the output to .pgf file - I don't understand what the documentation is suggesting I do at all.

I tried separately converting from the eps to pgf using epstopgf, and the resulting file can be added in as an ornament but it does not resize or respond to the size and symmetry instructions from pgfornaments, and I can see by inspecting the file it is not formatted in the same shorthand as the example on 3.5 of the package documentation. For example, a line of of pgf might read:

\pgfpathcurveto{\pgfqpoint{12.732cm}{18.229cm}}{\pgfqpoint{12.695cm}{18.209cm}}{\pgfqpoint{12.657cm}{18.19cm}}


whereas the example pgf file in the example in the package document reads:

\l 310.29 189.71


which is clearly not encoded in the same way. Thanks for any advice!

EDIT: as requested, here is an example eps :https://pastebin.com/Bz9C8xA4 and after conversion to an PStricks file https://pastebin.com/3zSYkwNn. I'm not sure how to convert this to a suitable pgf file. A MWE for pgfornament would be something like:

\documentclass{scrartcl}
\usepackage[object=custom]{pgfornament}
\begin{document} %
\begin{tikzpicture}[shorten >=1pt,->,draw=black, x = 1 cm, y = 1 cm]
\node  at (0,0) {\pgfornament{1}};%
\end{tikzpicture}
\end{document}


This would expect the pgf file to be saved as custom1.pgf and also the presence of pgflibrarycustom.code.tex which gives some default sizes, for example:

\makeatletter
\def\@pgfornamentDim#1{%
\ifcase#1\relax%
\or\def\@pgfornamentX{136}\def\@pgfornamentY{107}% 1
\fi%
}%
\makeatother
\endinput


which I copied from the PSvectorian example.

• Please provide a complete example, including exactly what you do for the conversion step and the output you get for a minimal case. You have to substitute the shortened forms in, if you want to use them. But you don't want to convert to PGF. You have to transform the output from Inkscape manually. (But you don't have to use the shortened forms - they just take less space that way.) However, without an example to play with, it is hard to say anything much useful. – cfr Aug 27 '18 at 1:25
• Thanks, I have added example files. It is the conversion from the .tex output from Inkscape to a correctly formatted pgf file. – JP Janet Aug 27 '18 at 2:11
• Also to be clear, using the .pgf file given on page 35 of package documentation everything works perfectly, and the documentation alludes to "saving in Inkscape to .tex and then converting to pgf" but I have no idea how to do that. – JP Janet Aug 27 '18 at 2:18

I don't know what it should look like. I get

which seems a bit odd, but I have no idea.

Here's the code, with the converted file.

\begin{filecontents}{\jobname1.pgf}
\begingroup
\def\i{\pgfusepath{clip}}%
\def\k{\pgfusepath{stroke}}%
\let\o\pgfpathclose
\let\s\pgfusepathqfillstroke
\def\p #1#2{\pgfqpoint{#1bp}{#2bp}}%
\def\m #1 #2 {\pgfpathmoveto{\p{#1}{#2}}}%
\def\r #1 #2 #3 #4 {\pgfpathrectangle{\p{#1}{#2}}{%
\p{#3}{#4}}}%
\def\l #1 #2 {\pgfpathlineto{\p{#1}{#2}}}%
\def\c #1 #2 #3 #4 #5 #6 {%
\pgfpathcurveto{\p{#1}{#2}}{\p{#3}{#4}}{\p{#5}{#6}}}%
\begin{tikzpicture}
\pgftransformscale{.4}
\m 181.82745361 904.71787184
\c 181.82745361 885.26139442 166.50712224 869.48880308 147.60853577 869.48880308
\c 128.70994929 869.48880308 113.38961792 885.26139442 113.38961792 904.71787184
\c 113.38961792 924.17434926 128.70994929 939.94694059 147.60853577 939.94694059
\c 166.50712224 939.94694059 181.82745361 924.17434926 181.82745361 904.71787184
\k

\m 181.82745361 904.71787184
\c 181.82745361 885.26139442 166.50712224 869.48880308 147.60853577 869.48880308
\c 128.70994929 869.48880308 113.38961792 885.26139442 113.38961792 904.71787184
\c 113.38961792 924.17434926 128.70994929 939.94694059 147.60853577 939.94694059
\c 166.50712224 939.94694059 181.82745361 924.17434926 181.82745361 904.71787184
\k

\m 250.13902283 904.08653944
\c 250.13902283 884.63006202 234.81869146 868.85747069 215.92010498 868.85747069
\c 197.02151851 868.85747069 181.70118713 884.63006202 181.70118713 904.08653944
\c 181.70118713 923.54301686 197.02151851 939.3156082 215.92010498 939.3156082
\c 234.81869146 939.3156082 250.13902283 923.54301686 250.13902283 904.08653944
\s

\m 250.13902283 904.08653944
\c 250.13902283 884.63006202 234.81869146 868.85747069 215.92010498 868.85747069
\c 197.02151851 868.85747069 181.70118713 884.63006202 181.70118713 904.08653944
\c 181.70118713 923.54301686 197.02151851 939.3156082 215.92010498 939.3156082
\c 234.81869146 939.3156082 250.13902283 923.54301686 250.13902283 904.08653944
\k

\m 180.62789917 834.19660109
\c 180.62789917 814.74012367 165.3075678 798.96753233 146.40898132 798.96753233
\c 127.51039485 798.96753233 112.19006348 814.74012367 112.19006348 834.19660109
\c 112.19006348 853.6530785 127.51039485 869.42566984 146.40898132 869.42566984
\c 165.3075678 869.42566984 180.62789917 853.6530785 180.62789917 834.19660109
\s

\m 180.62789917 834.19660109
\c 180.62789917 814.74012367 165.3075678 798.96753233 146.40898132 798.96753233
\c 127.51039485 798.96753233 112.19006348 814.74012367 112.19006348 834.19660109
\c 112.19006348 853.6530785 127.51039485 869.42566984 146.40898132 869.42566984
\c 165.3075678 869.42566984 180.62789917 853.6530785 180.62789917 834.19660109
\k

\m 248.93946838 833.56526869
\c 248.93946838 814.10879127 233.61913701 798.33619993 214.72055054 798.33619993
\c 195.82196406 798.33619993 180.50163269 814.10879127 180.50163269 833.56526869
\c 180.50163269 853.02174611 195.82196406 868.79433745 214.72055054 868.79433745
\c 233.61913701 868.79433745 248.93946838 853.02174611 248.93946838 833.56526869
\s

\m 248.93946838 833.56526869
\c 248.93946838 814.10879127 233.61913701 798.33619993 214.72055054 798.33619993
\c 195.82196406 798.33619993 180.50163269 814.10879127 180.50163269 833.56526869
\c 180.50163269 853.02174611 195.82196406 868.79433745 214.72055054 868.79433745
\c 233.61913701 868.79433745 248.93946838 853.02174611 248.93946838 833.56526869
\k

\end{tikzpicture}
\endgroup
\end{filecontents}

\documentclass[border=10pt]{standalone}
\usepackage{pgfornament}
\makeatletter
\newcommand{\callornament}[1]{%
\begingroup
\def\i{\pgfusepath{clip}}%
\let\o\pgfpathclose
\let\s\pgfusepathqfillstroke
\def\p ##1##2{\pgfqpoint{##1bp}{##2bp}}%
\def\m ##1 ##2 {\pgfpathmoveto{\p{##1}{##2}}}%
\def\l ##1 ##2 {\pgfpathlineto{\p{##1}{##2}}}%
\def\r ##1 ##2 ##3 ##4 {\pgfpathrectangle{\p{##1}{##2}}{%
\p{##3}{##4}}}%
\def\c ##1 ##2 ##3 ##4 ##5 ##6 {%
\pgfpathcurveto{\p{##1}{##2}}{\p{##3}{##4}}{\p{##5}{##6}}}%
\@@input #1\relax
\m 0 0 \l 400 0 \o\s
\endgroup
}
\makeatother

\usepackage{tikz}

\begin{document}
\tikz \callornament{\jobname1.pgf};
\end{document}


As the manual explains, there are different ways of using the code. I just went with the simplest, but, obviously, you can do this with a library wrapper or something. Also, although the manual doesn't do this, it seems to me that you can remove the duplicated code at the start and end of each picture if your wrapper macro provides that. That is, you shouldn't need all the \def stuff in every .pgf.

Hope this helps somewhat. I just followed the manual in a pretty simple-minded way, I think, as I'm not familiar with this process at all. No doubt you can finesse it a good deal.

• Thanks for looking into it, so you just macro the pgf lines using \callornament and then replace them in the file? My actual eps is very complicated so I will need to script the translation, but I appreciate the starting point! – JP Janet Aug 27 '18 at 13:13
• @JPJanet As far as I can see, yes. I used regular expressions for most of the translation. If I had to do several, I'd write a sed or gawk script. – cfr Aug 27 '18 at 14:00