Flexi Face

From ConTeXt wiki
Jump to navigationJump to search

< Fonts

FlexiFace is a system I've been playing with for a few months on and off. Basically, it's to get around the difficulty of creating typefaces for every combination of fonts. It combines typescripts based on just one parameter—x-height—because other parameters (e.g., italic slant, color/weight) are really hard to quantify, and are best left to the typographer's artistry.

Currently, I normalise all fonts to match with Computer Modern Roman's x-height, which is 5.16667 points for a font size of 12 pt. Seeing that that was a little small, I implemented a variation for larger-eyed fonts, where all fonts are normalised around an x-height of 6.0 pt for the same body font size. Following me yet? How about this:

When you use \setupbodyfont[flex], you get the typescripts you called previously, accessible as rm, ss, etc. (as appropriate), all relatively scaled so that their x-height matches up with that of CMR.

Okay then, how about an example. Given the following in a typescript that gets loaded:

\starttypescript[palatino][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][palatino][default][rscale=0.91,encoding=\typescripttwo]
\definetypeface[flex][mm][math][palatino][default][rscale=0.91,encoding=\typescripttwo]
\stoptypescript

\starttypescript[helvetica][texnansi,ec,8r,default]
\definetypeface[flex][ss][sans][helvetica][default][rscale=0.83,encoding=\typescripttwo]
\stoptypescript 

You can use FlexiFace with the following in your source file:

\usetypescript[palatino,helvetica][texnansi]% or ec or 8r
\setupbodyfont[flex,12pt,rm]

...and you get Palatino (serif and math) with Helvetica, both scaled to a compatible x-height. That seems more complex than necessary, given a one-time use, but the power behind FlexiFace lies in the endless combinations, and that it's embedded in the natural \usetypescript calls. Once it's set up, you only need to worry about calling one typeface/bodyfont.

