Kategoriler
Anlatım Genel Linux

Embed and Subset Fonts

Assalamu alaikum (Peace be upon you) dear visitor,

I have faced with font embed and subset problem every time I submit my research paper to IEEE or ACM conference or journal. In this article, I am going to explain how I embed and subset fonts in Ubuntu 14.04.1 LTS 64 bit. Here is my solution:

  1. Open terminal.
  2. Update repository.
  3. Install texlive.
  4. Install texlive-publishers.
  5. Install ghostscript.
  6. Create a shell script (sh) file in the folder that has your (IEEE, ACM) tex file.
  7. Copy the code below and paste it to the shell script file.
  8. Grant the execution permission and run it!

Congratulations! Now you have a pdf with embeded subset fonts.

Assalamu alaikum (Peace be upon you) 🙂

#!/bin/bash

## do not write tex extension
## only write tex file name
TEX_FILENAME=””
## do not write bib extension
## only write bib file name
BIB_FILENAME=””

if [ $# == 1 ]; then
TEX_FILENAME=$1
BIB_FILENAME=$1
elif [ $# == 2 ]; then
TEX_FILENAME=$1
BIB_FILENAME=$2
else
echo “This script requires two parameters to generate pdf with embeded subset fonts. These are tex and bib filenames.”
echo “You must provide at least one argument. In this case, script assumes that tex and bib file has exactly the same name.”
echo “Otherwise, first one must be tex file name without extension and the second one must be bib file name without extension.”
echo “Example: shellScript.sh myTexFile myBibFile”
echo “Wrong: shellScript.sh myBibFile.bib myTexFile.tex”
echo “Wrong: shellScript.sh myBibFile myTexFile.tex”
echo “Wrong: shellScript.sh myBibFile.bib myTexFile”
echo “Wrong: shellScript.sh myTexFile.tex myBibFile”
echo “Wrong: shellScript.sh myTexFile myBibFile.bib”
echo “Wrong: shellScript.sh myTexFile.tex myBibFile.bib”

exit 1
fi

## globals
LATEX_EXTENSION=”.tex”
BIBTEX_EXTENSION=”.bib”
DVI_EXTENSION=”.dvi”
PS_EXTENSION=”.ps”
PDF_EXTENSION=”.pdf”
AUX_EXTENSION=”.aux”
BBL_EXTENSION=”.bbl”
BLG_EXTENSION=”.blg”
LOG_EXTENSION=”.log”
SYNCTEX_EXTENSION=”.synctex”
GZ_EXTENSION=”.gz”

## create DVI file and update references
latex $TEX_FILENAME
bibtex $BIB_FILENAME
latex $TEX_FILENAME
latex $TEX_FILENAME

## convert DVI to PS
#dvips -Ppdf -G0 -ta4
dvips -Ppdf -G0 -ta4 $TEX_FILENAME

## convert PS to PDF
## in the mean time embed font subsets
ps2pdf -dCompatibilityLevel#1.4 \
-dPDFSETTINGS#/prepress \
-dAutoRotatePages#/None \
-dCompressPages#true \
-dASCII85EncodePages#false \
-dUseFlateCompression#true \
-dEmbedAllFonts#true \
-dSubsetFonts#true \
-dMaxSubsetPct#100 \
-dConvertCMYKImagesToRGB#false \
-dAutoFilterColorImages#true \
-dColorImageFilter#/DCTEncode \
-dEncodeColorImages#true \
-dDownsampleColorImages#true \
-dColorImageDepth#-1 \
-dColorImageResolution#300 \
-dColorImageDownsampleThreshold#1 \
-dColorImageDownsampleType#/Bicubic \
-dAutoFilterGrayImages#true \
-dGrayImageFilter#/DCTEncode \
-dEncodeGrayImages#true \
-dDownsampleGrayImages#true \
-dGrayImageDownsampleThreshold#1 \
-dGrayImageDownsampleType#/Bicubic \
-dGrayImageDepth#-1 \
-dGrayImageResolution#300 \
-dMonoImageFilter#/CCITTFaxEncode \
-dEncodeMonoImages#true \
-dDownsampleMonoImages#true \
-dMonoImageDownsampleThreshold#1 \
-dMonoImageDownsampleType#/Bicubic \
-dMonoImageDepth#-1 \
-dMonoImageResolution#600 \
“$TEX_FILENAME$PS_EXTENSION” “$TEX_FILENAME$PDF_EXTENSION”

## remove unnecessary files automatically
rm $TEX_FILENAME$AUX_EXTENSION
rm $TEX_FILENAME$DVI_EXTENSION
rm $TEX_FILENAME$PS_EXTENSION
rm $TEX_FILENAME$BBL_EXTENSION
rm $TEX_FILENAME$BLG_EXTENSION
rm $TEX_FILENAME$LOG_EXTENSION