blob: 70901ec28dfb75620c60d561f6db2d33e113d05b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
%%
%% This is file `textfit.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% textfit.dtx (with options: `package')
%% Copyright (C) 1993,94 Sebastian Rahtz and Phil Taylor.
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainers of this work are Sebastian Rahtz and Phil Taylor.
%%
%% This work consists of all files listed in manifest.txt.
%%
%% This licence statement added 2010/11/26 by Clea F. Rees on behalf
%% of Sebastian Rahtz and Phil Taylor.
%%
\def\fileversion{5}
\def\filedate{1994/04/15}
\def\docdate{1994/04/15}
%% File: textfit.dtx Copyright (C) 1994 Sebastian Rahtz and Phil Taylor
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{textfit}[\filedate]
\newif\ifScalebyMagsteps
\newif\ifNoisyFitting
\NoisyFittingfalse
\ScalebyMagstepsfalse
\DeclareOption{noisy}{\NoisyFittingtrue}
\DeclareOption{magstep}{\ScalebyMagstepstrue}
\ProcessOptions
\newcount \mags@f@r
\newdimen \desired@size
\newcount \r@mainder
\newcount \m@gstepcount
\newcount \m@gsteplimit
\newcount \m@gstepvalue
\newdimen \m@gstepdimen
\def \magsteps {\afterassignment \m@gsteps \m@gsteplimit = }
\def \m@gsteps
{\let \@r = \or
\def \or {\noexpand \or}%
\m@gstepdimen = 0.166667 \maxdimen
\m@gstepvalue = 1000
\m@gstepcount = 0
\def \magstep {}%
\loop
\ifnum \m@gstepcount < \m@gsteplimit
\advance \m@gstepcount by 1
\ifnum \m@gstepvalue > \m@gstepdimen
\advance \m@gstepcount by -1
\message {Sorry --- integer overflow would occur if
I went any further; stopped at
\the \m@gstepcount.}
\m@gsteplimit = \m@gstepcount
\else
\multiply \m@gstepvalue by 12
\multiply \r@mainder by 12
\divide \r@mainder by 10
\advance \m@gstepvalue by \r@mainder
\r@mainder = \m@gstepvalue
\divide \m@gstepvalue by 10
\multiply \m@gstepvalue by 10
\advance \r@mainder by -\m@gstepvalue
\divide \m@gstepvalue by 10
\ifnum \r@mainder < 5
\edef \magstep {\magstep \or \the \m@gstepvalue}%
\else
\advance \m@gstepvalue by 1
\edef \magstep {\magstep \or \the \m@gstepvalue}%
\advance \m@gstepvalue by -1
\fi
\fi
\repeat
\edef \magstep ##1%
{\noexpand \ifcase ##1
1000\magstep
\noexpand \else 0%
\noexpand \message
{Sorry --- \string \magstep \space ##1
is not in range 0 .. \the \m@gsteplimit}%
\noexpand \fi
\noexpand \relax
}%
\let \or = \@r
}
\magsteps 63
\def \Fontname #1{\expandafter \strip@size \fontname #1 }
\def \strip@size #1 #2#{#1\void@@@}
\def \void@@@ #1{}
\gdef\n@d#1.#2:{#1}
\def \@scaletofit[#1]#2#3{%
\def\Hb@x{h}\def\H@rV{#1}%
\ifx\H@rV\Hb@x\def\C@mpare{\wd}\else\def\C@mpare{\ht}\fi
\desired@size #2
\def\curr@fontname{\Fontname \font {} }%
\ifScalebyMagsteps
\mags@f@r \z@
\setbox 0 = \hbox{#3}%
\def\@increment{1}%
\def\@test{<}%
\ifdim \C@mpare 0 > \desired@size
\message{When scaling by Magsteps, you cannot go downwards!}%
\fi
\loop
\font \temp@font = \curr@fontname scaled \magstep \mags@f@r
\setbox 0 = \hbox{{\temp@font #3}}%
\ifNoisyFitting
\message {Trying \noexpand \magstep \the \mags@f@r...}%
\fi
\ifdim \C@mpare 0 \@test \desired@size
\advance \mags@f@r by \@increment
\repeat
\ifnum \mags@f@r=\z@
\mags@f@r1
\fi
\advance \mags@f@r by -\@increment
\else
\font\temp@font=\curr@fontname at1pt
\setbox 0 = \hbox{{\temp@font #3}}%
\@tempdima\C@mpare0
\multiply\@tempdima by 500 %\@m
\def\foo@@{\expandafter\n@d\the\@tempdima:}%
\@tempdimb\desired@size
\divide\@tempdimb by \foo@@
\multiply\@tempdimb by 500 %\@m
\fi
\ifScalebyMagsteps
\ifNoisyFitting
\message {The calculated font is \curr@fontname
scaled \noexpand \magstep \the \mags@f@r}%
\fi
\font \temp@font = \curr@fontname scaled \magstep \mags@f@r
\else
\ifNoisyFitting
\message {The calculated font is \curr@fontname ->\the\@tempdimb}%
\fi
\font\temp@font=\curr@fontname at \the\@tempdimb
\fi
\ifx\H@rV\Hb@x
\hbox to \desired@size {\hss{\temp@font #3}\hss}%
\else
\hbox {{\temp@font #3}}%
\fi
}
\def\scaletowidth{\@scaletofit[h]}
\def\scaletoheight{\@scaletofit[v]}
\endinput
%%
%% End of file `textfit.sty'.
|