Some side-effects to watch out for:

  • The typeface doesn't make rm the default, so watch out. It's best to put 'rm' (or your choice) into the \setupbodyfont call, as above. (Hans points out that \setuptypeface[flex][default=rm] is just as effective, and it's probably better in a local config file.)
  • An x-height to match CMR is a bit small for most fonts—and it can distort the actual size of the font—so either be aware of this global rescaling (e.g., the “12pt” Palatino above actually comes out at 10.92pt after scaling) or use the flex2 alternative.
  • This system depends on a “correct” ConTeXt font installation—it doesn't manage any magic if you haven't run TeXfont or use the berry typescripts.

The below typescript includes most of the TeXLive fonts supported in ConTeXt's distribution, and the type-microsoft and type-bitstream-vera provided by Hraban. I've kept some of my local extensions just in case they're useful to others as examples.

Here's my current (May/June 2004) type-flex:

% Flexible typefaces
% 2004.04.18 Adam Lindsay
% All flex typefaces are normalised to match with CMR 12pt's x-height: 5.1666667pt
% This may be too low.
% for this reason, I introduced flex2, where fonts are scaled to an x-height of 6.0pt (with a bodyfont of 12pt)
% This may be too high

% default TeXLive fonts

\starttypescript[palatino][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][palatino][default][rscale=0.91,encoding=\typescripttwo]
\definetypeface[flex][mm][math][palatino][default][rscale=0.91,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][palatino][default][rscale=1.057,encoding=\typescripttwo]
\definetypeface[flex2][mm][math][palatino][default][rscale=1.057,encoding=\typescripttwo]
\stoptypescript

\starttypescript[palatinoserif][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][palatino][default][rscale=0.91,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][palatino][default][rscale=1.057,encoding=\typescripttwo]
\stoptypescript

\starttypescript[palatinomath][texnansi,ec,8r,default]
\definetypeface[flex][mm][math][palatino][default][rscale=0.91,encoding=\typescripttwo]
\definetypeface[flex2][mm][math][palatino][default][rscale=1.057,encoding=\typescripttwo]
\stoptypescript

\starttypescript[helvetica][texnansi,ec,8r,default]
\definetypeface[flex][ss][sans][helvetica][default][rscale=0.83,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][helvetica][default][rscale=0.967,encoding=\typescripttwo]
\stoptypescript

\starttypescript[courier][texnansi,ec,8r,default]
\definetypeface[flex][tt][mono][courier][default][encoding=\typescripttwo]
\definetypeface[flex2][tt][mono][courier][default][rscale=1.1612,encoding=\typescripttwo]
\stoptypescript

\starttypescript[schoolbook][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][schoolbook][default][rscale=0.896,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][schoolbook][default][rscale=1.04,encoding=\typescripttwo]
\stoptypescript

\starttypescript[times][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][times][default][rscale=0.937,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][times][default][rscale=1.088,encoding=\typescripttwo]
\definetypeface [flex] [mm] [math]  [times]     [default][rscale=0.96]
\definetypeface [flex2] [mm] [math]  [times]     [default][rscale=1.115]
\stoptypescript

\starttypescript[timesserif][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][times][default][rscale=0.937,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][times][default][rscale=1.088,encoding=\typescripttwo]
\stoptypescript

\starttypescript[timesmath][texnansi,ec,8r,default]
\definetypeface [flex] [mm] [math]  [times]     [default][rscale=0.96]
\definetypeface [flex2] [mm] [math]  [times]     [default][rscale=1.115]
\stoptypescript

\starttypescript[charter][texnansi,ec,8r]
\definetypeface[flex][rm][serif][charter][default][rscale=0.8850,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][charter][default][rscale=1.028,encoding=\typescripttwo]
\stoptypescript

\starttypescript[bookman][texnansi,ec,8r]
\definetypeface[flex][rm][serif][bookman][default][rscale=0.879,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][bookman][default][rscale=1.02,encoding=\typescripttwo]
\stoptypescript

\starttypescript[antykwa-torunska][texnansi,ec,8r,pl0,pl1]
\definetypeface[flex][rm][serif][antykwa-torunska][default][rscale=0.845,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][antykwa-torunska][default][rscale=0.98,encoding=\typescripttwo]
\stoptypescript

\starttypescript[antykwa-poltawskiego][texnansi,ec,8r,pl0,pl1]
\definetypeface[flex][rm][serif][antykwa-poltawskiego][default][rscale=0.969,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][antykwa-poltawskiego][default][rscale=1.125,encoding=\typescripttwo]
\stoptypescript

\starttypescript[cm-mono][texnansi,ec,8r,default]
\definetypeface[flex][tt][mono][computer-modern][computer-modern][encoding=\typescripttwo]
\definetypeface[flex2][tt][mono][computer-modern][computer-modern][rscale=1.1612,encoding=\typescripttwo]
\stoptypescript

\starttypescript[euler][texnansi,ec,8r,default]
\definetypeface[flex][mm][math][euler][euler][rscale=0.95]
\definetypeface[flex2][mm][math][euler][euler][rscale=1.09,encoding=math]
\stoptypescript

\starttypescript[concrete][texnansi,ec,8r,default,pl0]
\definefontsynonym [ccr10] [pcr10]% [encoding=pl0]
\definefontsynonym [ccti10] [pcti10] %[encoding=pl0]
\definefontsynonym [ccsl10] [pcsl10] %[encoding=pl0]
\definefontsynonym [cccsc10] [pccsc10]% [encoding=pl0]
\definefontsynonym [ccr9][pcr9]
\definefontsynonym [ccr8][pcr8]
\definefontsynonym [ccr7][pcr7]
\definefontsynonym [ccr6][pcr6]
\definefontsynonym [ccr5][pcr5]
\definetypeface[flex][rm][serif][concrete][concrete][rscale=0.939,encoding=pl0]
\definetypeface[flex2][rm][serif][concrete][concrete][rscale=1.091,encoding=pl0]
\stoptypescript

\starttypescript[simple][texnansi,ec,8r,default]
  \definetypeface [flex] [rm] [serif] [simple] [default] [encoding=\typescripttwo]
  \definetypeface [flex2] [rm] [serif] [simple] [default] [rscale=1.1612,encoding=\typescripttwo]
\stoptypescript


\starttypescript[latin-modern][default,texnansi,ec,8r] % modern,modern-base are also defined, but not called properly
  \definetypeface [flex] [rm] [serif] [\typescriptone] [computer-modern] [encoding=\typescripttwo]
  \definetypeface [flex] [ss] [sans]  [\typescriptone] [computer-modern] [encoding=\typescripttwo]
  \definetypeface [flex] [tt] [mono]  [\typescriptone] [computer-modern] [encoding=\typescripttwo]
  \definetypeface [flex] [mm] [math]  [\typescriptone] [computer-modern] [encoding=\typescripttwo]
  \definetypeface [flex2] [rm] [serif] [\typescriptone] [computer-modern] [rscale=1.1612,encoding=\typescripttwo]
  \definetypeface [flex2] [ss] [sans]  [\typescriptone] [computer-modern] [rscale=1.1612,encoding=\typescripttwo]
  \definetypeface [flex2] [tt] [mono]  [\typescriptone] [computer-modern] [rscale=1.1612,encoding=\typescripttwo]
  \definetypeface [flex2] [mm] [math]  [\typescriptone] [computer-modern] [rscale=1.1612,encoding=\typescripttwo]
\stoptypescript

% TeXLive, but not normally installed:

\starttypescript[avantgarde][texnansi,ec,8r,default]
\definetypeface[flex][ss][sans][avantgarde][default][rscale=0.80,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][avantgarde][default][rscale=0.92,encoding=\typescripttwo]
\stoptypescript

\starttypescript[utopia][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][utopia][default][rscale=0.882,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][utopia][default][rscale=1.025,encoding=\typescripttwo]
\stoptypescript

\starttypescript[fourier][texnansi,ec,8r,default]
\loadmapfile[fourier]
\definetypeface[flex][mm][math][fourier][default][rscale=0.945,encoding=default]
\definetypeface[flex2][mm][math][fourier][default][rscale=1.097,encoding=default]
\stoptypescript

% atl local: type-loc

\starttypescript[chaparral,chaparrallt][texnansi]   %,ec,8r,default]
\definetypeface[flex][rm][serif][\typescriptone][default][encoding=texnansi,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][\typescriptone][default][rscale=1.1612,encoding=texnansi,encoding=\typescripttwo]
\stoptypescript

