5

The following will list all the fonts, but I would like to take it a step further and render a sample of each font.

How can ConTeXt render each font in its respective font? Maybe LuaTeX would be good for this?

http://wiki.contextgarden.net/Font_Switching suggests three other articles, but I can't tell which is relevant.

% When you want list of all fonts in the database you can do this with 
% a few macros in your document which are provided for this purpose.

% nofruns=1

\setupbodyfont[10pt]

\starttext

\dolookupfontbyspec{filename=*}

\starttabulate
\dorecurse{\dolookupnoffound}
  {\expanded{\NC \dolookupgetkeyofindex{fontname}{\recurselevel} \EQ \dolookupgetkeyofindex{filename}{\recurselevel} \NC\NR}}
\stoptabulate

\stoptext
  • Probably you should start with this one as it shows how to use the fonts by filename. – TeXnician Apr 3 '17 at 19:48
5

Use \definedfont[file:<filename>]. Alternatively, \definedfont[name:<fontname>] would also be possible but thereby you just instruct the fontloader to do the fontname-to-filename resolution again, which is pointless because you already have the filename. More info can be found in »Fonts out of ConTeXt« aka Hans' new font manual.

This will most likely take forever and will probably not typeset as some fonts contain bugs or do not contain printable characters. In my TL 2016 installation for example I got the error

! error:  (file /usr/local/texlive/2016/texmf-dist/fonts/afm/urw/avantgar/uagbi8a.afm) (cff): could not understand Type1 font: /usr/local/texlive/2016/texmf-dist/fonts/afm/urw/avantgar/uagbi8a.afm

and no pages output. For the first 100 it works okay and I include the first page of this output below.

\setupbodyfont[10pt]

\starttext

\dolookupfontbyspec{filename=*}

\starttabulate[|l|l|l|l|]
\dorecurse{\dolookupnoffound}{
  \expanded{
    \NC \recurselevel
    \NC \dolookupgetkeyofindex{fontname}{\recurselevel}
    \EQ \dolookupgetkeyofindex{filename}{\recurselevel}
    \EQ \definedfont[file:\dolookupgetkeyofindex{filename}{\recurselevel}] My test text
    \NC\NR
  }
}
\stoptabulate

\stoptext

enter image description here

  • Wow! Thanks. I'll add definedfont to the bag of tricks, and perhaps the bag will be big enough soon. – selden Apr 4 '17 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.