% Macros for basic text.
% Copyright (C) 1993, 1994 Gary Houston
% This program may be copied and modified under the terms of the 
% GNU General Public License version 2.

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gftext}[1994/08/13 gf text defaults]

% Need the LaTeX symbol font for \guillemotleft and \guillemotright with
% OT1 encoding.
\RequirePackage{latexsym}

% Ensure that line breaking will always occur if necessary, since
% underful hboxes usually look better than text sticking out into the
% margin.  \emergencystretch needs TeX 3.0 or higher.
\emergencystretch=\hsize

% Highlighted phrases.
\newcommand{\hpone}[1]{{\normalfont\textit{#1}}}
\newcommand{\hptwo}[1]{{\normalfont\textbf{#1}}}
\newcommand{\hpthree}[1]{{\normalfont\textbf{\itshape#1}}}
\newcommand{\hpzero}[1]{{\normalfont\textrm{#1}}}

% Phrase architectural form.
% #1 gives element name (in capitals), #2 gives text.

\DeclareRobustCommand{\phrase}[2]{%
  \def\el@ment{EM}\def\@arg{#1}%
  \ifx\el@ment\@arg
    \emph{#2}%
  \else
    \emph{#2}%
  \fi
}

% Code architectural form.  1st parameter gives the name of the element, 
% 2nd gives the text.
\DeclareRobustCommand{\code}[2]{{\tt\frenchspacing#2}}

% Abbreviations (assumes a single abbreviated word).
% Put the argument in an hbox, to get the spacing right in case it ends
% with a capital letter and is followed by a period.  Then check whether a
% period follows: if not, add a normal space (rather than a sentence-ending
% stretchable space).
% Not used at present.
%\newcommand{\abbr}[1]{\hbox{#1}\futurelet\next\abbrx}
%\newcommand{\abbrx}{\ifx\next.\else.\ \ignorespaces\fi}

% A macro which turns off a special property of capital letters: a capital
% followed by a period is assumed to be an abbreviation. Don't wan't this
% behaviour in Snafu, since abbreviations can be marked explicitly.
\newcommand{\regularspacing}{
  \sfcode`A=1000 \sfcode`B=1000 \sfcode`C=1000 \sfcode`D=1000
  \sfcode`E=1000 \sfcode`F=1000 \sfcode`G=1000 \sfcode`H=1000
  \sfcode`I=1000 \sfcode`J=1000 \sfcode`K=1000 \sfcode`L=1000
  \sfcode`M=1000 \sfcode`N=1000 \sfcode`O=1000 \sfcode`P=1000
  \sfcode`Q=1000 \sfcode`R=1000 \sfcode`S=1000 \sfcode`T=1000
  \sfcode`U=1000 \sfcode`V=1000 \sfcode`W=1000 \sfcode`X=1000
  \sfcode`Y=1000 \sfcode`Z=1000
}

% Address components.
\newcommand{\org}[1]{#1}
\newcommand{\street}[1]{#1}
\newcommand{\city}[1]{#1}
\newcommand{\region}[1]{#1}
\newcommand{\country}[1]{#1}
\newcommand{\postcode}[1]{#1}
\newcommand{\postbox}[1]{#1}

% Small fractions, from the texbook.
\def\sfrac#1/#2{\leavevmode\kern.1em
  \raise.5ex\hbox{\the\scriptfont0 #1}\kern-.1em
  /\kern-.15em\lower.25ex\hbox{\the\scriptfont0 #2}}

% Various European quotation marks 

% Should have:
%
%    ldquo  `` ___ '' rdquor        lsquo  ` ___ ' rsquor
%             |   |'' rdquo 		    |   |' rsquo
% laquo <<    |   | 			    |   |          >> raquo
%             |___|			    |___|
%    ldquor ''			    lsquor '
% 
% ISO to LaTeX Names:
% laquo = \guillemotleft
% raquo = \quillemotright
% ldquor = \quotedblbase
% lsquor = \quotesinglbase

% Some are not currently defined.

% The quote definitions below are derived from Johannes Braams, TeX and
% TUG NEWS, Vol 2, No 3, July 1993.

% Utility: put a string in a low box.
\def\set_low_box#1{\sbox2{,}\sbox0{#1}%
  \dimen0\ht0 \advance\dimen0 -\ht2%
  \sbox0{\lower\dimen0 \box0}\ht0\ht2 \dp0\dp2}

% Utility: preserve the current spacefactor.
\def\@save_sf_q#1{{\ifhmode
  \edef\@SF{\spacefactor\the\spacefactor}\else
  \let\@SF\empty \fi \leavevmode #1\@SF}}

% \guillemotleft and \guillemotright are predefined when using the T1 encoding:
% here are definitions for OT1.
\DeclareMathSymbol{\@lg}{0}{lasy}{40}
\DeclareMathSymbol{\@rg}{0}{lasy}{41}
\DeclareTextCommand{\guillemotleft}{OT1}
  {\makebox{\ensuremath{\@lg\kern-0.2em\@lg\kern+0.2em}}}
\DeclareTextCommand{\guillemotright}{OT1}
  {\makebox{\ensuremath{\kern+0.2em\@rg\kern-0.2em\@rg}}}

% Likewise for \quotedblbase and \quotesinglbase.
\DeclareTextCommand{\quotedblbase}{OT1}
  {\@save_sf_q{\set_low_box{''}\box0\kern-.04em}}
\DeclareTextCommand{\quotesinglbase}{OT1}
  {\@save_sf_q{\set_low_box{'}\box0\kern-.04em}}

% &thorn; and &THORN; are defined as \th and \TH in T1 encoding.
% This is not a very good definition for OT1.
\DeclareTextCommand{\th}{OT1}
  {th}
\DeclareTextCommand{\TH}{OT1}
  {Th}

% &eth; and &ETH; are defined as \dh and \DH in T1 encoding.
% This is not a very good definition for OT1.
\DeclareTextCommand{\dh}{OT1}
  {\ensuremath\partial}
\DeclareTextCommand{\DH}{OT1}
  {\mbox{\rlap{\raise.3ex\hbox{--}}D}}

% Circled r symbol, stolen from Peter Mutsaers and modified.
\newcommand{\rcircle}{%
\begin{picture}(8,10)
\put (.9,4.4){\tiny R}
\put (3,6){\circle{6.5}}
\end{picture}}

% Filled square and hyphen bullet symbols.  The catcode of the space character
% must be set since otherwise the macros fail in the listing environment.
\newcommand{\squf}{{\catcode`\ =10\vrule height .9ex width .8ex depth -.1ex}}
\newcommand{\hybull}{{\catcode`\ =10\vrule height .6ex width .8ex depth -.4ex}}

% Male and female symbols (poor).
\newcommand{\male}{$\bigcirc^{\mkern-5.5mu\raise.5ex\hbox{$\nearrow$}}$}
\newcommand{\female}{$\bigcirc\mkern-15.64mu\lower1.75ex\hbox{+}$}

\newcommand{\cent}{\textrm{\rlap/c}}
