Margin Kerning and Font Expansion with Pdftex

Margin Kerning and Font Expansion with Pdftex

Margin Kerning and Font Expansion with pdfTEX H`anTh´eTh`anh Introduction \f ends up at the right margin, it should be moved out to the margin by 700 thousandths of its width pdfT X has some micro-typographic extensions that E (i.e., 70 %). are not so widely used, for the lack of documentation It is conveninent to specify the protruding fac- and quite complicated setup. In this paper I would tor for individual characters in thousandths of char- like to describe their use in a step-by-step manner acter width. This is also the way how \rpcode so the reader can give a try afterwards. Two exten- was implemented in versions up to 0.14h. However, sions will be introduced: margin kerning and font this method cannot be used for characters with expansion. zero width (”faked” characters that can be used to Margin kerning is the technique to move the protrude other elements than normal characters), so characters slightly out to the margins of a text block in version 0.14h and later, the protruding amount in order to make the margins look straight. Without is specified in thousandths of an em of the font. margin kerning, certain characters when ending up A macro called \adjustprotcode (defined in file at the margins can cause the optical illusion that \protrude.tex) is used here to checks whether the the margins look rather ragged. Margin kerning used version is older than 0.14h and if so it will is similar to hanging punctuation, but it can also convert the settings for versions before 0.14h (i.e., in be applied to other characters as well. When used thousandths of character width) to the correspond- with appropriate settings, this extension can help to ing settings for later versions (i.e., in thousandths of considerably improve appearance of a text block. an em). Font expansion is the technique to use a slightly By default, all characters have their \rpcode wider or narrower variant of a font to make inter- set to zero, so no characters will be protruded unless word spacing more even. A font that can be ex- we explicitly set \rpcode. panded thus has some ”stretchability” and ”shrink- The primitive \pdfprotrudechars is used to ability”. The potentiality to make a font wider or control margin kerning at global level. narrow then can be used by the line-breaking engine to choose better breakpoints. • ≤ 0: no margin kerning. I will describe the use of those two extensions • 1: level 1 margin kerning, which does not have by examples, as I find it a very good way to explain effect to line breaking. This setting is handy if how to use something in practice. People interested you want to keep line-breaking to be compatible in the concepts and further details will find more in with TEX. my thesis. • ≥ 2: level 2 margin kerning, which usually gives different result of line breaking. This Margin kerning setting causes the line-breaking engine to take The simplest use of margin kerning can look like: the amount needed to protrude the characters at the margins into account. As the result, \input protcode.tex interword spacing is better. \font\f=cmr10 Now we go for another example: \rpcode\f‘\-=700 \input protcode.tex \adjustprotcode\f \font\f=cmr10 \f \lpcode\f‘\‘=700 \pdfprotrudechars=1 \rpcode\f‘\’=700 Some text... \adjustprotcode\f \rpcode stands for ”right protruding code”. \f The first parameter is a font identifier, and the \pdfprotrudechars=2 second parameter is a character code. The third Some text... parameter specifies the amount how much the char- This example introduced another primitive, acter will be moved to the right margin. The above \lpcode. It is the counterpart of \rpcode, used for example says that if the hyphen character from font protruding at the left margin. The above example 146 TUGboat, Volume 22 (2001), No. 3 — Proceedings of the 2001 Annual Meeting Margin Kerning and Font Expansion with pdfTEX thus sets the left quote to be protruded at left sandths. For example, cmr10 expanded by 10 thou- mergin and the right quote at the right margin. sandths (1 %) will be named cmr10+10. Expansion We set \pdfprotrudechars to 2, which may lead value can be negative, which stands for condensing. to different line breaking. Putting the created fonts into their correct loca- Fortunately one does not have to set \lpcode tion is another matter. I suggest simply putting all and \rpcode for each character. A common set of expanded fonts into a single directory to play with. protruding factors works quite reasonably for most Computer Modern fonts Computer Modern of body fonts, so one can use them as in the following fonts can be expanded by altering the unit width example: in the source. For example, cmr12+10.mf is created \input protcode.tex by copying the source of the base font (cmr12.mf), \font\f=cmr10 with a line appended after the place where the unit \setprotcode\f width is defined as: \f u#:=20/36pt#; % unit width \pdfprotrudechars=2 u#:=u#+10/1000u#; Some text... Then the changed source is used to generate the The macro \setprotcode is also defined in the expanded TFM as well as the bitmap font needed file protcode.tex and it will call \adjustprotcode for rendering the output. While using expanded after settings the common values for protruding, Computer Modern fonts, the corresponding entries that is why we do not have \adjustprotcode in in used the map files must be commented out, this example. otherwise pdfTEX will treat them as Type 1 fonts. Assigment to \lpcode and \rpcode is always Type 1 fonts Type 1 fonts are expanded by alter- global. In a LAT X document, setting up margin E ing the FontMatrix of Type 1 fonts. pdfTEX will do kerning can look like: that for you, the only task is to create the expanded \documentclass{report} TFM files. Suppose that we have an AFM file ... putr8a.afm (Adobe Utopia Regular). Then creat- \input protcode.tex ing 8y-encoded TFM expanded by 10 thousandths \begin{document} (1 %) can looks like: \setprotcode\font afm2tfm putr8a.afm -e 1.010 {\it \setprotcode\font} -T texnansi.enc putr8y+10.tfm {\bf \setprotcode\font} {\bf\it \setprotcode\font} You also need an entry in the map files that Some text... looks like: \end{document} putr8y Utopia-Regular "TeXnANSIEncoding In case the settings in protcode.tex do not ReEncodeFont" <texnansi.enc <putr8a.pfb look for a particular font, you can always change it Only the entry for the base font (non-expanded) to your taste. is needed. The expanded versions will be embedded Font expansion according to the entry for the base font. Multiple Master fonts Only Multiple Master Use of font expansion is more complicated due to with a width axis can be expanded. The idea is to the need to create expanded versions of a font. This create a new instance with the width value increased task can be done on-the-fly; however, its setup is by the expansion amount. The following example system-dependent so I will describe rather how to shows how to create an Multiple Master instance create these fonts manually. and a variant expanded by 20 thousandths: Creating expanded fonts Font expansion can be mmafm --weight=400 --optical-size=12 - used with -width=535 - 1. fonts based on Computer Modern fonts -output pmnr8a12.afm MinionMM.afm (i.e., Computer Modern fonts and variants for Czech, Vietnamese, etc.); mmafm --weight=400 --optical-size=12 2. Type 1 fonts; --width=545.7 3. Multiple Master fonts with a width axis. --output pmnr8a12+20.afm MinionMM.afm Expanded fonts have the name from the base The magic number 545.7 comes from the ex- 20 font, followed by the expansion amount in thou- pression 535 × (1 + 1000 ), which means that we TUGboat, Volume 22 (2001), No. 3 — Proceedings of the 2001 Annual Meeting 147 H`anTh´eTh`anh increase the width value of the base instance by 20 A macro called \resetefcode, available in the thousandths. file efcode.tex, can be used to reset all expansion The PFB font files are created in a similar way. factors to 1000. Afterwards the AFM can be converted to TFM using So we can try to put margin kerning and font afm2tfm: expansion together: afm2tfm pmnr8a12.afm -T \input protcode.tex texnansi.enc pmnr8y12.tfm \input efcode.tex \font\f=cmr10 afm2tfm pmnr8a12+20.afm -T \setprotcode\f texnansi.enc pmnr8y12+20.tfm \reasetefcode\f Similar to Type 1 fonts, only the entry for the \pdffontexpand\f 20 20 5 1000 base font is needed in map files: \pdfadjustspacing=2 \pdfprotrudechars=2 pmnr8y12 MinionMM_400_535_12_ \f <texnansi.enc <pmnr8a12.pfb Some text... Using font expansion Suppose that given a font, or in a LATEX document: we know how to create expanded versions of that \documentclass{report} font. Now let us try an example: ... \font\f=cmr10 \input protcode.tex \pdffontexpand \f 20 10 5 1000 \input efcode.tex \efcode\f‘\e=1000 \def\setupfont#1{ \f \setprotcode#1 \pdfadjustspacing=1 \resetefcode#1 Some text... \pdffontexpand#1 20 20 5 1000 The primitive \pdffontexpand says that font } \f can be expanded up to 20 thousandths, con- \begin{document} densed to 10 thousandths by step 5 thousandths. \setupfont\font This means that only variants whose expansion {\it \setupfont\font} amount is a multiple of 5 are needed. In our ex- {\bf \setupfont\font} ample, the following variants are needed (they must {\bf\it \setupfont\font} be created before running the example): cmr10+20, Some text... cmr10+15, cmr10+10, cmr10+5, cmr10-5, cmr10-10.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us