7

I have a font with some optical sizes which I want to use. I tried two solutions (below), without success. How can I use optical sizes of a local font? The solutions I tried:

  1. Using \definefontfamily, which gave me correct basic alternatives (italics, bold etc.) and correctly converted --- to em-dashes, but doesn't support changing font according to size (as I understood from the docs).

  2. Using typescripts, which didn't give me correct alternatives (more below) nor converted --- to em-dashes. I was not capable to understand how to configure optical sizes this way (although it seems to be the recommended way).

With typescripts, regular italics were converted to semibold italics. I put semibold declarations on typescript, but not in regular italics. My typescript declaration and usage:

\definebodyfontenvironment[default][em=italic]
\definebodyfontenvironment[12pt][interlinespace=4.2ex]
\definebodyfontenvironment[10pt][interlinespace=3.2ex]

\starttypescript [serif] [garamond]
  \setups [font:fallback:serif]
  \definefontsynonym [Garamond-Regular]         [name:Garamond Premier Pro Regular]
  \definefontsynonym [Garamond-Italic]          [name:Garamond Premier Pro Italic]
  \definefontsynonym [Garamond-Medium]          [name:Garamond Premier Pro Medium]
  \definefontsynonym [Garamond-Semibold]        [name:Garamond Premier Pro Semibold]
  \definefontsynonym [Garamond-Bold]            [name:Garamond Premier Pro Bold]
  \definefontsynonym [Garamond-MediumItalic]    [name:Garamond Premier Pro Medium Italic]
  \definefontsynonym [Garamond-SemiboldItalic]  [name:Garamond Premier Pro Semibold Italic]
  \definefontsynonym [Garamond-BoldItalic]      [name:Garamond Premier Pro Bold Italic]
\stoptypescript

\starttypescript [serif] [garamond]
  \definefontsynonym [Serif]                [Garamond-Regular]
  \definefontsynonym [SerifItalic]          [Garamond-Italic]
  \definefontsynonym [SerifSlanted]         [Garamond-Italic]
  \definefontsynonym [SerifMedium]          [Garamond-Medium]
  \definefontsynonym [SerifSemibold]        [Garamond-Semibold]
  \definefontsynonym [SerifBold]            [Garamond-Bold]
  \definefontsynonym [SerifMediumItalic]    [Garamond-MediumItalic]
  \definefontsynonym [SerifSemiboldItalic]  [Garamond-SemiboldItalic]
  \definefontsynonym [SerifBoldItalic]      [Garamond-BoldItalic]
  \definefontsynonym [SerifBoldSlanted]     [Garamond-BoldItalic]
\stoptypescript

\starttypescript [garamond]
  \definetypeface   [garamond] [rm] [serif] [garamond] [default]
\stoptypescript

\usetypescript [serif] [garamond]
\usetypescript [garamond]
\setupbodyfont [garamond, 12pt]

Thanks in advance!

1 Answers1

8

You have to use font Goodies to use design sizes. Font Goodies are Lua scripts which return a table with extra information about the font and are loaded at runtime. More about Goodies can be found in chapter 5.4 “Goodies” in Fonts out of ConTeXt (PDF).

garamond-premier.lfg

