Debian Codegraph @

texmf-dist/doc/pdftex/samplepdftex/protcode.tex

raw
1 % $Id: protcode.tex 883 2022-06-08 17:30:43Z karl $
2 % Public domain. Originally written by Han The THanh.
3 % Example \lpcode and \rpcode ("left/right protrusion code") settings
4 % for per-glyph tuning of protrusion, and a macro to execute them
5 %
6 % As written, this file does nothing but make definitions.
7 % Adapt and adjust for your needs.
8 %
9 % Much more in the LaTeX microtype package (https://ctan.org/pkg/microtype).
10
11 \def\setprotcode#1{%
12 % this macro works with OT1 encoding only -- mostly ASCII,
13 % but assumes OT1 for quotes and dashes.
14 \rpcode#1`\!=200
15 \rpcode#1`\,=700
16 \rpcode#1`\-=700
17 \rpcode#1`\.=700
18 \rpcode#1`\;=500
19 \rpcode#1`\:=500
20 \rpcode#1`\?=200
21 \lpcode#1`\`=700
22 \rpcode#1`\'=700
23 \lpcode#1 92=500 % ``
24 \rpcode#1 34=500 % ''
25 \rpcode#1 123=300 % --
26 \rpcode#1 124=200 % ---
27 \rpcode#1`\)=50
28 \rpcode#1`\A=50
29 \rpcode#1`\F=50
30 \rpcode#1`\K=50
31 \rpcode#1`\L=50
32 \rpcode#1`\T=50
33 \rpcode#1`\V=50
34 \rpcode#1`\W=50
35 \rpcode#1`\X=50
36 \rpcode#1`\Y=50
37 \rpcode#1`\k=50
38 \rpcode#1`\r=50
39 \rpcode#1`\t=50
40 \rpcode#1`\v=50
41 \rpcode#1`\w=50
42 \rpcode#1`\x=50
43 \rpcode#1`\y=50
44 \lpcode#1`\(=50
45 \lpcode#1`\A=50
46 \lpcode#1`\J=50
47 \lpcode#1`\T=50
48 \lpcode#1`\V=50
49 \lpcode#1`\W=50
50 \lpcode#1`\X=50
51 \lpcode#1`\Y=50
52 \lpcode#1`\v=50
53 \lpcode#1`\w=50
54 \lpcode#1`\x=50
55 \lpcode#1`\y=0
56 \adjustprotcode#1\relax
57 }
58
59 \newif\ifneedadjustprotcode
60 \newbox\boxA
61 \newcount\countA
62 \newcount\countB
63 \def\adjustprotcode#1{%
64 \needadjustprotcodefalse
65 \ifnum\pdftexversion = 14
66 \ifnum \expandafter`\pdftexrevision > `g
67 \needadjustprotcodetrue
68 \fi
69 \else\ifnum\pdftexversion > 14
70 \needadjustprotcodetrue
71 \fi \fi
72 \ifneedadjustprotcode
73 \countA=0
74 \loop
75 \ifcase\lpcode#1\countA\else
76 \adjustcp\lpcode#1\countA
77 \fi
78 \ifcase\rpcode#1\countA\else
79 \adjustcp\rpcode#1\countA
80 \fi
81 \advance\countA 1
82 \ifnum\countA < 256 \repeat
83 \fi
84 }
85 \def\adjustcp#1#2#3{%
86 \setbox\boxA=\hbox{%
87 \ifx#2\font\else#2\fi
88 \char#3}%
89 \countB=\wd\boxA
90 \multiply\countB #1#2#3\relax
91 \divide\countB \fontdimen6 #2\relax
92 #1#2#3=\countB\relax
93 }