3

I have converted svg-icons of car brands into a custom font because the pstricks macro can only take alphanumeric characters in the text-argument and not images (I have the icons in svg, eps and png format).

How can I use this custom font inside a pstricks environment where I must use pdftex (in my case LaTeX)?

Is it possible?

This is what my font look like when the font is installed on my local computer and I must use LuaLaTeX (not pdftex) to compile:

\documentclass[]{article}
\usepackage{lmodern}
\usepackage{fontspec}  % requires XeLaTex or LuaLaTeX
\newfontfamily\customfont[]{untitled-font-1}

\begin{document}
   {\huge \customfont a} {\huge \customfont b} {\huge \customfont c} {\huge \customfont d}  
   {\huge \customfont e} {\huge \customfont f} {\huge \customfont g} {\huge \customfont h} 
   {\huge \customfont i} {\huge \customfont \%} {\huge \customfont !} 
\end{document}

The result is: The custom car-font

I want to use this font of car brands inside the pstricks environment - but then I have to use normal LaTeX (pdftex) to compile, but then the following code will not work because the font require LuaLaTeX:

% added this packages to preamble 
\usepackage{lmodern}  
\usepackage{multido} 
\usepackage{pst-plot,pst-text}

% body
\DeclareFixedFont{\SF}{T1}{phv}{b}{n}{2.45cm}
\pstextpath(0,-0.3ex){\pscharpath*[linestyle=none]{\SF Cars}}{\tiny \multido{}{202}{%
   {\huge \customfont a} {\huge \customfont b} {\huge \customfont c} {\huge \customfont d}  
   {\huge \customfont e} {\huge \customfont f} {\huge \customfont g} {\huge \customfont h} 
   {\huge \customfont i} {\huge \customfont \%} {\huge \customfont !}  }}

This is how the result looks like with fontawesome icons (but I want to use the car brand icons :( ...):

enter image description here

The problem summarized: the custom font demands LuaLatex while pstricks demands LaTeX. How can I solve this issue?

Edit: when I use the XeLaTex engine: This is the error-message I get when I use the XeLaTeX engine on overleaf.com: enter image description here

And this is the result: enter image description here

I.e XeLaTex does not like the pstextpath and the pscharpath macros. Hope that can help. I can also supply different kind of log files if someone wants to take a look.

10
  • 1
    Can't you use xelatex? Or maybe with the recent package auto-pst-pdf-lua?
    – Bernard
    Commented Jul 23, 2020 at 23:13
  • @Bernard I don´t think XeLaTeX is compatible with pstricks.
    – Mr. B
    Commented Jul 23, 2020 at 23:41
  • I don't think the auto-pst-pdf-lua package will help in this case because that package seems to convert pstricks stuff into images that is inserted in the pdf in the second run. My custom-font will be part of the image, but they is not defined in the first run.
    – Mr. B
    Commented Jul 24, 2020 at 0:49
  • If there are fewer than 256 icons in the font, could you encode it as a Type 1 font with the U encoding?
    – Davislor
    Commented Jul 24, 2020 at 2:58
  • 1
    For auto-pst-pdf-lua, it was only a suggestion (I don't use lualatex). As to XeLaTeX, I'm sorry, but all my answers on this site using pstricks were compiled with it.
    – Bernard
    Commented Jul 24, 2020 at 8:44

1 Answer 1

4

Puuh - not easy, but very nice:

The word car outlined with car brands icons

I use TeX Live, TexMaker and FontForge that runs on OS X machine.

So this is what I did:

I converted the .svg files into a postscript font (in other words a .pfb and .afm file):

  1. Used FontForge to import the svg-images and to generate the font (PS Type 1 binary - has fileextension .pfb). The car icons is mapped to 0-9A-Za-e.

FontForge

Get LaTeX to use the car-font locally:

  1. Made a directory - that I called testfont that I put the cars___.afm and cars___.pfb files into.

  2. Run the commandoline tool and set the working directory to testfont: cd testfont.

  3. Used TEX utilities to produce the .map file and the .pl file (human readable):

    afm2pl -p texnansi cars___.afm cars8y.pl
    
  4. Then I used the .pl file to get the .tfm file (compact binary file):

    pltotf cars8y
    
  5. Made the .fd file that I called ly1mycarfontfam.fd that is saved to the testfont folder with this content:

    \ProvidesFile{ly1mycarfontfam.fd}
    \DeclareFontFamily{LY1}{mycarfontfam}{} 
    \DeclareFontShape{LY1}{mycarfontfam}{m}{n}{<-> cars8y }{}
    
  6. And the content in testfont.tex file:

    \documentclass{article}
    \pagestyle{empty}
    
    % Car font
    \usepackage{texnansi}
    % I cannot use the \pdfmacro when I use LaTeX -> dvips -> ps2pdf
    %\pdfmapfile{=cars8y.map}
    \newcommand{\fancyfont}%
    {\fontfamily{mycarfontfam}\selectfont}
    
    % Pstricks
    \usepackage{pst-plot}
    \usepackage{pst-text}
    
    \begin{document}
    \DeclareFixedFont{\SF}{T1}{phv}{b}{n}{3.5cm}
    
    \hspace*{-1.5cm}\pstextpath(0,-0.5ex){\pscharpath*[linestyle=none]{\SF Cars}}{
    \scriptsize \multido{}{120}{\fancyfont 345678HIJLMNRSXYZ}
    }
    \end{document}
    
  7. Result:

Result before dvips

  1. Not good. This is because I cannot use \pdfmapfile macro in dvips mode. So when you have compiled the tex-code you also get an testfont.dvi file in the directory, and you have to use the commandoline with the following commando each time where you supply the name of the map- and dvi- file (this will update the testfont.ps file):

    dvips -u +cars8y.map testfont.dvi  
    

Double-click the testfont.ps file in the folder and a copy gets made in .pdf format with the result shown above or use the following commando to update the .pdf file from the updated .ps file: ps2pdfwr testfont.ps testfont.pdf

Isn´t it nice (with some dummy text)?

Sweety cars

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .