summaryrefslogtreecommitdiff
path: root/fonts/poetica/inputs/poetica.sty
blob: 078d7de9a4e95594b438358e7c272c9d9480f1a3 (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
%%% Package File poetica.sty
\newcount\poetic \newcount\poetbound \poetbound=4
\newcount\poetceiling \poetceiling=8
\newcount\poetfloor   \poetfloor=0

\def\wordbounds{\def\fancyshape{F}}
\def\nowordbounds{\def\fancyshape{f}}\nowordbounds % default

\def\parsefontshape#1#2{\poetic=-1% for `non-text' fonts
  \if f#1\poetic=\poetbound \advance\poetic by#2 \fi
  \if n#1\poetic=\poetfloor \advance\poetic by#2 \fi
}
\def\setshape{% input is the value of \poetic
  \ifnum\poetic<0 \else 
    \ifnum\poetic<\poetbound \edef\fshape{n\the\poetic}%
      \else\advance\poetic by-\poetbound \edef\fshape{\fancyshape\the\poetic}%
    \fi
  \fi
}
\newcommand{\Fontshape}[1]{\parsefontshape#1%
  \fontshape{#1}\selectfont}
\newenvironment{Poetica}{%
  \begingroup\fontencoding{OT1}\fontfamily{poet}\fontsize{18}{22}
  \fontseries{m}\Fontshape{n3}\poetic=3 \setshape}{\endgroup}
\let\dhyph=\- \let\mytabs=\+ % save discretionary hyphen, tab command
\let\oldhat=^ \let\oldsub=_ \let\oldvert=|
\catcode`\^\active \catcode`\_\active 
\catcode`\|\active \def\|{\oldvert} \let|=\noboundary
\newcount\INC \INC 1 % an increment register
\def^{\bgroup \let\compare=-\let\bump=\bumpdown \INC-1 \poetic=\poetceiling 
  \afterassignment\getnextchar \global\let\nexttok= }
\def_{\bgroup \let\compare=+\let\bump=\bumpup \INC 1 \poetic=\poetfloor 
  \afterassignment\getnextchar \global\let\nexttok= }
\def\-{\bgroup \let\compare=-\let\bump=\bumpdown \INC-1 \bump
  \afterassignment\getnextchar \global\let\nexttok= }
\def\+{\bgroup \let\compare=+\let\bump=\bumpup \INC 1 \bump
  \afterassignment\getnextchar \global\let\nexttok= }

\def\getnextchar{%
  \if\compare\nexttok % fancy sign? if so, bump the right way
    \bump \let\nextact\grabchar
  \else
    \edef\nextact{\noexpand\typeset\noexpand\nexttok}% default behavior  
  \fi \nextact
}
\def\grabchar{\afterassignment\getnextchar \let\nexttok}
\def\bumpdown{\advance\poetic \INC 
  \ifnum\poetic<\poetfloor \poetic\poetfloor \fi}
\def\bumpup{\advance\poetic \INC 
  \ifnum\poetic>\poetceiling \poetic\poetceiling \fi}
\def\typeset#1{\setshape\fontshape{\fshape}\selectfont
  #1\egroup}

%% ornaments and ampersands

\newcommand{\orn}[1]{{\fontshape{orn}\selectfont\symbol{#1}}}
\newcommand{\amp}[1]{{\fontshape{amp}\selectfont\symbol{#1}}}

\endinput