\starttypescript[gillsans,gillsanslt][texnansi]  % ,ec,8r,default]
\definetypeface[flex][ss][sans][\typescriptone][default][rscale=0.94,encoding=texnansi,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][\typescriptone][default][rscale=1.092,encoding=texnansi,encoding=\typescripttwo]
\stoptypescript

\starttypescript[eureka][texnansi,ec,8r,default]
\definetypeface[flex][ss][sans][eureka][default][rscale=1.06,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][eureka][default][rscale=1.243,encoding=\typescripttwo]
\stoptypescript

% fiee: type-bitstream-vera
\starttypescript[vera][texnansi,ec,8r]
\definetypeface[flex][ss][sans][vera][default][rscale=0.821,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][vera][default][rscale=0.953,encoding=\typescripttwo]
\definetypeface[flex][rm][serif][vera,fallback][default][rscale=0.821,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][vera,fallback][default][rscale=0.953,encoding=\typescripttwo]
\definetypeface[flex][tt][mono][vera][default][rscale=0.821,encoding=\typescripttwo]
\definetypeface[flex2][tt][mono][vera][default][rscale=0.953,encoding=\typescripttwo]
\stoptypescript

\starttypescript[verasans][texnansi,ec,8r]
\definetypeface[flex][ss][sans][vera][default][rscale=0.821,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][vera][default][rscale=0.953,encoding=\typescripttwo]
\stoptypescript

