[pdftex] character protruding with palatino

Guy Worthington guyw at multiline.com.au
Sun Jun 1 17:13:37 CEST 2003


The following is long, boring and probably wrong.  Do not read unless

    \pdffontexperience=7
    \pdftypobackground=1
    \pdfcanseethedifference=1

Using the font cmr10, Thanh's protcode.tex (available on CTAN), gives
good results for margin kerning.  Using the palantino font (pplr),
instead of making the margin look smoother, it makes it so ragged it's
distracting.  It turns out that Thanh's protcode.tex, must be tuned to
the particular font you're using.

Below is a purely mechanical technique for adjusting Thanh's
protcode.tex file for palatino.  It is based (loosely) on comments
made in a recent thread "Han The Thanh's thesis on microtypography".
Before a start, a disclaimer: 

  "I have no ability, or experience with typographic design.  The
  following technique is purely for comment (robust or otherwise)."

The following file is an attempt to compare the principal character
metrics between computer modern roman and palatino.  The numbers
assigned to the principal characters are not arbitrary.  They are
transferred directly from Thanh's protcode.tex file.

%--adjustprotcode.tex------------------------------
\font\palatinofont = pplr at 10pt

\def\adjustCmrTenForPplr#1=#2 {
  \setbox0=\hbox{\char#1}\count0=\wd0
  \setbox1=\hbox{{\palatinofont \char#1}}\count1=\wd1
  \multiply\count0 by200
  \divide\count0 by\count1
  \char#1=\the\count0\par}

\def\enumerateList#1{\def\\##1=##2{\adjustCmrTenForPplr##1=##2}#1}

\toks0={%
    \\`\!=200
    \\`\,=700
    \\`\-=700
    \\`\.=700
    \\`\;=500
    \\`\:=500
    \\`\?=200
    \\`\`=700
    \\`\'=700
    \\ 92=500  % ``
    \\ 34=500  % ''
    \\ 123=300 % --
    \\ 124=200 % ---
    \\`\)=50
    \\`\A=50
    \\`\F=50
    \\`\K=50
    \\`\L=50
    \\`\T=50
    \\`\V=50
    \\`\W=50
    \\`\X=50
    \\`\Y=50
    \\`\k=50
    \\`\r=50
    \\`\t=50
    \\`\v=50
    \\`\w=50
    \\`\x=50
    \\`\y=50
    \\`\(=50
    \\`\A=50
    \\`\J=50
    \\`\T=50
    \\`\V=50
    \\`\W=50
    \\`\X=50
    \\`\Y=50
    \\`\v=50
    \\`\w=50
    \\`\x=50
    \\`\y=50
}

\enumerateList{\the\toks0}

\bye
%--------------------------------------------------

Running the command

    pdftex adjustprotcode

on the file generates a pdf file.  I extracted the text from the pdf
file, and pasted into a new file, I called pplprotcode.tex, which
I've pasted below.

%--pplprotcode.tex---------------------------------
input abbr.tex

\def\setprotcode#1{%
    \rpcode#1`\!=199    
    \rpcode#1`\,=222    
    \rpcode#1`\­=200    
    \rpcode#1`\.=222    
    \rpcode#1`\;=222    
    \rpcode#1`\:=222    
    \rpcode#1`\?=212    
    \lpcode#1`\`=199    
    \rpcode#1`\'=199    
    \lpcode#1 92=165  % ``
    \rpcode#1 34=269  % ''
    \rpcode#1 123=300 % --
    \rpcode#1 124=330 % ---
    \rpcode#1`\)=233    
    \rpcode#1`\A=192    
    \rpcode#1`\F=234    
    \rpcode#1`\K=214    
    \rpcode#1`\L=204    
    \rpcode#1`\T=235    
    \rpcode#1`\V=207    
    \rpcode#1`\W=205    
    \rpcode#1`\X=224    
    \rpcode#1`\Y=224    
    \rpcode#1`\k=189    
    \rpcode#1`\r=198    
    \rpcode#1`\t=238    
    \rpcode#1`\v=186    
    \rpcode#1`\w=173    
    \rpcode#1`\x=204    
    \rpcode#1`\y=189    
    \lpcode#1`\(=233    
    \lpcode#1`\A=192    
    \lpcode#1`\J=308    
    \lpcode#1`\T=235    
    \lpcode#1`\V=207    
    \lpcode#1`\W=205    
    \lpcode#1`\X=224    
    \lpcode#1`\Y=224    
    \lpcode#1`\v=186    
    \lpcode#1`\w=173    
    \lpcode#1`\x=204    
    \lpcode#1`\y=189    
    \adjustprotcode#1
}

\makeatletter
\newif\ifneedadjustprotcode
\def\adjustprotcode#1{%
    \needadjustprotcodefalse
    \ifnum\pdftexversion > 13
        \ifnum \expandafter`\pdftexrevision > `g
            \needadjustprotcodetrue
        \fi 
    \else\ifnum\pdftexversion > 14
        \needadjustprotcodetrue
    \fi\fi
    \ifneedadjustprotcode
        \@tempcnta=0
        \loop
            \ifcase\lpcode#1\@tempcnta\else
                \adjustcp\lpcode#1\@tempcnta
            \fi
            \ifcase\rpcode#1\@tempcnta\else
                \adjustcp\rpcode#1\@tempcnta
            \fi
            \advance\@tempcnta 1
        \ifnum\@tempcnta < 256 \repeat
    \fi
}
\def\adjustcp#1#2#3{%
    \setbox0=\hbox{%
        \ifx#2\font\else#2\fi
        \char#3}%
    \@tempcntb=\wd0
    \mul\@tempcntb #1#2#3%
    \div\@tempcntb \fontdimen6 #2%
    #1#2#3=\@tempcntb
}
\makeatother
%--------------------------------------------------

Finally, I tested it the file below:

%--------------------------------------------------
% This was compiled using pdfetex 1.00a pretest
%
\input pplprotcode

\font\bodyfont = pplr at 10pt
\font\italicfont = pplri at 10pt 

\def\emph#1{{\italicfont#1}}

\hsize=333pt% This number is 2.5 times the width of one alphabet
            % using pplr at 10pt
\parindent=24pt

  \bodyfont

  \setprotcode\font
  \pdfprotrudechars=2
  
  In Section 19, you learned how to use abstract classes to impose
  method definition requirements on subclasses.  In this section, you
  learn how to use Java's \emph{interface mechanism} to establish
  method definition requirements on a class without relying on
  inheritance from an abstract class.
  
  A principle of good programming practice is that you should think
  about what your programs should do before you proceed to write
  them.  Establishing requirements forces you to think about what you want
  your programs to do; thus liberal use of Java's interface mechanism is
  good practice.
  
  In this section, you also learn that Java's interface mechanism help
  teams of programmers to work together effectively, and you learn that
  interfaces offer splendid locations for program documentation.

  Thus, Java's interface mechanism, reflectively used, can make you a
  much better programmer.

\bye
%--------------------------------------------------






More information about the pdftex mailing list