return {
    name = "garamond-premier",
    version = "1.00",
    comment = "Goodies that complement Garamond Premier Pro.",
    author = "Adobe",
    copyright = "ConTeXt development team",
    designsizes = {
        ["GaramondPremier-Regular"] = {
            [ "4pt"] = "file:GaramondPremrPro-Capt.otf",
            [ "5pt"] = "file:GaramondPremrPro-Capt.otf",
            [ "6pt"] = "file:GaramondPremrPro-Capt.otf",
            [ "7pt"] = "file:GaramondPremrPro.otf",
            [ "8pt"] = "file:GaramondPremrPro.otf",
            [ "9pt"] = "file:GaramondPremrPro.otf",
            ["10pt"] = "file:GaramondPremrPro.otf",
            ["11pt"] = "file:GaramondPremrPro.otf",
            ["12pt"] = "file:GaramondPremrPro.otf",
            ["13pt"] = "file:GaramondPremrPro-Subh.otf",
            ["14pt"] = "file:GaramondPremrPro-Subh.otf",
            ["15pt"] = "file:GaramondPremrPro-Subh.otf",
            ["16pt"] = "file:GaramondPremrPro-Subh.otf",
            ["17pt"] = "file:GaramondPremrPro-Subh.otf",
            ["18pt"] = "file:GaramondPremrPro-Subh.otf",
            ["19pt"] = "file:GaramondPremrPro-Subh.otf",
            ["20pt"] = "file:GaramondPremrPro-Disp.otf",
            ["21pt"] = "file:GaramondPremrPro-Disp.otf",
            ["22pt"] = "file:GaramondPremrPro-Disp.otf",
            default  = "file:GaramondPremrPro.otf",
        },
        ["GaramondPremier-Italic"] = {
            [ "4pt"] = "file:GaramondPremrPro-ItCapt.otf",
            [ "5pt"] = "file:GaramondPremrPro-ItCapt.otf",
            [ "6pt"] = "file:GaramondPremrPro-ItCapt.otf",
            [ "7pt"] = "file:GaramondPremrPro-It.otf",
            [ "8pt"] = "file:GaramondPremrPro-It.otf",
            [ "9pt"] = "file:GaramondPremrPro-It.otf",
            ["10pt"] = "file:GaramondPremrPro-It.otf",
            ["11pt"] = "file:GaramondPremrPro-It.otf",
            ["12pt"] = "file:GaramondPremrPro-It.otf",
            ["13pt"] = "file:GaramondPremrPro-ItSubh.otf",
            ["14pt"] = "file:GaramondPremrPro-ItSubh.otf",
            ["15pt"] = "file:GaramondPremrPro-ItSubh.otf",
            ["16pt"] = "file:GaramondPremrPro-ItSubh.otf",
            ["17pt"] = "file:GaramondPremrPro-ItSubh.otf",
            ["18pt"] = "file:GaramondPremrPro-ItSubh.otf",
            ["19pt"] = "file:GaramondPremrPro-ItSubh.otf",
            ["20pt"] = "file:GaramondPremrPro-ItDisp.otf",
            ["21pt"] = "file:GaramondPremrPro-ItDisp.otf",
            ["22pt"] = "file:GaramondPremrPro-ItDisp.otf",
            default  = "file:GaramondPremrPro-It.otf",
        },
        ["GaramondPremier-Bold"] = {
            [ "4pt"] = "file:GaramondPremrPro-BdCapt.otf",
            [ "5pt"] = "file:GaramondPremrPro-BdCapt.otf",
            [ "6pt"] = "file:GaramondPremrPro-BdCapt.otf",
            [ "7pt"] = "file:GaramondPremrPro-Bd.otf",
            [ "8pt"] = "file:GaramondPremrPro-Bd.otf",
            [ "9pt"] = "file:GaramondPremrPro-Bd.otf",
            ["10pt"] = "file:GaramondPremrPro-Bd.otf",
            ["11pt"] = "file:GaramondPremrPro-Bd.otf",
            ["12pt"] = "file:GaramondPremrPro-Bd.otf",
            ["13pt"] = "file:GaramondPremrPro-BdSubh.otf",
            ["14pt"] = "file:GaramondPremrPro-BdSubh.otf",
            ["15pt"] = "file:GaramondPremrPro-BdSubh.otf",
            ["16pt"] = "file:GaramondPremrPro-BdSubh.otf",
            ["17pt"] = "file:GaramondPremrPro-BdSubh.otf",
            ["18pt"] = "file:GaramondPremrPro-BdSubh.otf",
            ["19pt"] = "file:GaramondPremrPro-BdSubh.otf",
            ["20pt"] = "file:GaramondPremrPro-BdDisp.otf",
            ["21pt"] = "file:GaramondPremrPro-BdDisp.otf",
            ["22pt"] = "file:GaramondPremrPro-BdDisp.otf",
            default  = "file:GaramondPremrPro-Bd.otf",
        },
        ["GaramondPremier-BoldItalic"] = {
            [ "4pt"] = "file:GaramondPremrPro-BdItCapt.otf",
            [ "5pt"] = "file:GaramondPremrPro-BdItCapt.otf",
            [ "6pt"] = "file:GaramondPremrPro-BdItCapt.otf",
            [ "7pt"] = "file:GaramondPremrPro-BdIt.otf",
            [ "8pt"] = "file:GaramondPremrPro-BdIt.otf",
            [ "9pt"] = "file:GaramondPremrPro-BdIt.otf",
            ["10pt"] = "file:GaramondPremrPro-BdIt.otf",
            ["11pt"] = "file:GaramondPremrPro-BdIt.otf",
            ["12pt"] = "file:GaramondPremrPro-BdIt.otf",
            ["13pt"] = "file:GaramondPremrPro-BdItSubh.otf",
            ["14pt"] = "file:GaramondPremrPro-BdItSubh.otf",
            ["15pt"] = "file:GaramondPremrPro-BdItSubh.otf",
            ["16pt"] = "file:GaramondPremrPro-BdItSubh.otf",
            ["17pt"] = "file:GaramondPremrPro-BdItSubh.otf",
            ["18pt"] = "file:GaramondPremrPro-BdItSubh.otf",
            ["19pt"] = "file:GaramondPremrPro-BdItSubh.otf",
            ["20pt"] = "file:GaramondPremrPro-BdItDisp.otf",
            ["21pt"] = "file:GaramondPremrPro-BdItDisp.otf",
            ["22pt"] = "file:GaramondPremrPro-BdItDisp.otf",
            default  = "file:GaramondPremrPro-BdIt.otf",
        },
        ["GaramondPremier-Medium"] = {
            [ "4pt"] = "file:GaramondPremrPro-MedCapt.otf",
            [ "5pt"] = "file:GaramondPremrPro-MedCapt.otf",
            [ "6pt"] = "file:GaramondPremrPro-MedCapt.otf",
            [ "7pt"] = "file:GaramondPremrPro-Med.otf",
            [ "8pt"] = "file:GaramondPremrPro-Med.otf",
            [ "9pt"] = "file:GaramondPremrPro-Med.otf",
            ["10pt"] = "file:GaramondPremrPro-Med.otf",
            ["11pt"] = "file:GaramondPremrPro-Med.otf",
            ["12pt"] = "file:GaramondPremrPro-Med.otf",
            ["13pt"] = "file:GaramondPremrPro-MedSubh.otf",
            ["14pt"] = "file:GaramondPremrPro-MedSubh.otf",
            ["15pt"] = "file:GaramondPremrPro-MedSubh.otf",
            ["16pt"] = "file:GaramondPremrPro-MedSubh.otf",
            ["17pt"] = "file:GaramondPremrPro-MedSubh.otf",
            ["18pt"] = "file:GaramondPremrPro-MedSubh.otf",
            ["19pt"] = "file:GaramondPremrPro-MedSubh.otf",
            ["20pt"] = "file:GaramondPremrPro-MedDisp.otf",
            ["21pt"] = "file:GaramondPremrPro-MedDisp.otf",
            ["22pt"] = "file:GaramondPremrPro-MedDisp.otf",
            default  = "file:GaramondPremrPro-Med.otf",
        },
        ["GaramondPremier-MediumItalic"] = {
            [ "4pt"] = "file:GaramondPremrPro-MedItCapt.otf",
            [ "5pt"] = "file:GaramondPremrPro-MedItCapt.otf",
            [ "6pt"] = "file:GaramondPremrPro-MedItCapt.otf",
            [ "7pt"] = "file:GaramondPremrPro-MedIt.otf",
            [ "8pt"] = "file:GaramondPremrPro-MedIt.otf",
            [ "9pt"] = "file:GaramondPremrPro-MedIt.otf",
            ["10pt"] = "file:GaramondPremrPro-MedIt.otf",
            ["11pt"] = "file:GaramondPremrPro-MedIt.otf",
            ["12pt"] = "file:GaramondPremrPro-MedIt.otf",
            ["13pt"] = "file:GaramondPremrPro-MedItSubh.otf",
            ["14pt"] = "file:GaramondPremrPro-MedItSubh.otf",
            ["15pt"] = "file:GaramondPremrPro-MedItSubh.otf",
            ["16pt"] = "file:GaramondPremrPro-MedItSubh.otf",
            ["17pt"] = "file:GaramondPremrPro-MedItSubh.otf",
            ["18pt"] = "file:GaramondPremrPro-MedItSubh.otf",
            ["19pt"] = "file:GaramondPremrPro-MedItSubh.otf",
            ["20pt"] = "file:GaramondPremrPro-MedItDisp.otf",
            ["21pt"] = "file:GaramondPremrPro-MedItDisp.otf",
            ["22pt"] = "file:GaramondPremrPro-MedItDisp.otf",
            default  = "file:GaramondPremrPro-MedIt.otf",
        },
        ["GaramondPremier-Semibold"] = {
            [ "4pt"] = "file:GaramondPremrPro-SmbdCapt.otf",
            [ "5pt"] = "file:GaramondPremrPro-SmbdCapt.otf",
            [ "6pt"] = "file:GaramondPremrPro-SmbdCapt.otf",
            [ "7pt"] = "file:GaramondPremrPro-Smbd.otf",
            [ "8pt"] = "file:GaramondPremrPro-Smbd.otf",
            [ "9pt"] = "file:GaramondPremrPro-Smbd.otf",
            ["10pt"] = "file:GaramondPremrPro-Smbd.otf",
            ["11pt"] = "file:GaramondPremrPro-Smbd.otf",
            ["12pt"] = "file:GaramondPremrPro-Smbd.otf",
            ["13pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
            ["14pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
            ["15pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
            ["16pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
            ["17pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
            ["18pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
            ["19pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
            ["20pt"] = "file:GaramondPremrPro-SmbdDisp.otf",
            ["21pt"] = "file:GaramondPremrPro-SmbdDisp.otf",
            ["22pt"] = "file:GaramondPremrPro-SmbdDisp.otf",
            default  = "file:GaramondPremrPro-Smbd.otf",
        },
        ["GaramondPremier-SemiboldItalic"] = {
            [ "4pt"] = "file:GaramondPremrPro-SmbdItCapt.otf",
            [ "5pt"] = "file:GaramondPremrPro-SmbdItCapt.otf",
            [ "6pt"] = "file:GaramondPremrPro-SmbdItCapt.otf",
            [ "7pt"] = "file:GaramondPremrPro-SmbdIt.otf",
            [ "8pt"] = "file:GaramondPremrPro-SmbdIt.otf",
            [ "9pt"] = "file:GaramondPremrPro-SmbdIt.otf",
            ["10pt"] = "file:GaramondPremrPro-SmbdIt.otf",
            ["11pt"] = "file:GaramondPremrPro-SmbdIt.otf",
            ["12pt"] = "file:GaramondPremrPro-SmbdIt.otf",
            ["13pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
            ["14pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
            ["15pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
            ["16pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
            ["17pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
            ["18pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
            ["19pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
            ["20pt"] = "file:GaramondPremrPro-SmbdItDisp.otf",
            ["21pt"] = "file:GaramondPremrPro-SmbdItDisp.otf",
            ["22pt"] = "file:GaramondPremrPro-SmbdItDisp.otf",
            default  = "file:GaramondPremrPro-SmbdIt.otf",
        },
    },
}

type-imp-garamond-premier.mkiv

\starttypescriptcollection[garamond-premier]

  \starttypescript [serif] [garamond-premier] [all]
    \loadfontgoodies[garamond-premier]
    \definefontsynonym [Serif]                [GaramondPremier-Regular]        [features=default,goodies=garamond-premier]
    \definefontsynonym [SerifItalic]          [GaramondPremier-Italic]         [features=default,goodies=garamond-premier]
    \definefontsynonym [SerifSlanted]         [SerifItalic]
    \definefontsynonym [SerifBold]            [GaramondPremier-Bold]           [features=default,goodies=garamond-premier]
    \definefontsynonym [SerifBoldItalic]      [GaramondPremier-BoldItalic]     [features=default,goodies=garamond-premier]
    \definefontsynonym [SerifBoldSlanted]     [SerifBoldItalic]
    \definefontsynonym [SerifMedium]          [GaramondPremier-Medium]         [features=default,goodies=garamond-premier]
    \definefontsynonym [SerifMediumItalic]    [GaramondPremier-MediumItalic]   [features=default,goodies=garamond-premier]
    \definefontsynonym [SerifMediumSlanted]   [SerifMediumItalic]
    \definefontsynonym [SerifSemibold]        [GaramondPremier-Semibold]       [features=default,goodies=garamond-premier]
    \definefontsynonym [SerifSemiboldItalic]  [GaramondPremier-SemiboldItalic] [features=default,goodies=garamond-premier]
    \definefontsynonym [SerifSemiboldSlanted] [SerifSemiboldItalic]
    \definefontsynonym [SerifCaps]            [Serif]                          [features=smallcaps]
  \stoptypescript

  \starttypescript [garamond-premier]
    \definetypeface [\typescriptone] [rm] [serif] [\typescriptone] [default] [designsize=auto]
    \definetypeface [\typescriptone] [ss] [sans]  [dejavu]         [default] [rscale=0.8]
    \definetypeface [\typescriptone] [tt] [mono]  [dejavu]         [default] [rscale=0.8]
    \definetypeface [\typescriptone] [mm] [math]  [dejavu]         [default] [rscale=0.8]
  \stoptypescript

\stoptypescriptcollection

You probably want to use a sans-serif, mono, and math font other than DejaVu. I just added them here for completeness. You should not leave any of these out because if you attempt to use them and they are not defined, strange things happen.

Font alternative can only have two letters, because ConTeXt will use anything after it as the size specifier, as the b in \tfb.

Then you can use this in your document via

\loadtypescriptfile[garamond-premier]

\definefontalternative[mf]
\definefontalternative[mi]
\definefontalternative[ms]
\definefontalternative[sf]
\definefontalternative[si]
\definefontalternative[ss]

\definebodyfont [default] [rm]
  [tf=Serif            sa 1,
   bf=SerifBold        sa 1,
   it=SerifItalic      sa 1,
   sl=SerifSlanted     sa 1,
   bi=SerifBoldItalic  sa 1,
   bs=SerifBoldSlanted sa 1,
   sc=SerifCaps        sa 1,
   %
   mf=SerifMedium        sa 1,
   mi=SerifMediumItalic  sa 1,
   ms=SerifMediumSlanted sa 1,
   %
   sf=SerifSemibold        sa 1,
   si=SerifSemiboldItalic  sa 1,
   ss=SerifSemiboldSlanted sa 1]
\stoptypescript

\setupbodyfont[garamond-premier]

\setuppapersize [A4,landscape]

\starttext

\dorecurse{22}{
  \switchtobodyfont[\recurselevel pt]
  \recurselevel\
  Regular
  \italic{Italic}
  \bold{Bold}
  \bolditalic{Bold italic}
  {\mf Medium}
  {\mi Medium italic}
  {\sf Semibold}
  {\si Semibold italic}
  \par
}

\stoptext

enter image description here

As you can see, this does not look really continuous. This is because I have guessed the values at which the different design sizes should be used. In production, one should carefully fine tune these to achieve a more continuous behaviour.

The output of pdffonts confirms that all fonts are embedded.

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
EKDZXO+GaramondPremrPro-Capt         CID Type 0C       Identity-H       yes yes yes      4  0
HXIZMD+GaramondPremrPro-ItCapt       CID Type 0C       Identity-H       yes yes yes      5  0
YCEHGM+GaramondPremrPro-BdCapt       CID Type 0C       Identity-H       yes yes yes      6  0
LXMWZN+GaramondPremrPro-BdItCapt     CID Type 0C       Identity-H       yes yes yes      7  0
YSTBXJ+GaramondPremrPro-MedCapt      CID Type 0C       Identity-H       yes yes yes      8  0
UZWASV+GaramondPremrPro-MedItCapt    CID Type 0C       Identity-H       yes yes yes      9  0
BCZEUK+GaramondPremrPro-SmbdCapt     CID Type 0C       Identity-H       yes yes yes     10  0
ULHHSI+GaramondPremrPro-SmbdItCapt   CID Type 0C       Identity-H       yes yes yes     11  0
KYSIQC+GaramondPremrPro              CID Type 0C       Identity-H       yes yes yes     12  0
ZQKUVZ+GaramondPremrPro-It           CID Type 0C       Identity-H       yes yes yes     13  0
NEOZVY+GaramondPremrPro-Bd           CID Type 0C       Identity-H       yes yes yes     14  0
JHIVFR+GaramondPremrPro-BdIt         CID Type 0C       Identity-H       yes yes yes     15  0
EMFOVD+GaramondPremrPro-Subh         CID Type 0C       Identity-H       yes yes yes     16  0
DAPJGX+GaramondPremrPro-ItSubh       CID Type 0C       Identity-H       yes yes yes     17  0
NBZBXV+GaramondPremrPro-BdSubh       CID Type 0C       Identity-H       yes yes yes     18  0
EEPVVZ+GaramondPremrPro-BdItSubh     CID Type 0C       Identity-H       yes yes yes     19  0
DCVBES+GaramondPremrPro-MedSubh      CID Type 0C       Identity-H       yes yes yes     20  0
KRRICW+GaramondPremrPro-MedItSubh    CID Type 0C       Identity-H       yes yes yes     21  0
GNNEBG+GaramondPremrPro-SmbdSubh     CID Type 0C       Identity-H       yes yes yes     22  0
NOXUKA+GaramondPremrPro-SmbdItSubh   CID Type 0C       Identity-H       yes yes yes     23  0
OJMMRC+GaramondPremrPro-Disp         CID Type 0C       Identity-H       yes yes yes     24  0
CHNDOC+GaramondPremrPro-ItDisp       CID Type 0C       Identity-H       yes yes yes     25  0
MPPVHL+GaramondPremrPro-BdDisp       CID Type 0C       Identity-H       yes yes yes     26  0
MMQBOJ+GaramondPremrPro-BdItDisp     CID Type 0C       Identity-H       yes yes yes     27  0
AFGIHW+GaramondPremrPro-MedDisp      CID Type 0C       Identity-H       yes yes yes     28  0
VYQMOL+GaramondPremrPro-MedItDisp    CID Type 0C       Identity-H       yes yes yes     29  0
ZZMXKE+GaramondPremrPro-SmbdDisp     CID Type 0C       Identity-H       yes yes yes     30  0
LUNAOE+GaramondPremrPro-SmbdItDisp   CID Type 0C       Identity-H       yes yes yes     31  0

System-wide installation

For a system-wide installation you can put the files into appropriate locations in the ConTeXt tree. I just use the local tree within the ConTeXt installation. I show all the commands together with the output they produce on my machine. These might of course differ from yours.

First we get the path of the local tree and then we go there.

$ mtxrun --resolve-path '$TEXMFLOCAL'
/opt/context/tex/texmf-local
$ cd /opt/context/tex/texmf-local

Now we make a directory for the typescript files.

$ mkdir -p tex/context/fonts/mkiv/

In this new directory, create the two files garamond-premier.lfg and type-imp-garamond-premier.mkiv with the contents from above.

Now we make a directory for the OpenType font files. I follow the convention of the directory name scheme <foundry>/<fontname>.

$ mkdir -p fonts/opentype/adobe/garamond-premier/

Place all the OpenType files in there.

Because we have added new files to the tree, we have to rebuild the filename database. This is done using

$ mtxrun --generate

This will take a moment and print a lot of messages to the terminal. Afterwards, you can check whether the new files are detected in the tree

$ mtxrun --find-file garamond-premier.lfg
/opt/context/tex/texmf-local/tex/context/fonts/mkiv/garamond-premier.lfg
$ mtxrun --find-file type-imp-garamond-premier.mkiv
/opt/context/tex/texmf-local/tex/context/fonts/mkiv/type-imp-garamond-premier.mkiv
$ mtxrun --find-file GaramondPremrPro.otf
/opt/context/tex/texmf-local/fonts/opentype/adobe/garamond-premier/GaramondPremrPro.otf

If that all works, you are ready to typeset your document. The typescript should automatically found by \setupbodyfont[garamond-premier] (no \usetypescriptfile or similar necessary).

Henri Menke
  • 109,596
  • Wow, thank you!!! I didn't know that specific doc, "Fonts out of ConTeXt"! Thank you, this should be sufficient (semibold and medium alternatives, I guess, can be managed the same way, creating custom alternatives). – Josí Neto Dec 20 '18 at 16:21
  • 2
    @JosédeMattosNeto You might be interested in The definitive guide to ConTeXt MkIV documentation. – Henri Menke Dec 20 '18 at 19:45
  • +1 Exactly what the second half of ConTeXt: Define fonts with additional non-standard styles, alternatives and sizes was asking, without using the terminology. My second MWE tried to automatically switch between the text and display optical sizes of the Libertinus font using \definebodyfont... which for several reasons didn't work. – user19087 Dec 21 '18 at 03:06
  • @HenriMenke in the goodies file, it seems that one should declare all sizes used, not ranges as you suggested. I tested your code and opened the PDF in Acrobat to see size vs. font used, and without declaring sizes explicitly it doesn't use my ranges, but seems to use default ranges (caption < 8, regular < 12, subhead < 16, display above). BTW, all-sizes-declared is the way built-in goodies work (for instance lm.lfg). – Josí Neto Dec 21 '18 at 04:59
  • I'm still struggling with where to put .lfg and .mkiv files... I tried to put them in ConTeXt directory (context/tex/texmf-context/tex/context/fonts/mkiv), but it doesn't work (and files are erased at updating). I tried to put them in parent directory of that of .tex file, and declare \usetypescriptfile[type-imp-garamond-premier], also without success... (in production, I'm unable to put them in same directory of .tex file, only in parent directory). – Josí Neto Dec 21 '18 at 05:05
  • @JosédeMattosNeto They just go in the same directory as your document, along with the .otf files for the font. Unless you want to install this system-wide, then it gets a bit trickier. – Henri Menke Dec 21 '18 at 05:17
  • 1
    @JosédeMattosNeto I've added a section on system-wide installation to my answer. – Henri Menke Dec 21 '18 at 05:34
  • It works like a charm with all optical sizes and most common styles (regular, italics, bold and bold italics). But the font also has medium and semibold styles, which I want to use. I'll open a new question about that. Thank you!! – Josí Neto Dec 24 '18 at 04:17
  • @JosédeMattosNeto I have added the medium and semibold weights to the typescript and goodies as well. However, please take this piece of typographic advice and do not use more than two distinct weights in your document. – Henri Menke Dec 24 '18 at 21:42
  • Many thanks again, @HenriMenke ! It works!!! I changed your solution a little bit: I put \definebodyfont inside typescript file (as this define should always be used with that typescript) and added size modifiers (like \tfa, tfx, but with new weights). But \em still doesn't work (as expected): it puts text in regular italics (like \tf \it). I will search a work around for that. – Josí Neto Dec 26 '18 at 17:45
  • @HenriMenke thank you for the typographic advice! I use semibold and medium weights only in headings and lines of document cover, never in body text, so I don't think this would be a problem. But thank you anyway! – Josí Neto Dec 26 '18 at 17:47
  • Well, I've searched how to redefine or extend \em, but didn't find anything, neither here in TexExchange nor in ConTeXt site or documentation... @HenriMenke if you know anything about that, please share with us. Thank you again! – Josí Neto Dec 26 '18 at 18:06
  • @JosédeMattosNeto What do you mean by “\em doesn't work”? Garamond Premier has no slanted font, so I just use italics in place. – Henri Menke Dec 26 '18 at 19:36
  • Using \definebodyfontenvironment[default][em=italic], one can use \em to get italics instead of slant. But when using medium or semibold weight, \em doesn't switch between regular and italics of current weight, but turns to regular weight. E.g., in semibold context, the code text {\em italics} text is rendered as: 1st and 3rd words semibold, 2nd word regular italics. I'm worried about \em because I'm not writing directly in ConTeXt, but instead in Markdown and then converting to ConTeXt using Pandoc, which uses \em for italics. – Josí Neto Dec 26 '18 at 21:40
  • @JosédeMattosNeto ConTeXt only knows the two canonical weights Regular and Bold. Because Medium and Semibold were patched in, macros like \em are not aware of it. – Henri Menke Dec 27 '18 at 02:31