\starttypescript[veramono][texnansi,ec,8r]
\definetypeface[flex][tt][mono][vera][default][rscale=0.821,encoding=\typescripttwo]
\definetypeface[flex2][tt][mono][vera][default][rscale=0.953,encoding=\typescripttwo]
\stoptypescript

\starttypescript[veraserif][texnansi,ec,8r]
\definetypeface[flex][rm][serif][vera,fallback][default][rscale=0.821,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][vera,fallback][default][rscale=0.953,encoding=\typescripttwo]
\stoptypescript


%% fiee: type-microsoft
\starttypescript[mstimes][texnansi,ec,8r]
\definetypeface[flex][rm][serif][mstimes][default][rscale=0.977,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][mstimes][default][rscale=1.135,encoding=\typescripttwo]
\stoptypescript

\starttypescript[georgia][texnansi,ec,8r]
\definetypeface[flex][rm][serif][georgia][default][rscale=0.916,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][georgia][default][rscale=1.064,encoding=\typescripttwo]
\stoptypescript

\starttypescript[arial][texnansi,ec,8r]
\definetypeface[flex][ss][sans][arial][default][rscale=0.862,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][arial][default][rscale=1,encoding=\typescripttwo]
\stoptypescript

\starttypescript[trebuchet][texnansi,ec,8r]
\definetypeface[flex][ss][sans][trebuchet][default][rscale=0.85,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][trebuchet][default][rscale=0.99,encoding=\typescripttwo]
\stoptypescript

\starttypescript[verdana][texnansi,ec,8r]
\definetypeface[flex][ss][sans][verdana][default][rscale=0.804,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][verdana][default][rscale=0.938,encoding=\typescripttwo]
\stoptypescript

\starttypescript[mscourier][texnansi,ec,8r]
\definetypeface[flex][tt][mono][mscourier][default][rscale=1.036,encoding=\typescripttwo]
\definetypeface[flex2][tt][mono][mscourier][default][rscale=1.21,encoding=\typescripttwo]
\stoptypescript

\starttypescript[andale][texnansi,ec,8r]
\definetypeface[flex][tt][mono][andale,fallback][default][rscale=0.843,encoding=\typescripttwo]
\definetypeface[flex2][tt][mono][andale,fallback][default][rscale=0.989,encoding=\typescripttwo]
\stoptypescript

\starttypescript[comic][texnansi,ec,8r]
\definetypeface[flex][hw][handwriting][comic][default][rscale=0.845,encoding=\typescripttwo]
\definetypeface[flex2][hw][handwriting][comic][default][rscale=1,encoding=\typescripttwo]
\stoptypescript



% for PDF built-in fonts:
\starttypescript[adobekb][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][times][default][rscale=0.957,encoding=\typescripttwo]
\definetypeface[flex][ss][sans][helvetica][default][rscale=0.823,encoding=\typescripttwo]
\definetypeface[flex][tt][mono][courier][default][encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][times][default][rscale=1.111,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][helvetica][default][rscale=0.956,encoding=\typescripttwo]
\definetypeface[flex2][tt][mono][courier][default][rscale=1.1612,encoding=\typescripttwo]
\stoptypescript

% measurements made using the java Lucida on MacOSX:
\starttypescript[lucida][texnansi,ec,8r,default]
\definetypeface[flex][rm][serif][lucida][default][rscale=0.803]%,encoding=\typescripttwo]
\definetypeface[flex][ss][sans][lucida][default][rscale=0.803]%,encoding=\typescripttwo]
\definetypeface[flex][tt][mono][lucida][default][rscale=0.803]%,encoding=\typescripttwo]
\definetypeface[flex2][rm][serif][lucida][default][rscale=0.932]%,encoding=\typescripttwo]
\definetypeface[flex2][ss][sans][lucida][default][rscale=0.932]%,encoding=\typescripttwo]
\definetypeface[flex2][tt][mono][lucida][default][rscale=0.932]%,encoding=\typescripttwo]
\stoptypescript

\endinput