TeX - LaTeX Asked by Mr. B on August 29, 2021
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
newfontfamilycustomfont[]{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}
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 🙁 …):
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:
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.
Puuh - not easy, but very nice:
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):
.pfb
). The car icons is mapped to 0-9A-Za-e.Get LaTeX to use the car-font locally:
Made a directory - that I called testfont
that I put the cars___.afm
and cars___.pfb
files into.
Run the commandoline tool and set the working directory to testfont: cd testfont
.
Used TEX utilities to produce the .map
file and the .pl
file (human readable):
afm2pl -p texnansi cars___.afm cars8y.pl
Then I used the .pl
file to get the .tfm
file (compact binary file):
pltotf cars8y
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 }{}
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}
Result:
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)?
Correct answer by Mr. B on August 29, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP