6

It happens many times that I take a look at an interestingly typeset document in LaTeX, but to which I don't have the source-code to inspect the style. One such example is this one: http://philosophy.unimelb.edu.au/ajl/2011/2011_5.pdf

I know there are free services online that identify the fonts. They may be useful for simple text, but, for example, mathematics, it becomes very hard to identify the correct style.

So, my question is, what could one use to help reproducing a specific style when only having access to the final PDF?

doncherry
  • 54,637

4 Answers4

12

For fonts, you can use pdffonts:

$ pdffonts charismanie.pdf 
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
BQFNPY+TimesNewRomanPS-ItalicMT      CID TrueType      yes yes yes     59  0
UQUJMH+Centennial-Roman              CID TrueType      yes yes yes     60  0
NSOUSR+LinLibertine                  Type 1            yes yes no     137  0
NSOUSR+LinLibertine                  Type 1            yes yes no     138  0
PTKESR+LinLibertineI                 Type 1            yes yes no     143  0
TYFIDZ+CMSY10                        Type 1            yes yes no     144  0
MHUAJQ+LinLibertineB                 Type 1            yes yes no     145  0
[none]                               Type 3            yes no  no     146  0
QTAYVE+LinBiolinumB                  Type 1            yes yes no     161  0
CXJGOW+CMR12                         Type 1            yes yes no     207  0
PTKESR+LinLibertineI                 Type 1            yes yes no     285  0
PFIFSH+fourier-orns                  Type 1            yes yes no     465  0

Edit: pipitas provided a nice answer with the -f and -l options for pdffonts. In order to automate his suggestion a bit more to list fonts in a PDF, here is a little script:

#!/bin/bash

# Parse options
RANGE=0
while getopts ":ap:f:l:g:" option; do
   case $option in
      a)
         RANGE=1
         ;;
      p)
         RANGE=1
         STARTPAGE=$OPTARG
         ENDPAGE=$STARTPAGE
         ;;
      f)
         RANGE=1
         STARTPAGE=$OPTARG
         ;;
      l)
         RANGE=1
         ENDPAGE=$OPTARG
         ;;
      g)
         GREP=1
         KEYWORD=$OPTARG
         ;;
      *)
         echo "Unknown option $option"
         exit 1
         ;;
  esac
done

shift $(($OPTIND - 1))
PDF="$1"

if [ -z "$PDF" ]; then
   echo "E: You must provide a PDF file"
   exit 1
fi

PAGES=$(pdfinfo $PDF | awk '/^Pages:/ { print $2 }')


if [ $RANGE = 1 ]; then
   for p in $(seq ${STARTPAGE:-1} ${ENDPAGE:-$PAGES}); do
      echo "== Fonts on page $p/$PAGES =="
      pdffonts -f $p -l $p $PDF
   done
elif [ $GREP = 1 ]; then
   FOUND=""
   for p in $(seq ${STARTPAGE:-1} ${ENDPAGE:-$PAGES}); do
      pdffonts -f $p -l $p $PDF | grep -q "^${KEYWORD} " && \
         FOUND="$FOUND $p"
   done
   if [[ -n $FOUND ]]; then
      echo "The font $KEYWORD was found on the following pages:$FOUND"
   else
      echo "The font $KEYWORD was not found"
   fi
else
   pdffonts $PDF
fi

It is a bash script, to be used on *nix systems. Here, I saved it as showfonts.sh).

Here is what it does:

  • Without any options, it just executes pdffonts on the given PDF file;
  • The -a option (for all) does what pipitas suggested: it lists fonts on every page individually, e.g.:

    $ ./showfonts.sh -a charismanie.pdf
    
  • The -p option (for page) lists fonts on a specific page of the PDF, e.g.:

    $ ./showfonts.sh -p 15 charismanie.pdf
    
  • The -f and -l options (for first and last) are the equivalent of the same options in pdffonts (so -f 1 is equivalent to -a), e.g.:

    $ ./showfonts.sh -f 13 -l 16 charismanie.pdf
    
  • The -g option (for grep) lets you find on which pages a font is used, e.g.:

    $ ./showfonts.sh -g "LeagueGothic" charismanie.pdf
    

    It also also takes wildcards to match fonts with similar names, e.g.:

    $ ./showfonts.sh -g ".*Libertine.*" charismanie.pdf
    

This script is now committed on github: https://github.com/raphink/listpdffonts

Edit: The script now supports font subsets with -g as requested by Kurt Pfeifle. See Git repository.

raphink
  • 31,894
  • 2
    Nice tip -- but are there any tools suitable for identifying on which page(s) / page-locations of the pdf an object can be found? – Mark May 24 '11 at 17:34
  • @Mark: see my answer below... – Kurt Pfeifle Oct 22 '11 at 09:51
  • 1
    @Mark: Thanks to pipitas' suggestion, see my edited answer, in particular option -g. – raphink Oct 22 '11 at 21:33
  • Very nice script, Raphink :-) You could put the icing on the cake by adding some more options: (1) Add a --help option. (2) Let -g also handle font subsets (which are marked by prefix to the main font name, see http://tex.stackexchange.com/questions/23104/using-and-interpreting-pdffonts/32189#32189 ) and print the respective messages. – Kurt Pfeifle Nov 10 '11 at 21:10
  • @Raphink: are you considering my suggestion for you script? – Kurt Pfeifle Dec 15 '11 at 22:04
  • @pipitas: Sorry, I didn't update the answer. Will do that later, and I might start a project on github for it. – raphink Dec 15 '11 at 22:58
  • @pipitas: I'm not sure to understand what you would like to do with font subsets. -g already allows to grep them since they are shown in the name field. – raphink Dec 16 '11 at 09:59
  • @Raphink: What I meant with the 'handling of subsets': (1) Assume a PDF which uses Arial. (2) However, the font isn't fully embedded, but only as a subset. (3) That means the fontname used in the PDF is not 'Arial' but something like 'ABCDEF+Arial'. -- Your script should be made to find anyway it when called with -g Arial (no Wildcard required). – Kurt Pfeifle Jul 10 '12 at 20:39
  • @Raphink: Oh, and when using wildcards -g .*Libertine.* the result should print the full name of the found fonts... :-) Just for your wishlist :-) – Kurt Pfeifle Jul 10 '12 at 20:41
  • Ok @KurtPfeifle. These are good ideas. Patches/PRs welcome :) – raphink Jul 11 '12 at 04:38
  • Just implemented them actually. – raphink Jul 11 '12 at 04:52
5

For the fonts. If viewing in Adobe Reader, right click, Document Properties..., then Fonts.

doncherry
  • 54,637
4

@Mark:

If you want to know the fonts on page 3, use

pdffonts -f 3 -l 3 /path/to/pdf

(The f is for first, the l is for last page). If you want to know which font appears on which page of a 10-page PDF, use

for p in $(seq 1 10); do
    pdffonts -f ${p} -l ${p} /path/to/pdf
done

Above examples are for *nix OS. If you are on Windows, try

for %p in (1,1,10) do pdffonts -f %p -l %p
doncherry
  • 54,637
Kurt Pfeifle
  • 3,791
2

It seems to be a in-house style for "The Australasian Journal of Logic". They require submissions as standard LaTeX documents using the article class, and the style file is not publicly available.

egreg
  • 1,121,712