XeTeXBash + Xelatex: Quick font test / preview

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
Post Reply
sdaau
Posts: 26
Joined: Fri Feb 19, 2010 2:08 pm

Bash + Xelatex: Quick font test / preview

Post by sdaau »

Hi all,

I just wanted to have that type of a preview they have on some font websites, where you type a phrase and it gets rendered in different fonts ... So here is a small bash script (tested on Ubuntu 9.10) which will loop through a directory where .ttf or .otf fonts are places, and will generate a .tex file with a phrase in all those fonts - and will finally call xelatex to generate a pdf based on the tex file.

Excuse the messy comments - and hope some may find it useful,

Cheers!


quickfonttest.sh:

Code: Select all

# to be used with xetex - xelatex
# for texlive:
# tlmgr install xetex xunicode xltxtra fontspec xkeyval euenc metalogo xetex-def
# Must NOT have spaces in font names !!
# Note - some fonts (those with commas in their names? can cause Segmentation fault).
# the script will loop through a directory (assuming it has only .ttf or .otf font files) and will generate a xetex file, which will display a phrase in all the fonts found in that directory; and then it will compile the file with xelatex. (something similar to http://fontforge.sourceforge.net/fontimage.html)
# sudo apt-get install fontforge # for showttf
# bugs - Verbatim doesn't wrap (break lines) and doesn't show footnotesize
OFN=fonttester # output file name (base)
TEXF=$OFN.tex
function becho()
{
echo "$*" | tee -a $TEXF
}
PHRASE="My Test Phrase"
FONTDIR=/home/USERNAME/.openoffice.org/3/user/fonts
echo "" > "$TEXF" # erase
becho "
\documentclass{article}
\usepackage{fontspec}
\usepackage{xunicode}
%\usepackage{xltxtra}
\usepackage{graphicx} % for scalebox
\usepackage{fancyvrb} % for Verbatim
\usepackage{fancybox} % for fbox?
% from fancybox.pdf:
\newenvironment{fminipage}%
{\begin{Sbox}\begin{minipage}}%
{\end{minipage}\end{Sbox}\fbox{\TheSbox}}
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply