3

I've been trying to use a couple of my Mac system fonts in my document, and I'm finding that ConTeXt is only finding one style for a couple of the fonts I've been using. The ones I've tried are Baskerville and Optima.

\definefontfamily[myfamily][serif][Baskerville]
\definefontfamily[myfamily][sans][Optima]
\setupbodyfont[myfamily]

With this preamble, all of the serif text is typeset as bold, no matter what font switch I use for it, and all the sans text is typeset using the regular style.

Both of these fonts are stored in .ttc TrueType collection files, and it seems like mtxrun --script fonts --list --all --pattern=Optima* yields:

optima          optimaregular   /System/Library/Fonts/Optima.ttc   index:  4
optimanormal    optimaregular   /System/Library/Fonts/Optima.ttc   index:  4
optimaregular   optimaregular   /System/Library/Fonts/Optima.ttc   index:  4

and mtxrun for Baskerville shows a similar result. Both runs reference an index number, but it seems like ConTeXt is only finding the one style instead of all of them.

What do I need to do to get ConTeXt to find the other styles?

EDIT: Here's what I've found after further investigation.

The simplefonts module had lent the impression that things were working correctly for me, but looking at the log file, simplefonts appears to fallback on the librebaskerville font that came with TeXLive.

\usemodule[simplefonts]
\setmainfont[Baskerville]

Using other system fonts that live .ttc files seems to produce a similar result with fallbacks from the TeX tree being used if a similar name is found.

The Arial font on my system is separated by style into individual .ttf files. simplefonts finds them correctly, and the newer \definefontfamily method also works as expected.

Additionally, I tried defining my own Baskerville typescript with the following:

\starttypescript [serif] [baskerville]
  \definefontsynonym [Baskerville-Roman]          [name:Baskerville]
  \definefontsynonym [Baskerville-Bold]           [name:Baskerville-Bold]       
  \definefontsynonym [Baskerville-Italic]         [name:Baskerville-Italic]     
  \definefontsynonym [Baskerville-Bold-Italic]    [name:Baskerville-BoldItalic] 
\stoptypescript

\starttypescript [serif] [baskerville]
  \usetypescript[serif][fallback]
  \definefontsynonym [Serif]                   [Baskerville-Roman]                   
  \definefontsynonym [SerifItalic]             [Baskerville-Italic]                  
  \definefontsynonym [SerifBold]               [Baskerville-Bold]                    
  \definefontsynonym [SerifBoldItalic]         [Baskerville-Bold-Italic]             
\stoptypescript

\starttypescript [Baskerville]
  \definetypeface [Baskerville] [rm] [serif] [baskerville] [default] 
\stoptypescript

\usetypescript[Baskerville]
\setupbodyfont[Baskerville]

But that method seems to also find the fallbacks that simplefonts found instead of using the various styles provided by the system font.

  • Is this something ConTeXt can generally do? Does it work with other .ttcs and it is just these particular fonts which are a problem? – cfr Aug 16 '15 at 22:59
  • I've added some more information based on further research. As far as I can tell, all .ttcs seem to provide only one style for ConTeXt, unless I'm setting things up incorrectly. – Ben Aug 17 '15 at 12:27
  • Also, a quick test with lualatex appears to have some method of indexing into the .ttc file to get the different styles instead of just one of them (I think the one with the 0 index position) – Ben Aug 17 '15 at 12:40
3

Which version of ConTeXt are you using? I am using 2015.08.13 on Mac and the following example:

\definefontfamily[myfamily][serif][Baskerville]
\definefontfamily[myfamily][sans][Optima]
\setupbodyfont[myfamily]

\starttext

Hello \sans{World}

\stoptext

works correctly.

pdffonts test.pdf
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
PKVICD+Baskerville                   CID TrueType      Identity-H       yes yes yes     16  0
QZBUCL+Optima-Regular                CID TrueType      Identity-H       yes yes yes     17  0

A more detailed example:

\definefontfamily[myfamily][serif][Baskerville]
\definefontfamily[myfamily][sans][Optima]
\setupbodyfont[myfamily]

\starttext

\bold{Hello} \italic{world} \bolditalic{Hello World} Hello World

{\ss \bold{Hello} \italic{world} \bolditalic{Hello World} Hello World}

\stoptext

gives

enter image description here

  • I'm using 2015.05.18 from the latest MacTeX release. The second example above gives me one line of all boldface "Hello World", and a second line of all regular-sans "Hello World". – Ben Aug 17 '15 at 14:52
  • 1
    @Ben: it may be a good idea to check context stanalone. I have always had a had time with context on texlive (which mactex is based on) – Aditya Aug 17 '15 at 16:09
  • looking into context standalone did seem to fix the problem for a time, but it still crops up if I manually rebuild the font cache with mtxrun --script font --reload. After I do that, I get back to finding only one style in a .ttc file unless I manually delete the cache files and start from scratch. – Ben Aug 27 '15 at 13:44

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.