diff options
Diffstat (limited to 'usergrps/uktug/baskervi/4_1/duggan.tex')
-rw-r--r-- | usergrps/uktug/baskervi/4_1/duggan.tex | 430 |
1 files changed, 430 insertions, 0 deletions
diff --git a/usergrps/uktug/baskervi/4_1/duggan.tex b/usergrps/uktug/baskervi/4_1/duggan.tex new file mode 100644 index 0000000000..9289d5c9bc --- /dev/null +++ b/usergrps/uktug/baskervi/4_1/duggan.tex @@ -0,0 +1,430 @@ +\special{header courier.pfb} +% oxford.tex -*- LaTeX -*- +% AJCD 15/1/94 +% Notes for UKTUG meeting on PostScript fonts, Wed 19th Jan 1994 +% +%\newcommand\th{\raisebox{.6ex}{\protect\small\protect\small th}} +%%\newcommand\st{\raisebox{.6ex}{\protect\small\protect\small st}} +%\newcommand\rd{\raisebox{.6ex}{\protect\small\protect\small rd}} + +\title{Mixing and matching PostScript fonts} +\author[Angus Duggan]{Angus Duggan\\ +Harlequin Ltd.\\ +Barrington Hall\\ +Barrington\\ +Cambridge CB2 5RG\\[2pt] +\tt angus@harlequin.co.uk} +\begin{Article} +\section{Introduction} +The Apple LaserWriter\footnote{LaserWriter is a trademark of Apple + Computer, Inc.} was the product that introduced +PostScript\footnote{PostScript is a trademark of Adobe Systems + Incorporated.} to the world, bringing in its wake a major change in +the publishing and printing industry. PostScript is now used +everywhere from the home to high-quality printing presses. + +PostScript also made scalable font technology popular; instead of using +bitmaps for one particular resolution and font size, outlines can be scaled to +the size required quickly. The original LaserWriter came with a set of +thirteen scalable outline fonts, often known as the ``LaserWriter 13''. The +LaserWriter fonts are shown in table~\ref{tab:lw13}; there are eight faces +from Linotype AG (the Times and Helvetica families), four from IBM (the +Courier family), and one from Adobe (Symbol). There is one serifed text face +family (Times) and an accompanying mathematical symbol set (Symbol), one +sans-serif text face family (Helvetica), and one monospaced family (Courier). + +\begin{table}[H] +\footnotesize +\begin{tabular}{lll} +Times-Roman & Helvetica & Courier\\ +Times-Bold & Helvetica-Bold & Courier-Bold\\ +Times-Italic & Helvetica-Oblique & Courier-Oblique\\ +Times-BoldItalic & Helvetica-BoldOblique & Courier-BoldOblique\\ +Symbol & & \\ +\end{tabular} +\caption{The original 13 LaserWriter fonts}\label{tab:lw13} +\end{table} + +The choice of typeface styles for the LaserWriter was well-informed\,---\,for +computer usage a monospaced font is required. The mathematical symbol set, +while not complete, encouraged technical writers to invest in PostScript laser +printers. A choice of a serif and sans-serif font families was provided for +text setting. + +Unfortunately, the particular typefaces chosen look terrible when used +together. + +%Technical writing often needs different typefaces to distinguish between +%different elements. For example, output from computers or input to computers, +%especially where the exact format is important, are often set in monospaced +%fonts. Similarly, sans-serif are often used to distinguish different elements +%of the document. + +The weight and width differences between the LaserWriter 13 fonts make the +page look blotchy; some words jump out at the reader, some seem to vanish, +leaving pale holes in the page. Variations in width, ex-height (the height of +the lowercase letters, traditionally measured from the lowercase x), and +to a lesser extent capital height make the text less legible. +Given these problems with documents composed with the original LaserWriter +fonts, why not use other fonts? The answer to this question depends on the +purpose of the document. + +If a document is being created for personal reading, or for a number of people +at one place, then purchasing a set of typefaces which complement each other +is an admirable solution. Similarly, if the document is being prepared for +publication, purchasing and using the fonts suggested by the designer or +printer is advised. + +If the PostScript source of the document is being distributed to a wider +audience, with no knowledge of the facilities on which it will be printed, +then the story is different. The original thirteen LaserWriter fonts are the +only fonts that can be guaranteed to be available on any PostScript laser +printer or previewer, anywhere in the world.\footnote{There is a larger set of +35 fonts which was distributed with the LaserWriter Plus which are available +on most PostScript printers now. There are still original LaserWriters in +use, so I still consider the original 13 fonts as the only guaranteed fonts.} +There is also the major consideration that giving away the fonts used in a +document (even if they are embedded in the document) may be illegal under +copyright law or licensing agreements. Even if the fonts required to print a +document are freely distributable, using the resident fonts has the beneficial +side effect of reducing the size of the document. + +A growing number of scientific papers, software manuals and technical notes +are being made available in PostScript form, and many of these use the ugly +combination of the original LaserWriter fonts. + +Fortunately, the outline descriptions of fonts in PostScript allow us to do +something about the variations in width, height and weight of the fonts. +Anamorphic scaling can be used to squash wide characters, stretch short +characters, and even slant characters to create obliqued fonts if desired. +PostScript also has tricks which can be used the thicken light characters. + + + +\section{Matching fonts} +To match the width and height of characters from different fonts better, we +need to scale the characters {\em anamorphically\/}; that is, to alter their +aspect ratio. +The idea is to make the weight, width, x- and cap height of the fonts more +consistent, so that they are have a similar colour. (The colour of a font is +the amount of ink or toner that is placed on the page when printing; open, +wide fonts have a less colour than close, heavy fonts.) +The change of letterform still provides cues to the distinction between the +elements of the page, but the anoying distractions of light spaces and dark +blobs will be removed. The more even height of characters will aid legibility. + +\TeX\ cannot scale characters anamorphically, so a small amount of PostScript +and virtual font work will be necessary. All of the matching steps I will +describe can be done in PostScript alone, but virtual fonts make the process +of using \TeX\ with the altered fonts much easier. The examples given are for +use with Rokicki's {\tt dvips} driver, but the techniques can be adapted to +most DVI to PostScript converters. + +\subsection{Matching heights} +The first step in the process of scaling fonts to match is to sort out the +height differences. There are two parts to consider; to match the ex-height so +that running text looks good, and to match the capital height so that headers +look good. Figure~\ref{fig:normal} shows the wide variation in width, weight +and height of the LaserWriter fonts. + +\begin{figure*}[htb] +\begin{center}\leavevmode +\epsfbox{normal.ps} +\caption{Width, height and weight variation in the LaserWriter fonts} +\label{fig:normal} +\end{center} +\end{figure*} + + +\TeX\ can be used to match the ex-heights of fonts automatically. The following +(relatively obscure) piece of \LaTeX\ code uses the ``ex'' fontdimen to +construct and use a \LaTeX2e\ font definition for a font scaled to match the +ex-height of the current font. (This piece of code relies on a macro which +does long division of one integer by another, returning a fractional result. +For clarity's sake, this macro is not included.) + +\begin{small} +\begin{verbatim} +%% need long division routine +\input longdiv.sty % omitted for clarity! + +\def\psexfont#1#2#3#4#5{{% + \@tempdima=1ex% ex-height of current font + \font\tmp=#5\space at\f@size pt + \tmp\@tempdimb=1ex% ex-height of loaded font + \@tempcnta\@tempdima \@tempcntb\@tempdimb + % long division result in ex@scale macro + \long@divide\ex@scale\@tempcnta\@tempcntb + \edef\psex@sizes{<->[\ex@scale]#5}% + \DeclareFontShape{#1}{#2}{#3}{#4}% + {\psex@sizes}{}}% +} + +% Times-Roman at same ex-height as current font +\DeclareFontFamily{OT1}{times-xm}{} +\psexfont{OT1}{times-xm}{m}{n}{ptmr} +\end{verbatim} +\end{small} + +There are disadvantages to this method; it wastes one of \TeX's precious font +slots for every font loaded, and sometimes the fontdimen is not accurate, +either because of rounding errors in the conversion or because of incorrect +information in the original AFM file (Adobe Font Metric\,---\,the standard +files containing metric information for PostScript fonts). + +A method which avoids the loss of the font slot is to create a virtual font +containing the scaled font. The amount to scale the font by can be determined +either by comparing the ex-height parameters in the original AFM files, or +printing out large character samples and measuring the ex-heights if the first +method does not give good results. If the second method is used, be sure to +print a character with a flat top to it, as characters with rounded tops +usually overshoot the x-height deliberately. A virtual font file for the +scaled font can be created by using {\tt afm2tfm} to create a virtual property +list of the encoded file, and using a utility such as my own {\tt +makevpl} (available by anonymous ftp from {\tt +ftp.dcs.ed.ac.uk:pub/ajcd/vplutils.tar.Z}) to re-scale the virtual property +list file. For example, the following command would scale the Times-Roman font +up by 15\%. + +\begin{small} +\begin{verbatim} +makevpl -at 11.5 ptmr:extex >stimes.vpl +\end{verbatim} +\end{small} + +This virtual property list file can then be compiled into a virtual font file +with {\tt vptovf}. The capital heights can be matched in a similar way. + +Rather than arbitrarily matching all of the PostScript fonts to the height of +one of them, it is a good idea to match them to the height of the default +\TeX\ font (\ie\ Computer Modern Roman). If any symbols are required +which are not provided by the PostScript fonts, the symbols can be slipped in +without the result looking too ugly. + +The proportions of ex-height to capital height are different for each of the +LaserWriter fonts, so a single scaling factor will in general not be +sufficient to match both of the ex-height and capital height. The easiest way +to get different scaling factors for the capitals and lowercase is to make two +virtual fonts with the desired scalings as described above, and merge them +using a utility such as {\tt makevpl} or Alan Jeffrey's {\tt fontinst}. It is +not desirable to match both the ex-heights and cap-heights of Courier unless +the widths are adjusted to keep the matched font monospaced. + +This matching process only needs doing for one member out of each family of +fonts; the other members should use the same scaling ratios to stay consistent +with each other. Figure~\ref{fig:xmatch} shows the results +of matching the ex-heights and cap-heights of the LaserWriter fonts. + +\begin{figure}[H] +\begin{center}\leavevmode +\epsfbox{xmatch.ps} +\caption{LaserWriter fonts with matched ex- and/or cap-heights} +\label{fig:xmatch} +\end{center} +\end{figure} + +\subsection{Matching widths}\label{sec:widths} +Matching the widths of the fonts is one of the easiest effects to achieve. The +{\tt afm2tfm} program has an option to extend or compress PostScript +fonts. For example, a virtual font for the Times-Roman font extended to 110\% +of its normal width by the command can be created by the command: + +\begin{small} +\begin{verbatim} +afm2tfm Times-Roman -e 1.1 -v ptmrx Times-Extd +\end{verbatim} +\end{small} + +This will create a virtual property list file called {\tt ptmrx.vpl}, which +can be scaled up or down as described above to match the heights of the fonts, +and then compiled into a virtual font with {\tt vptovf}. A \TeX\ font metric +(TFM) file will also be generated, which should be put in an appropriate +directory for \TeX\ to find it. A line needs to be inserted into the {\tt +psfonts.map} file to tell {\tt dvips} about the pseudo-font Times-Extd, +which it will create from the Times-Roman base font if it is used: + +\begin{small} +\begin{verbatim} +Times-Extd "/Times-Roman 1.1 ExtendFont" +\end{verbatim} +\end{small} + +Extending or compressing fonts in this way has the undesirable effect of +altering the ratio of the horizontal strokes to the vertical strokes; these +fonts are not true compressed or extended designs, and there is unfortunately +nothing that can be done in PostScript to counteract this effect. + +When matching the font widths, it is undesirable to make all of the em-widths +the same; the design of Courier requires more space than Times Roman or +Helvetica. +What is desired is a more acceptable balance of widths so that the +most compact font (Times) does not look bad when used beside the widest font +(Courier). Figure~\ref{fig:widths} shows a comparison of the original widths +of the characters and a possible choice of new widths. + +\begin{figure*}[htb] +\begin{center}\leavevmode +\epsfbox{widths.ps} +\caption{Comparison of original widths and new widths} +\label{fig:widths} +\vspace{6pt} +\begin{tabular}{lllll} +Font family & Cap height ratio & ex-height ratio & Extension & Stroke Width\\ +Times & 10.24 & 9.57 & 105\,\% \\ +Helvetica & 9.46 & 8.26 & \\ +Courier & 12.05 & 10.13 & 90\,\% & 20 \\ +\end{tabular} +\caption{Parameters} +\label{tab:ratios} +\end{center} +\end{figure*} + +\subsection{Matching weight} +Matching the weights of the fonts is one of the most awkward effects to +achieve. The intention is to achieve a more even gray colour from pages with +mixed fonts. +Courier is the main problem in this respect; most versions of Courier are +significantly lighter than Times Roman and Helvetica. The versions of Courier +from some foundries (\eg\ Bitstream) are heavier than the Adobe version +usually found in PostScript printers. + +Some early versions of the Courier fonts had a painting type 1, +meaning that the font was rendered by a single line down the centre of each +stroke; these fonts could be made lighter or darker by increasing the width of +the line used. More recent versions of Courier are defined as outlines, +with which the same trick cannot be used. A similar effect can be achieved by +rendering the character outline with an increased linewidth on top of filled +character. This can be done by the following PostScript commands which create +a new type 3 (user defined) font which places both outlined and filled +characters on top of each other: + +\begin{small} +\begin{verbatim} +%! +% Courier-Heavy font definition +/Courier-Heavy + 10 dict begin + /FontType 3 def + /FontMatrix [0.001 0 0 0.001 0 0] def + /FontName /Courier-Heavy def + /Courier dup findfont 1000 scalefont def + /Encoding Courier /Encoding get def + /FontBBox [ % adjust for outline width + Courier /FontBBox get aload pop + 2 {10 add 4 1 roll} repeat + 2 {10 sub 4 1 roll} repeat + ] def + /Courier-Outline dup % outlined Courier + Courier dup length 1 add dict begin + { + 1 index /PaintType eq { + pop 2 def + } { + 1 index /FID eq { + pop pop + } { + def + } ifelse + } ifelse + } forall + /StrokeWidth 20 def + currentdict + end definefont def + /charstring ( ) def % string for charcode + /BuildChar { % dict charcode + exch begin + charstring dup 0 4 -1 roll put + Courier setfont + dup stringwidth FontBBox aload pop + setcachedevice % set char metrics + 0 0 moveto + gsave + dup show % fill character + grestore + Courier-Outline setfont + show % draw outline + end + } def + currentdict + end +definefont pop +\end{verbatim} +\end{small} + +If the PostScript character cache is large enough this method will not cause +too much of a slowdown because each thickened character will be constructed +only once for each size used. The size of each character cannot be easily +extracted from the original Courier font, so each character takes the maximum +size of cache needed, determined from the original font's bounding box. + +{\tt Dvips} can be made aware of this new font by putting the following line +in the {\tt psfonts.map} file: + +\begin{small} +\begin{verbatim} +rpcrsb Courier-Heavy <coursb.pf3 +\end{verbatim} +\end{small} + +The font metrics of this heavier font are the same as the original Courier +font, so the AFM file for the original font can be copied and used to +generate the virtual font and TFM file needed for use with \TeX. +Figure~\ref{fig:weights} shows how the weight of the new heavy version of +Courier compared with the original Courier and Courier-Bold. + +\begin{figure}[H] +\begin{center}\leavevmode +\epsfbox{weights.ps} +\caption{Comparison of Courier weights} +\label{fig:weights} + +\end{center} +\end{figure} + +This technique increases the width and the height of the character by the +width of the stroke used on the outlined character, so another iteration +around the height and width matching steps may be needed to improve the +results. +The extra width is added on all sides of the character, so the baseline may +also need adjusting, by altering the coordinates of the {\tt moveto} command +in the PostScript header. +%The font's bounding box also needs adjusting to take this +%increased line width into adjustment; this is not done in the example above. + +This technique can really only be used to thicken characters. If characters +are thinned by painting a white outline over the filled character, it will not +yield a satisfactory result. At small sizes the inside of the character +outline may not have any space in it, and so the final character will have +gaps in it. + +\subsection{Results} +The techniques used here do not add much (if anything) to the final size of +documents; the PostScript header files downloaded are very small. +Table~\ref{tab:ratios} shows the height and width ratios which I am currently +using; fine tuning these ratios for nicer looking output will take some more +time. The Symbol font should probably follow the treatment of the Times +family, since it was designed to be complementary to Times. + +And finally, a sample of the resulting output. Matching both the ex-height and +cap height without adjusting their relative widths tends to make the capitals +look wider; some more experiments to reduce this effect will be necessary. + +\begin{center}\leavevmode +\epsfbox{result.ps} +\end{center} + + + +\section{Conclusion} +Anamorphic scaling by its very nature distorts the shapes of the characters. +In general, distorting a pleasing typeface will not give another pleasing +typeface. The techniques described in this note make minor distortions to +a set of typefaces in order to make their use together more pleasing. +These techniques are only useful in limited circumstances, \ie\ when +the only fonts you can rely on using are the base LaserWriter fonts. As noted +in the introduction, there are circumstances where this is the case, and in +these cases almost anything is better than the ugly sight of Times, Helvetica +and Courier mixed together in their natural state. +\end{Article} + +\endinput |