\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#213: A Standard Dialog for Font Selection}
\date{August 21, 2004}
\author{Donal K. Fellows, Pat Thoyts}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#213}&\textbf{A Standard Dialog for Font Selection}\\\hline
Author&

Donal K. Fellows \tipmail{donal.k.fellows}{man.ac.uk}
\par
Pat Thoyts \tipmail{patthoyts}{users.sourceforge.net}
\\
Created&Saturday, \(\text{21}^{\text{st}}\) August 2004\\
Type&Project\\
Tcl Version&\(8.6\)\\
State&Withdrawn\\
Vote&Pending\\
Version&\tipversion$Revision: 1.7 $\\
Keywords&Tk\\
Obsoleted By&324\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP proposes a new command that pops up a dialog box that allows the selection of a font. Where possible, this dialog will be implemented using the host platform's standard dialogs.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

A number of platforms (Windows and MacOSX) have standard dialogs for common user-oriented tasks, and Tk provides an interface to these dialogs through commands such as \textit{tk\_getOpenFile} and \textit{tk\_chooseColor}. However, another dialog that they provide and which some programs would find useful is a font selector. This TIP proposes adding a command to do just that; where a platform does not provide such a standard dialog, one implemented using a Tcl script will be used instead.

\section{Proposed Change}

Tk shall have a new command, \textbf{tk\_chooseFont}, with the syntax described below (which should be recognizably similar to \textbf{tk\_chooseColor}). The dialog will not return a result as on some platforms (MacOSX) this is required to be modeless while on others (Windows) it must be modal. Therefore all actions will be done via an \textit{-apply} command. In the modal case clicking either the \textit{Apply} button (if present) or the \textit{OK} button will cause the \textit{-apply} command to be called with the font specification appended as an additional argument. If \textit{Cancel} is chosen then this is not called. For the modeless (MacOSX) case calling the \textit{tk\_chooseFont} command will cause the dialog to be displayed and closing the dialog will just withdraw it.

\begin{quote}
\textbf{tk\_chooseFont} ?\textit{-option value -option value ...}?
\end{quote}

Permitted options are:
\begin{description}
\item[-parent]
This specifies the parent window of the dialog (similarly to the \textbf{-parent} option to other dialogs).
\item[-title]
This specifies the title of the dialog. If the platform specific dialog cannot support this then the option is ignored.
\item[-initialfont]
This specifies the initial font in any form given on the font(n) manual page (section ``FONT DESCRIPTION''). Provided it is supported by the platform implementation this font will be selected when the dialog is displayed.
\item[-apply]
This specifies a command prefix to be called when a font selection has been made by the user. The command will have the font specification appended as the final parameter and is then evaluated in the global namespace. The font specification will be a list of the form described on the font(n) manual page under ``FONT DESCRIPTION'' section 3. That is a list of \{family size style ?style ...?\}
\end{description}

Whenever a platform provides a suitable font dialog in its own API, Tk should not use a script-based alternative, even if this means missing out on features like the title or dynamic updating of the font during the selection process.

User code should not expect to receive a result from \textit{tk\_chooseFont} and may not assume that the dialog has been withdrawn or closed when the command returns.

\section{Reference Implementation}

\url{http://sourceforge.net/support/tracker.php?aid=1477426}

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
