LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-10-2016, 09:23 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
BASH script to install, configure, and view your truetype (TTF fonts) in PDFLATEX


Hello,

Here is the script. You need a bit of knowledge of Latex/Linux if you would like to use it.

1. Make sure that you use a new ~/tmp directory.
2. You need those two files run.sh and test.tex.
3. test it with for instance:
Code:
bash run.sh ~/.fonts/amiga.ttf

test.tex
Code:
\documentclass{article}

\usepackage{fonttable}
\usepackage[T1]{fontenc}
\renewcommand*{\familydefault}{jcs}
\begin{document}

Test your TTF! \\

\Large
{\bfseries H}{\normalsize ello World}
\bigskip

\normalsize
Normal size: This is a test
\bigskip


Some of the greatest \emph{discoveries} 
in science 
were made by accident.
 
\textit{Some of the greatest \emph{discoveries} 
in science 
were made by accident.}
 
\textbf{Some of the greatest \emph{discoveries} 
in science 
were made by accident.}

\fonttable{jcsr8t}
\end{document}
run.sh
Code:
echo convert ttf

cd 
mkdir tmp

cd tmp

rm test.pdf
cp "$1" newfont.ttf


 mkdir -p ~/texmf/tex/latex/local/
mkdir ~/.texmf-config/web2c/ -p  ; mktexlsr 

echo "\\ProvidesFile{T1jcs.fd}" > ~/texmf/tex/latex/local/T1jcs.fd 
echo "[2009/06/14 Provides font definitions for T1/jcs.]" >> ~/texmf/tex/latex/local/T1jcs.fd 
echo "\\DeclareFontFamily{T1}{jcs}{}" >> ~/texmf/tex/latex/local/T1jcs.fd 
echo "\\DeclareFontShape{T1}{jcs}{m}{n} {<-> jcsr8t } {}" >> ~/texmf/tex/latex/local/T1jcs.fd 
echo "\\endinput " >> ~/texmf/tex/latex/local/T1jcs.fd 


 otftotfm  --no-type1  -fkern  --encoding="T1-WGL4.enc"  --map-file="myfont.map"  "newfont.ttf"  "jcsr8t" 

    mkdir  -p  ~/texmf/fonts/tfm/microsoft/comicsans/
    mkdir -p   ~/texmf/fonts/vf/microsoft/comicsans/
    mkdir -p   ~/texmf/fonts/truetype/comicsans/
    mkdir -p   ~/texmf/fonts/enc/dvips/comicsans/

   cp -v *.tfm  ~/texmf/fonts/tfm/microsoft/comicsans/
   cp -v *.vf  ~/texmf/fonts/vf/microsoft/comicsans/ 
   cp -v *.ttf  ~/texmf/fonts/truetype/comicsans/
   cp -v *.enc  ~/texmf/fonts/enc/dvips/comicsans/ 
   cp myfont*.map ~/texmf/fonts/maps/dvips/comicsans/myfont.map


 texhash
 mkdir -p ~/texmf/fonts/maps/dvips/comicsans/
 updmap --enable Map=~/texmf/fonts/maps/dvips/comicsans/myfont.map

 mkdir ~/.texmf-config/web2c/ -p  ; mktexlsr 

 pdflatex test.tex
 mupdf test.pdf 

 echo done
 
Old 11-13-2016, 04:43 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Thanks for posting your script. Please note however it doesn't:
- use proper conventions (shebang, proper quoting variables, exit 0),
- test if "$1" exists or even has TTF magic ('man magic;'),
- doesn't use proper temporary directory creation ('man mktemp;'),
- test file existence before deletion,
- test for tool existence before using,
- do any error handing.
 
Old 11-19-2016, 10:33 AM   #3
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by unSpawn View Post
Thanks for posting your script. Please note however it doesn't:
- use proper conventions (shebang, proper quoting variables, exit 0),
- test if "$1" exists or even has TTF magic ('man magic;'),
- doesn't use proper temporary directory creation ('man mktemp;'),
- test file existence before deletion,
- test for tool existence before using,
- do any error handing.
those are minor improvements, very easily done in bash , i.e.
Code:
 [ ! -f blabla ] && ....
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using pdflatex into a bash script jmvidalvia Linux - General 2 04-08-2011 04:09 PM
problem with TrueType TTF fonts - got only squares, cant read anything soa Debian 9 04-26-2009 06:15 PM
TrueType fonts won't install ilikejam Linux - Software 1 06-19-2005 11:23 PM
How do you install new TrueType fonts in Suse 9.2? avidwriter SUSE / openSUSE 5 04-20-2005 11:31 PM
Can I Install TrueType Fonts On Slack? Chryyz Slackware 4 03-05-2005 09:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration