| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2011 by Raphaël Pinson <[email protected]> |
| 4 |
% --------------------------------------------------------------------------- |
| 5 |
% This work may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 7 |
% of this license or (at your option) any later version. |
| 8 |
% The latest version of this license is in |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 11 |
% version 2005/12/01 or later. |
| 12 |
% |
| 13 |
% This work has the LPPL maintenance status `maintained'. |
| 14 |
% |
| 15 |
% The Current Maintainer of this work is Raphaël Pinson. |
| 16 |
% |
| 17 |
% This work consists of the files fontbook.dtx and fontbook.ins |
| 18 |
% and the derived filebase fontbook.sty. |
| 19 |
% |
| 20 |
% \fi |
| 21 |
% |
| 22 |
% \iffalse |
| 23 |
%<*driver> |
| 24 |
\ProvidesFile{fontbook.dtx} |
| 25 |
%</driver> |
| 26 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 27 |
%<package>\ProvidesPackage{fontbook} |
| 28 |
%<*package> |
| 29 |
[2011/08/17 0.2 Generate a font book] |
| 30 |
%</package> |
| 31 |
% |
| 32 |
%<*driver> |
| 33 |
\documentclass[a4paper]{ltxdoc} |
| 34 |
\usepackage{fontbook}[2011/07/05] |
| 35 |
\usepackage{xltxtra} |
| 36 |
\EnableCrossrefs |
| 37 |
\CodelineIndex |
| 38 |
\RecordChanges |
| 39 |
\begin{document} |
| 40 |
\DocInput{fontbook.dtx} |
| 41 |
\PrintChanges |
| 42 |
\PrintIndex |
| 43 |
\end{document} |
| 44 |
%</driver> |
| 45 |
% \fi |
| 46 |
% |
| 47 |
% \CheckSum{69} |
| 48 |
% |
| 49 |
% \CharacterTable |
| 50 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 51 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 52 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 53 |
% Exclamation \! Double quote \" Hash (number) \# |
| 54 |
% Dollar \$ Percent \% Ampersand \& |
| 55 |
% Acute accent \' Left paren \( Right paren \) |
| 56 |
% Asterisk \* Plus \+ Comma \, |
| 57 |
% Minus \- Point \. Solidus \/ |
| 58 |
% Colon \: Semicolon \; Less than \< |
| 59 |
% Equals \= Greater than \> Question mark \? |
| 60 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 61 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 62 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 63 |
% Right brace \} Tilde \~} |
| 64 |
% |
| 65 |
% |
| 66 |
% \changes{0.2}{2011/08/17}{Fix some licenses and name} |
| 67 |
% \changes{0.1}{2011/07/05}{Converted to DTX file} |
| 68 |
% |
| 69 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 70 |
% |
| 71 |
% \providecommand*{\url}{\texttt} |
| 72 |
% \GetFileInfo{fontbook.dtx} |
| 73 |
% \title{The \textsf{fontbook} package} |
| 74 |
% \author{Raphaël Pinson \\ \url{[email protected]}} |
| 75 |
% \date{\fileversion~from \filedate} |
| 76 |
% |
| 77 |
% \maketitle |
| 78 |
% |
| 79 |
% \section{Introduction} |
| 80 |
% |
| 81 |
% \XeTeX{} allows us to make use of pretty much all possible fonts. |
| 82 |
% With all the possible fonts that can be used and the many features provided |
| 83 |
% by OpenType fonts, it can be useful to compile a font book of your favorite |
| 84 |
% fonts, so you can find the one you need more easily. This is what the |
| 85 |
% \textsf{fontbook} package is about. |
| 86 |
% |
| 87 |
% |
| 88 |
% \section{Usage} |
| 89 |
% |
| 90 |
% To use this package, simply include it: |
| 91 |
% |
| 92 |
% \begin{verbatim} |
| 93 |
% \usepackage{fontbook} |
| 94 |
% \end{verbatim} |
| 95 |
% |
| 96 |
% \subsection{Package Options} |
| 97 |
% |
| 98 |
% This package provides several options to fine-tune the way its commands react. |
| 99 |
% |
| 100 |
% \subsubsection{The \textsf{sizes} option} |
| 101 |
% |
| 102 |
% The \textsf{sizes} option lets you define which sizes |
| 103 |
% are to be printed for each font. |
| 104 |
% By default, all sizes from \textsf{huge} to \textsf{tiny} downward |
| 105 |
% are used: |
| 106 |
% \makeatletter\textsf{\fontbook@allsizes}\makeatother. |
| 107 |
% This option can take a single value or a list |
| 108 |
% of comma-separated values: |
| 109 |
% |
| 110 |
% \begin{verbatim} |
| 111 |
% \usepackage[sizes={large,huge}]{fontbook} |
| 112 |
% \end{verbatim} |
| 113 |
% |
| 114 |
% \subsubsection{The \textsf{features} option} |
| 115 |
% |
| 116 |
% Similarly to the \textsf{sizes} option, the \textsf{features} option |
| 117 |
% lets you define which features you wish to print for each font. |
| 118 |
% By default, the following features are used: |
| 119 |
% \makeatletter\textsf{\fontbook@allfeatures}\makeatother. |
| 120 |
% This option can take a single value or a list |
| 121 |
% of comma-separated values: |
| 122 |
% |
| 123 |
% \begin{verbatim} |
| 124 |
% \usepackage[features=scshape]{fontbook} |
| 125 |
% \end{verbatim} |
| 126 |
% |
| 127 |
% \subsubsection{The \textsf{featuresize} option} |
| 128 |
% |
| 129 |
% By default, features are typeset in size |
| 130 |
% \makeatletter\textsf{\fontbook@defaultfeaturesize}\makeatother. |
| 131 |
% This can be changed by passing the desired size name |
| 132 |
% as the \textsf{featuresize} option: |
| 133 |
% |
| 134 |
% \begin{verbatim} |
| 135 |
% \usepackage[featuresize=huge]{fontbook} |
| 136 |
% \end{verbatim} |
| 137 |
% |
| 138 |
% \subsection{Package commands} |
| 139 |
% |
| 140 |
% \DescribeMacro{\setsampletext} |
| 141 |
% |
| 142 |
% Set the sample text used in the font demo. |
| 143 |
% |
| 144 |
% \DescribeMacro{\printfont} |
| 145 |
% |
| 146 |
% This is the main command of this package |
| 147 |
% It takes 2 mandatory arguments and 1 optional argument. |
| 148 |
% The 2 mandatory arguments are the font name, as passed to |
| 149 |
% \textsf{fontspec}, and the license. |
| 150 |
% The optional argument is the fontspec option that allow |
| 151 |
% to set OpenType features for example: |
| 152 |
% |
| 153 |
% \begin{verbatim} |
| 154 |
% \printfont[Ligatures=Rare]{Linux Libertine O}{Public Domain} |
| 155 |
% \end{verbatim} |
| 156 |
% |
| 157 |
% \StopEventually{} |
| 158 |
% |
| 159 |
% \section{Implementation} |
| 160 |
% |
| 161 |
% \iffalse |
| 162 |
%<*package> |
| 163 |
% \fi |
| 164 |
% |
| 165 |
% \begin{macrocode} |
| 166 |
\ProvidesPackage{fontbook} |
| 167 |
\RequirePackage{fontspec} |
| 168 |
\RequirePackage{xunicode} |
| 169 |
\RequirePackage{kvoptions} |
| 170 |
\RequirePackage{etoolbox} |
| 171 |
\SetupKeyvalOptions{ |
| 172 |
family=fontbook, |
| 173 |
prefix=fontbook@, |
| 174 |
} |
| 175 |
% \end{macrocode} |
| 176 |
%% Options |
| 177 |
% |
| 178 |
% |
| 179 |
% \begin{macro}{\fontbook@allsizes} |
| 180 |
% Sizes |
| 181 |
% \begin{macrocode} |
| 182 |
\def\fontbook@allsizes{% |
| 183 |
huge, LARGE, Large, large, normalsize, |
| 184 |
small, footnotesize, scriptsize, tiny} |
| 185 |
\expandafter\DeclareStringOption\expandafter[\fontbook@allsizes]{sizes} |
| 186 |
% \end{macrocode} |
| 187 |
% \end{macro} |
| 188 |
% |
| 189 |
% |
| 190 |
% \begin{macro}{\fontbook@allfeatures} |
| 191 |
% Features |
| 192 |
% \begin{macrocode} |
| 193 |
\def\fontbook@allfeatures{% |
| 194 |
scshape, itshape, bfseries} |
| 195 |
\expandafter\DeclareStringOption\expandafter[\fontbook@allfeatures]{features} |
| 196 |
\def\fontbook@defaultfeaturesize{large} |
| 197 |
\expandafter\DeclareStringOption\expandafter[\fontbook@defaultfeaturesize]{featuresize} |
| 198 |
\ProcessKeyvalOptions* |
| 199 |
% \end{macrocode} |
| 200 |
% \end{macro} |
| 201 |
% |
| 202 |
% |
| 203 |
% \begin{macro}{\fontbook@sampletext} |
| 204 |
% \begin{macrocode} |
| 205 |
\def\fontbook@sampletext{% |
| 206 |
Dans l'affliction éphémère qui m'accable, je teste |
| 207 |
la police d'affichage qui est utilisée sur cette page 1 2 3 4 5. |
| 208 |
} |
| 209 |
% \end{macrocode} |
| 210 |
% \end{macro} |
| 211 |
% |
| 212 |
% |
| 213 |
% \begin{macro}{\sampletext} |
| 214 |
% \begin{macrocode} |
| 215 |
\newcommand{\sampletext}[2][]{% |
| 216 |
{\par\csname#2\endcsname \csname#1\endcsname |
| 217 |
#2 #1\\ \fontbook@sampletext}} |
| 218 |
% \end{macrocode} |
| 219 |
% \end{macro} |
| 220 |
% |
| 221 |
% |
| 222 |
% \begin{macro}{\setsampletext} |
| 223 |
% \begin{macrocode} |
| 224 |
\newcommand{\setsampletext}[1]{% |
| 225 |
\def\fontbook@sampletext{#1}} |
| 226 |
% \end{macrocode} |
| 227 |
% \end{macro} |
| 228 |
% |
| 229 |
% |
| 230 |
% \begin{macro}{\samplefeature} |
| 231 |
% \begin{macrocode} |
| 232 |
\newcommand{\samplefeature}[1]{% |
| 233 |
\sampletext[#1]{\fontbook@featuresize}} |
| 234 |
%% TODO: call font once |
| 235 |
%%%% print all variants |
| 236 |
% |
| 237 |
% \end{macrocode} |
| 238 |
% \end{macro} |
| 239 |
% |
| 240 |
% |
| 241 |
% \begin{macro}{\printfont} |
| 242 |
% \begin{macrocode} |
| 243 |
\newcommand{\printfont}[3][\empty]{% |
| 244 |
\fontspec[#1]{#2} |
| 245 |
\section*{#2 #1 --- Licence: #3} |
| 246 |
\ifx#1\empty |
| 247 |
\addcontentsline{toc}{section}{#2} |
| 248 |
\else |
| 249 |
\addcontentsline{toc}{subsection}{#1} |
| 250 |
\fi |
| 251 |
\expandafter\forcsvlist\expandafter\sampletext\expandafter{\fontbook@sizes} |
| 252 |
\expandafter\forcsvlist\expandafter\samplefeature\expandafter{\fontbook@features} |
| 253 |
\pagebreak |
| 254 |
} |
| 255 |
% \end{macrocode} |
| 256 |
% \end{macro} |
| 257 |
% |
| 258 |
% |
| 259 |
% \iffalse |
| 260 |
%</package> |
| 261 |
% \fi |
| 262 |
% |
| 263 |
% \Finale |
| 264 |
\endinput |