# How to speed up rendering a PSTricks object with a custom fill

Because PSTricks does not provide us with dotted and x-like fill styles, I must create my own custom fill style using pst-fill package.

However, the rendering is too slow and sometimes out of memory.

\documentclass[cmyk]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{amsmath}
\usepackage{pstricks,pst-fill}

\psboxfill{%
\psset{unit=1pt}
\begin{pspicture}(3.6,3.6)
\psdot(1.8,1.8)
\end{pspicture}%
}

\begin{document}

\begin{figure}[hbtp]
\centering
\begin{pspicture}[showgrid=false](-2,-2)(2,2)
\pscircle[
fillstyle=solid,
opacity=0.25,
fillcolor=gray,
fillsep=0.4,
(0,0){2}
\pscircle[
linecolor=red,
linestyle=dashed,
linewidth=2pt]
(0,0){1}
\end{pspicture}
\caption{The magnetic field $\vec{B}$ is directed perpendicularly out of the page.}
\end{figure}

\end{document}


How to speed up rendering a PSTricks object with a custom fill?

\psboxfill{%
\psset{unit=1pt}
\begin{pspicture}(3.6,3.6)
\qdisk(1.8,1.8){1.8}
\end{pspicture}%
}


I know the reason why using \psdot runs slowly. When I highlighted the PDF output, there are unnecessary hidden objects as follows. It might be a feature of \psdot.

Thus, to speed up, use \pscircle* instead of \psdot as follows, and the hidden objects disappear.

\documentclass[cmyk]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{amsmath}
\usepackage{pstricks,pst-fill}

\psboxfill{%
\psset{unit=1pt}
\begin{pspicture}(3.6,3.6)
%\psdot(1.8,1.8)
\pscircle*(1.8,1.8){1.8}
\end{pspicture}%
}

\begin{document}

\begin{figure}[hbtp]
\centering
\begin{pspicture}[showgrid=false](-2,-2)(2,2)
\pscircle[
fillstyle=solid,
opacity=0.25,
fillcolor=gray,
fillsep=0.4,
(0,0){2}
\pscircle[
linecolor=red,
linestyle=dashed,
linewidth=2pt]
(0,0){1}
\end{pspicture}
\caption{The magnetic field $\vec{B}$ is directed perpendicularly out of the page.}
\end{figure}

\end{document}


Another drawback when using \psdot is: \psdot uses T3Font_0 as follows

This font cannot be embedded to the PDF output, even though you use ps2pdf -dPDFSETTINGS#/prepress input.ps.

• This font is actually embedded in this case. Adobe reader has a strange way of dealing with type 3 fonts. – Lev Bishop Jul 9 '11 at 15:09
• @Lev: I think the font is not embedded since pdfcrop also cannot produce correct BB. – xport Jul 9 '11 at 15:14
• The font is embedded. I did check before writing. You can check yourself with multivalent, pdffonts or acrobat professional preflight tool (and probably many other tools). Also, pdfcrop produces the correct bbox for me. – Lev Bishop Jul 9 '11 at 22:18