diff options
Diffstat (limited to 'Master/texmf-dist/source/xelatex/fontspec/fontspec.dtx')
-rw-r--r-- | Master/texmf-dist/source/xelatex/fontspec/fontspec.dtx | 1572 |
1 files changed, 1021 insertions, 551 deletions
diff --git a/Master/texmf-dist/source/xelatex/fontspec/fontspec.dtx b/Master/texmf-dist/source/xelatex/fontspec/fontspec.dtx index fd85b0232ce..e1824682b9c 100644 --- a/Master/texmf-dist/source/xelatex/fontspec/fontspec.dtx +++ b/Master/texmf-dist/source/xelatex/fontspec/fontspec.dtx @@ -5,21 +5,24 @@ % Copyright 2005 by Will Robertson <wspr81@gmail.com> % % Distributable under the LaTeX Project Public License, -% version 1.3a or higher (your choice). The latest version of +% version 1.3c or higher (your choice). The latest version of % this license is at: http://www.latex-project.org/lppl.txt % % This work is "maintained" (as per LPPL maintenance status) % by Will Robertson. % % This work consists of the file fontspec.dtx -% and the derived files fontspec.sty and fontspec.pdf. +% and the derived files fontspec.sty, +% fontspec.ins, +% and fontspec.pdf. % -% -%<*batchfile> +%<*internalbatchfile> \begingroup +%</internalbatchfile> +%<*batchfile> \input docstrip.tex \keepsilent -\usedir{xetex/latex/fontspec} +\usedir{tex/xelatex/fontspec} \preamble ________________________________ @@ -32,10 +35,10 @@ \endpreamble \postamble -Copyright 2005 by Will Robertson <wspr81@gmail.com> +Copyright 2005-2006 by Will Robertson <wspr81@gmail.com> Distributable under the LaTeX Project Public License, -version 1.3b or higher (your choice). The latest version of +version 1.3c or higher (your choice). The latest version of this license is at: http://www.latex-project.org/lppl.txt This work is "maintained" (as per LPPL maintenance status) @@ -47,13 +50,16 @@ This work consists of the file fontspec.dtx \endpostamble \askforoverwritefalse \generate{\file{fontspec.sty}{\from{fontspec.dtx}{fontspec}}} +\generate{\file{fontspec-doc-style.sty}{\from{fontspec.dtx}{doc-style}}} \nopreamble\nopostamble \generate{\file{fontspec.cfg}{\from{fontspec.dtx}{cfg}}} \generate{\file{fontspec.ins}{\from{fontspec.dtx}{batchfile}}} -\generate{\file{fontspec-example.tex}{\from{fontspec.dtx}{example}}} -\generate{\file{fontspec-doc-style.sty}{\from{fontspec.dtx}{doc-style}}} -\endgroup +\generate{\file{fontspec-example.ltx}{\from{fontspec.dtx}{example}}} %</batchfile> +%<batchfile>\endbatchfile +%<*internalbatchfile> +\endgroup +%</internalbatchfile> % %<*driver> \documentclass{ltxdoc} @@ -63,26 +69,26 @@ This work consists of the file fontspec.dtx \RecordChanges %\OnlyDescription \begin{document} +\ifxetex \DocInput{fontspec.dtx} +\fi \end{document} %</driver> % %<*fontspec> \ProvidesPackage{fontspec} - [2006/06/07 v1.10 Advanced font selection for XeLaTeX] + [2006/12/24 v1.13 Advanced font selection for XeLaTeX] %</fontspec> % % \fi % -% \CheckSum{2270} -% % \makeatletter ^^A% To document @-cmds % \errorcontextlines=999 ^^A% Show up all my mistakes % % \GetFileInfo{fontspec.sty} % -% \title{The \pkg{fontspec} package} -% \author{Will Robertson} +% \title{The {\fontspec[Scale=0.82,Variant=3]{Zapfino}{\addfontfeature{Variant=4}f}ontspec} package} +% \author{\scshape Will Robertson} % \date{\filedate \qquad \fileversion} % % \maketitle @@ -95,17 +101,17 @@ This work consists of the file fontspec.dtx % now easily access system-wide fonts directly in a \TeX\ % variant, providing a best of both worlds environment. \XeTeX\ % eliminates the need for all those files required for installing -% fonts (|.tfm|, |.vf|, |.map|,\dots) and provides an easy +% fonts (|.tfm|, |.vf|, |.map|, \dots) and provides an easy % way to select fonts in Plain \TeX: |\font\tenrm="Times New Roman" at 10pt|. % -% However, it was still necessary to write cumbersome font definition +% Before \pkg{fontspec}, it was still necessary to write cumbersome font definition % files for \LaTeX, since the NFSS had a lot more going on behind the % scenes to allow easy commands like \cmd\emph\ or \cmd\bfseries. % -% This package almost entirely eliminates this need by providing a +% This package provides a % completely automatic way to select font families in \LaTeX\ for -% arbitrary fonts. Furthermore, it allows (again, almost) total -% control over the selection of rich font features such as number case +% arbitrary fonts. Furthermore, it allows very flexible +% control over the selection of advanced font features such as number case % and fancy ligatures (and many more!) present in most modern fonts. % % \subsection{Usage} @@ -113,15 +119,34 @@ This work consists of the file fontspec.dtx % \begin{Verbatim}[gobble=4] % \usepackage{fontspec}% provides font selecting commands % \usepackage{xunicode}% provides unicode character macros +% \usepackage{xltxtra} % provides some fixes/extras % \end{Verbatim} -% \name{Ross Moore}'s \textsf{xunicode} package is highly recommended, as it +% \name{Ross Moore}'s \pkg{xunicode} package is highly recommended, as it % provides access \LaTeX's various methods for accessing extra % characters and accents (for example, |\%|, |\$|, |\textbullet|, |\"u|, and % so on), plus many more unicode characters. % +% The \pkg{xltxtra} package adds a couple of general improvements to \LaTeX\ under +% \XeTeX; it also provides the \cmd\XeTeX\ macro to typeset the \XeTeX\ logo. +% % \emph{The \pkg{babel} package is not really supported!} Especially Vietnamese, -% Greek, and Hebrew at least will all not work correctly, as far as I can tell. -% Cyrillic and Latin-based languages, however, should at least be supported. +% Greek, and Hebrew at least might not work correctly, as far as I can tell. +% There's a better chance with Cyrillic and Latin-based languages, however---\pkg{fontspec} ensures +% at least that fonts should load correctly, but hyphenation and other matters +% aren't guaranteed. +% +% \subsubsection{Latin Modern defaults} +% \pkg{fontspec} defines a new \LaTeX\ font encoding for its purposes to allow +% the Latin Modern fonts to be used by default \new{v1.12}. This has three implications: +% \begin{enumerate} +% \item Unicode fonts are loaded by default; it didn't make sense to have the legacy Computer Modern fonts in the Unicode-enabled \XeTeX. +% \item If you don't have the Latin Modern OpenType fonts installed, you might want to consider doing so. +% \item \pkg{fontspec} also requires the \pkg{euenc} package\footnote{\url{http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=euenc}} to be installed. +% \end{enumerate} +% Another package option is provided for controlling this behaviour: |[cm-default]| +% will ignore the Latin Modern fonts and go about things as it used to. Use this +% option if you don't have the Latin Modern fonts installed or you (Mac-specifically) +% want to use the `default \TeX\ font' without using the |xdvipdfmx| driver. % % \subsubsection{Configuration} % If you wish to customise any part of the \pkg{fontspec} interface (see later @@ -152,16 +177,15 @@ This work consists of the file fontspec.dtx % % Such things, and some other comments, are noted in the margin like % this~\warn{v1.6}{An example warning!}, with a red arrow if the -% change is relevant to the current release of the package. +% change is relevant to the current release of the package. (New features +% are denoted similarly in blue.) % % \subsection{About this manual} % This document has been typeset with \XeTeX\ using a variety of fonts % to display various features that the package supports. You will not % be able to typeset the documentation if you do not have all of these -% fonts, although I've used as many Mac~OS~X pre-installed fonts as -% possible. Running normal \LaTeX\ (\ie, with\emph{out} \XeTeX) on -% this file will generate the \texttt{fontspec.sty} file if this is -% required for some odd reason. +% fonts, many of which are distributed with \MacOSX\ or are otherwise +% commercial. % % Many examples are shown in this manual. These are typeset % side-by-side with their verbatim source code, although various @@ -200,13 +224,13 @@ This work consists of the file fontspec.dtx % \def\pangram{The five boxing % wizards jump quickly.\\} % \fontspec{Hoefler Text} \pangram -% { \itshape \pangram } -% { \scshape \pangram } -% { \scshape\itshape \pangram } +% {\itshape \pangram} +% {\scshape \pangram} +% {\scshape\itshape \pangram} % \bfseries \pangram -% { \itshape \pangram } -% { \scshape \pangram } -% { \itshape\scshape \pangram } +% {\itshape \pangram} +% {\scshape \pangram} +% {\itshape\scshape \pangram} % \end{example} % The \pkg{fontspec} package takes care of the necessary font % definitions for those shapes as shown above @@ -214,31 +238,17 @@ This work consists of the file fontspec.dtx % the font for \XeTeX\ in any way whatsoever: every font that is % installed in the operating system may be accessed. % -% \subsection{Font instances for efficiency} -% For cases when a specific font with a specific feature set is going -% to be re-used many times in a document, it is inefficient to keep -% calling \cs{fontspec} for every use. While the command does not -% define a new font instance after the first call, the feature options -% must still be parsed and processed. -% -% \DescribeMacro{\newfontinstance} For this reason, \emph{instances} -% of a font may be created with the \cs{newfontinstance} command, as -% shown in the following example: -% \begin{example} -% \newfontinstance\secfont[Letters=SmallCaps]{Hoefler Text} -% \secfont Font instances for efficiency -% \end{example} -% % \subsection{Default font families}\label{sec:setxxfont} -% \DescribeMacro{\setromanfont} \DescribeMacro{\setsansfont} -% \DescribeMacro{\setmonofont} The \cs{setromanfont}, +% \DescribeMacro{\setmainfont} \DescribeMacro{\setsansfont} +% \DescribeMacro{\setmonofont} The \cs{setmainfont}, +% \note{Or \cmd\setromanfont, a historical name that doesn't make much sense when you're, say, typesetting Greek.} % \cs{setsansfont}, and \cs{setmonofont} commands are used to select % the default font families for the entire document. They take the % same arguments as \cmd{\fontspec}. For example: -% \begin{example} % \def\pangram{Pack my box with five % dozen liquor jugs.} -% \setromanfont{Baskerville} +% \begin{example} +% \setmainfont{Baskerville} % \setsansfont[Scale=0.86]{Skia} % \setmonofont[Scale=0.8]{Monaco} % \rmfamily\pangram\par @@ -250,15 +260,47 @@ This work consists of the file fontspec.dtx % further in \vref{sec:font-ind-features}, including methods for automatic % scaling. % +% \subsection{Font instances for efficiency} +% \DescribeMacro{\newfontfamily} +% For cases when a specific font with a specific feature set is going +% to be re-used many times in a document, it is inefficient to keep +% calling \cs{fontspec} for every use. While the command does not +% define a new font instance after the first call, the feature options +% must still be parsed and processed. +% +% For this reason, \emph{instances} +% of a font may be created with the \cmd\newfontfamily\ command, +% \warn{v1.11}{This macro used to be called \cmd\newfontinstance. +% Backwards compatibility is preserved via \texttt{fontspec.cfg}.} +% as shown in the following example: +% \begin{example} +% \newfontfamily\notefont{Didot} +% \notefont This is a \emph{note}. +% \end{example} +% This macro should be used to create commands that would be used in +% the same way as \cmd\rmfamily, for example. +% +% \DescribeMacro{\newfontface} +% Sometimes only a specific font face is desired, without accompanying italic or bold variants. +% This is common when selecting a fancy italic font, say, that has swash features unavailable +% in the upright forms. \cmd\newfontface\ is used for this purpose: \new{v1.11} +% \begin{example} +% \newfontface\fancy +% [Contextuals={WordInitial,WordFinal}] +% {Hoefler Text Italic} +% \fancy where is all the vegemite +% \end{example} +% \noindent This example is repeated in \vref{sec:contextuals}. +% % \subsection{Arbitrary bold/italic/small caps fonts} \label{sec:bfitfonts} % The automatic bold, italic, and bold italic font selections will not be % adequate for the needs of every font: while some fonts mayn't even % have bold or italic shapes, in which case a skilled (or lucky) % designer may be able to chose well-matching accompanying shapes from % a different font altogether, others can have a range of bold and -% italic fonts to chose between. The \opt{BoldFont} and -% \opt{ItalicFont} options~\warn{v1.6}{These options used to be called -% \opt{Bold} and \opt{Italic}, and these shorter names may still be +% italic fonts to chose between. The \feat{BoldFont} and +% \feat{ItalicFont} features~\warn{v1.6}{These features used to be called +% \feat{Bold} and \feat{Italic}, and these shorter names may still be % used if you desire.} are provided for these situations. If only % one of these is used, the bold italic font is requested as the % default from the \emph{new} font. @@ -271,8 +313,8 @@ This work consists of the file fontspec.dtx % {\bfseries\itshape Helvetica Neue Italic} \\ % \end{example} % If a bold italic shape is not defined, or you want to specify -% \emph{both} custom bold and italic shapes, the \opt{BoldItalicFont} -% option is provided~\warn{v1.6}{Yes, \opt{BoldItalic} also works}. +% \emph{both} custom bold and italic shapes, the \feat{BoldItalicFont} +% feature is provided~\warn{v1.6}{\opt{BoldItalic} also works}. % % For those cases that the base font name is repeated, you can % replace it with an asterisk (first character only). For example, @@ -297,7 +339,7 @@ This work consists of the file fontspec.dtx % % \subsection{Math(s) fonts} % -% When \cmd\setromanfont, \cmd\setsansfont\ and \cmd\setmonofont\ are +% When \cmd\setmainfont, \cmd\setsansfont\ and \cmd\setmonofont\ are % used in the preamble, they also define the fonts to be used in maths % mode inside the \cmd\mathrm-type commands. This only occurs in the % preamble because \LaTeX\ freezes the maths fonts after this stage of @@ -323,13 +365,13 @@ This work consists of the file fontspec.dtx % \begin{Verbatim}[gobble=4] % \usepackage[mathcal]{euler} % \usepackage{fontspec,xunicode} -% \setromanfont{Optima Regular} +% \setmainfont{Optima Regular} % \setmathrm{Optima} % \setboldmathrm[BoldFont=Optima ExtraBlack]{Optima Bold} % \end{Verbatim} % and this would allow you to typeset something like this: % \begingroup -% \setromanfont{Optima Regular} +% \setmainfont{Optima Regular} % \begin{example} % $ X \rightarrow \mathrm{X} \rightarrow \mathbf{X} $ % \\\boldmath @@ -337,6 +379,31 @@ This work consists of the file fontspec.dtx % \end{example} % \endgroup % +% \subsection{External fonts} +% \XeTeX\ v0.995 introduced the feature of loading +% fonts not installed through the operating system (`external' fonts). This feature is currently +% only available through the |xdvipdfmx| driver, which is notably \emph{not} +% the default on \MacOSX. +% +% This feature is handled in \pkg{fontspec} with the font feature \feat{ExternalLocation}. +% When this feature is used, the main argument to \cmd\fontspec\ is the \emph{file name} of the +% font (in contrast to the usual syntax which requires the font display name) and the argument +% to the feature is the (absolute) path to the font. For example: +% \begin{verbatim} +% \fontspec[ExternalLocation=/Users/will/Fonts/]{CODE2000.TTF} +% \end{verbatim} +% +% If no path is given, then the font will be found in a location normally searched by +% \XeTeX, including the current directory. For example, the following declaration +% could load either the Latin Modern roman font in the current directory or, say, +% in \path{$TEXMF/fonts/opentype/public/lm/}: +% \begin{verbatim} +% \fontspec[ExternalLocation]{lmroman10-regular} +% \end{verbatim} +% +% Bold and italic fonts cannot be automatically selected when external fonts +% are being used; they must be explicitly declared using the methods +% described in \vref{sec:bfitfonts}. % % \subsection{Miscellaneous font selecting details} % @@ -350,18 +417,6 @@ This work consists of the file fontspec.dtx % conjunction. (This was implicitly shown in the first example, % but it's worth mentioning now, too.) % -% In previous versions of \XeTeX, -% nesting of \LaTeX's emphasis font switching was broken. To make it -% more reliable, \pkg{fontspec} overrides it anyway, and copies a feature -% from the \pkg{fixltx2e} package: \cmd\eminnershape\ defines how nested -% emphasis should look: -% \begin{example} -% \renewcommand\eminnershape{\scshape} -% \fontspec{Didot} -% Nested {\em emphasis is \emph{now} fixed.} -% \end{example} - -% % % \section{Selecting font features} \label{sec:selectingfeature} % @@ -401,13 +456,13 @@ This work consists of the file fontspec.dtx % 13 boats. In 1923, 111 people sailed 54 % miles in 56 boats.' \bigskip % -% \addfontfeatures{Numbers={Monospaced,Lining}} +% {\addfontfeatures{Numbers={Monospaced,Lining}} % \begin{tabular}{@{} cccc @{}} % \toprule Year & People & Miles & Boats \\ % \midrule 1842 & 999 & 75 & 13 \\ % 1923 & 111 & 54 & 56 \\ % \bottomrule -% \end{tabular} +% \end{tabular}} % \end{example} % \DescribeMacro{\addfontfeature} % This command may also be executed under the alias \cmd{\addfontfeature}. @@ -470,8 +525,61 @@ This work consists of the file fontspec.dtx % \itshape Bold Italic {\scshape Bold Italic Small Caps} % \end{example} % +% \subsection{Different features for different font sizes} +% \label{sec:sizefeature} % +% The \feat{SizeFeature} feature \new{v1.13} is a little more complicated +% than the previous features discussed. It allows different fonts +% and different font features to be selected for a given font +% family as the point size varies. % +% It takes a comma separated list of braced, comma separated lists of features for each size range. +% Each sub-list must contain the \opt{Size} option +% to declare the size range, and optionally \opt{Font} to change the +% font based on size. Other (regular) fontspec features that are added +% are used on top of the font features that would be used anyway. +% +% \begin{example} +% \fontspec[ SizeFeatures={ +% {Size={-8}, Font=Apple Chancery, Colour=AA0000}, +% {Size={8-14}, Colour=00AA00}, +% {Size={14-}, Colour=0000AA}} ]{Skia} +% {\scriptsize Small\par} Normal size\par {\Large Large\par} +% \end{example} +% A less trivial example is shown in the context of optical font sizes +% in \vref{sec:opticalsize}. +% +% To be precise, the \opt{Size} sub-feature accepts arguments in the form shown in \vref{tab:sizing}. +% Braces around the size range are optional. For an exact font size (|Size=X|) +% font sizes chosen near that size will `snap'. For example, for size definitions +% at exactly 11pt and 14pt, if a 12pt font is requested \emph{actually} the +% 11pt font will be selected. This is a remnant of the past when fonts were designed +% in metal (at obviously rigid sizes) and later when bitmap fonts were similarly +% designed for fixed sizes. +% +% If additional features are only required for a single size, the other sizes +% must still be specified. As in: +% \begin{verbatim} +% SizeFeatures={ +% {Size=-10,Numbers=Uppercase}, +% {Size=10-}} +% \end{verbatim} +% Otherwise, the font sizes greater than 10 won't be defined! +% +% \begin{table} +% \centering +% \begin{tabular}{@{}ll@{}} +% \toprule +% Input & Font size, $s$ \\ +% \midrule +% |Size = X-| & $s \geq \texttt{X}$ \\ +% |Size = -Y| & $s < \texttt{Y}$ \\ +% |Size = X-Y| & $\texttt{X} \leq s < \texttt{Y}$ \\ +% |Size = X| & $s = \texttt{X}$ \\ +% \bottomrule +% \end{tabular} +% \caption{Syntax for specifying the size to apply custom font features.}\label{tab:sizing} +% \end{table} % % % \section{Font independent options} \label{sec:font-ind-features} @@ -493,10 +601,10 @@ This work consists of the file fontspec.dtx % the current default roman font to either the height of the lowercase or % uppercase letters, respectively. % \begin{example} -% \setromanfont{Georgia} -% \newfontinstance\lc[Scale=MatchLowercase]{Verdana} +% \setmainfont{Georgia} +% \newfontfamily\lc[Scale=MatchLowercase]{Verdana} % The perfect match {\lc is hard to find.}\\ -% \newfontinstance\uc[Scale=MatchUppercase]{Arial} +% \newfontfamily\uc[Scale=MatchUppercase]{Arial} % L O G O \uc F O N T % \end{example} % The amount of scaling used in each instance is reported in the \texttt{.log} file. @@ -563,11 +671,6 @@ This work consists of the file fontspec.dtx % can do with the text! Unlike \TeX, \MacOSX\ will allow % fonts to letterspace themselves, which can be seen above; OpenType fonts, however, will not % show this tendency, as they do not support this arguably dubious feature. -% -% \textbf{Beware!} A font at a single scaling can only have a single -% set of interword space values, regardless of additional \pkg{fontspec} features. -% To obtain, say, two Cochin fonts with different amounts of interword space, -% it would be necessary to scale the second by a negligible amount, as in |Scale=0.9999|. % % \subsection{Post-punctuation space} % @@ -600,7 +703,7 @@ This work consists of the file fontspec.dtx % \subsection{Letter spacing} % Letter spacing, or tracking, is the term given to adding (or subtracting) a small amount of horizontal space in between adjacent characters. It is specified with the \feat{LetterSpace}, which takes a numeric argument. % -% That the letter spacing parameter is a normalised additive factor (not a scaling factor); it is defined as a percentage of the font size. That is, for a 10\,pt font, a letter spacing parameter of `|1.0|' will add 0.1\,pt between each letter. +% The letter spacing parameter is a normalised additive factor (not a scaling factor); it is defined as a percentage of the font size. That is, for a 10\,pt font, a letter spacing parameter of `|1.0|' will add 0.1\,pt between each letter. % \begin{example} % \fontspec{Didot} % \addfontfeature{LetterSpace=0.0} @@ -641,7 +744,7 @@ This work consists of the file fontspec.dtx % Note that in an actual situation, the \opt{Uppercase} option of the \feat{Letters} feature % would probably supply this for you (see \vref{sec:letters}). % -% The \pkg{xelatex} package redefines \LaTeX's \cmd\-\ macro +% The \pkg{xltxtra} package redefines \LaTeX's \cmd\-\ macro % such that it adjusts along with the above changes. % % \section{Font-dependent features} \label{sec:features} @@ -755,7 +858,18 @@ This work consists of the file fontspec.dtx % MM optical size test \\ % \end{aatexample} % -% +% The \feat{SizeFeatures} feature (\vref{sec:sizefeature}) can be +% used to specify exactly which optical sizes will be used for ranges +% of font size. For example, something like +% \begin{verbatim} +% \fontspec[ +% SizeFeatures={ +% {Size=-10, OpticalSize=8 }, +% {Size= 10-14, OpticalSize=10}, +% {Size= 14-18, OpticalSize=14}, +% {Size= 18-, OpticalSize=18}} +% ]{Warnock Pro} +% \end{verbatim} % % \subsection{Ligatures} % @@ -826,8 +940,8 @@ This work consists of the file fontspec.dtx % \end{opentypeexample} % The \opt{Uppercase} option is also provided \emph{but} it will (probably) % not actually map letters to uppercase. -% \note{If you want automatic uppercase letters, look into the -% \cmd\MakeUppercase\ command, as defined by \LaTeX.} +% \note{If you want automatic uppercase letters, look to \LaTeX's +% \cmd\MakeUppercase\ command.} % It will, however, select various % uppercase forms for glyphs such as accents and dashes. % \begin{opentypeexample} @@ -861,7 +975,7 @@ This work consists of the file fontspec.dtx % 0123456789 % \end{opentypeexample} % -% \subsection{Contextuals} +% \subsection{Contextuals} \label{sec:contextuals} % This feature refers to glyph substitution that vary by their position; % things like contextual swashes are implemented here % \warn{v1.9}{This feature used to be called \feat{Swashes}. This name still works, for now.}. @@ -871,10 +985,10 @@ This work consists of the file fontspec.dtx % non-exclusive selectors, like the ligatures, you can turn them off % by prefixing their name with \opt{No}. % \begin{aatexample} -% \fontspec +% \newfontface\fancy % [Contextuals={WordInitial,WordFinal}] % {Hoefler Text Italic} -% where is all the vegemite +% \fancy where is all the vegemite % \end{aatexample} % \begin{aatexample} % \fontspec[Contextuals=Inner]{Hoefler Text} @@ -895,56 +1009,11 @@ This work consists of the file fontspec.dtx % contextual in OpenType, which is why it is not included here. % % -% \subsection{Diacritics} -% Diacritics refer to characters that include extra marks that usually -% indicate pronunciation; \eg, accented letters. You may either choose -% to \opt{Show}, \opt{Hide} or \opt{Decompose} them in AAT fonts. -% -% Some fonts include |O/| \etc\ as diacritics for writing \O. You'll -% want to turn this feature off (imagine typing |hello/goodbye| and -% getting `hell\o goodbye' instead!) by decomposing the two characters -% in the diacritic into the ones you actually -% want. I would recommend using -% the proper \TeX\ input conventions for obtaining such characters -% instead. -% \begin{aatexample} -% \fontspec[Diacritics=Show]{Palatino} -% O´ \quad O¨ \quad O/ \par -% \fontspec[Diacritics=Decompose]{Palatino} -% O´ \quad O¨ \quad O/ \par -% Better: \'O \"O \O % (requires xunicode) -% \end{aatexample} -% The \opt{Hide} option is for Arabic-like fonts which may be -% displayed either with or without vowel markings. -% -% No options for OpenType fonts. -% -% \subsection{Kerning}\label{sec:kerning} -% Well designed fonts contain kerning information that controls the spacing between -% letter pairs, on an individual basis. The \feat{Kerning} feature provides -% options to control this, for OpenType fonts only. -% -% The options provided for now are \opt{On}, \opt{Off}, and \opt{Uppercase}. -% \begin{opentypeexample} -% \fontspec{Warnock Pro} -% Ta AV \\ -% \fontspec[Kerning=Off]{Warnock Pro} -% Ta AV -% \end{opentypeexample} -% -% As briefly mentioned previously at the end of \vref{sec:letters}, -% the \opt{Uppercase} option will add a small amount of tracking between uppercase letters: -% \begin{opentypeexample} -% \fontspec{Warnock Pro} -% UPPER-CASE EXAMPLE \\ -% \addfontfeature{Kerning=Uppercase} -% UPPER-CASE EXAMPLE -% \end{opentypeexample} -% % \subsection{Vertical position} -% Some subscript (\opt{Superior}) and superscript (\opt{Inferior}) numbers and -% letters (and a small amount of punctuation, sometimes) are available -% in various fonts. The \opt{Ordinal} feature is (supposed to be) +% The \feat{VerticalPosition} feature is used to access things like +% subscript (\opt{Superior}) and superscript (\opt{Inferior}) numbers and +% letters (and a small amount of punctuation, sometimes). +% The \opt{Ordinal} option is (supposed to be) % contextually sensitive to only raise characters that appear directly % after a number. % \begin{aatexample} @@ -975,7 +1044,7 @@ This work consists of the file fontspec.dtx % `Ordinals': 1st 2nd 3rd 4th 0th % \end{opentypeexample} % -% The \pkg{xelatex} package redefines the \cmd\textsubscript\ and +% The \pkg{xltxtra} package redefines the \cmd\textsubscript\ and % \cmd\textsuperscript\ commands to use the above font features. % % \subsection{Fractions} @@ -989,12 +1058,13 @@ This work consists of the file fontspec.dtx % be obtained by typing `{\fontspec{Lucida Grande}⌥⇧\,1}', is (supposed) % to be used to create fractions. When \feat{Fractions} are turned % \opt{On}, then (supposedly) only pre-drawn fractions will be used. -% \setmonofont[Scale=0.8]{Monaco} +% \begingroup\setmonofont[Scale=0.8]{Monaco} % \begin{aatexample} % \fontspec[Fractions=On]{Palatino} % 1⁄2 \quad 5⁄6 \\ % fraction slash % 1/2 \quad 5/6 % regular slash % \end{aatexample} +% \endgroup % Using the \opt{Diagonal} option (AAT only), the font will attempt % to create the fraction from superscript and subscript % characters. This is shown in the following example by Hoefler Text, @@ -1004,7 +1074,6 @@ This work consists of the file fontspec.dtx % 13579⁄24680 \\ % fraction slash % \quad 13579/24680 % regular slash % \end{aatexample} -% \setmonofont[Scale=0.95]{Osaka-Mono} % OpenType fonts simply use a regular text slash to create fractions: % \begin{opentypeexample} % \fontspec{Hiragino Maru Gothic Pro W4} @@ -1012,7 +1081,7 @@ This work consists of the file fontspec.dtx % \addfontfeature{Fractions=On} % 1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\ % \end{opentypeexample} -% Some (Asian fonts predominantly, perhaps) also provide for the +% Some (Asian fonts predominantly) also provide for the % \opt{Alternate} feature: % \begin{opentypeexample} % \fontspec{Hiragino Maru Gothic Pro W4} @@ -1020,7 +1089,7 @@ This work consists of the file fontspec.dtx % \addfontfeature{Fractions=Alternate} % 1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\ % \end{opentypeexample} -% The \pkg{xelatex} package provides a \cmd\vfrac\ command +% The \pkg{xltxtra} package provides a \cmd\vfrac\ command % for creating arbitrary so-called `vulgar' fractions: % \begin{opentypeexample} % \fontspec{Warnock Pro} @@ -1044,12 +1113,10 @@ This work consists of the file fontspec.dtx % Colour=005599\thetrans\thetrans]{Zapfino}% % \makebox[0.75\width]{d}% % \stepcounter{var}} -% \vspace{-1cm} % \end{aatexample} % For OpenType fonts, \opt{Variant} selects a `Stylistic Set', again % specified numerically. I don't have a font to % demonstrate this feature with, unfortunately. -% % See \vref{sec:newfeatures} for a way to assign names to variants, % which should be done on a per-font basis. % @@ -1075,6 +1142,15 @@ This work consists of the file fontspec.dtx % \footnotetext{`Ruby' refers to a small optical size, used in % Japanese typography for annotations.} % \let\savemark\@thefnmark +% \setexsize\huge +% \begin{aatexample} +% \newfontface\officedoor[Style=Engraved]{Hoefler Text} +% \officedoor [ABCD\dots WXYZ] +% \end{aatexample} +% ICU supported options are \opt{Alternate}, +% \opt{Italic}, \opt{Historic}, +% \opt{Ruby},\footnotemark[\savemark] +% \opt{Swash}, \opt{TitlingCaps}, \opt{HorizontalKana}, and \opt{VerticalKana}. % \setexsize\Large % \begin{opentypeexample} % \fontspec{Warnock Pro} @@ -1082,14 +1158,7 @@ This work consists of the file fontspec.dtx % \addfontfeature{Style=Alternate} % K Q R k v w y % \end{opentypeexample} -% \setexsize\huge -% \begin{aatexample} -% \fontspec[Style=Engraved]{Hoefler Text} -% [ABCD\dots WXYZ] -% \end{aatexample} -% ICU supported options are \opt{Alternate}, -% \opt{Italic}, \opt{Historic}, \opt{Ruby},\footnotemark[\savemark] -% \opt{Swash}, \opt{TitlingCaps}, \opt{HorizontalKana}, and \opt{VerticalKana}. +% Note the occasional inconsistency with which font features are labelled; a long-tailed `Q' could turn up anywhere! % \setexsize\Large % \begin{opentypeexample} % \fontspec{Adobe Jenson Pro} @@ -1104,6 +1173,7 @@ This work consists of the file fontspec.dtx % \addfontfeature{Style=TitlingCaps} % TITLING CAPS % \end{example} +% Two features in one example; \opt{Italic} affects the Latin text and \opt{Ruby} the Japanese: % \setexsize\Large % \begin{opentypeexample} % \fontspec{Hiragino Mincho Pro W3} @@ -1111,6 +1181,7 @@ This work consists of the file fontspec.dtx % \addfontfeature{Style={Italic, Ruby}} % Latin ようこそ ワカヨタレソ % \end{opentypeexample} +% Note the difference here between the default and the horizontal style kana: % \setexsize\Large % \begin{aatexample} % \fontspec{Hiragino Mincho Pro} @@ -1121,6 +1192,52 @@ This work consists of the file fontspec.dtx % ようこそ ワカヨタレソ} % \end{aatexample} % +% \subsection{Diacritics} +% Diacritics refer to characters that include extra marks that usually +% indicate pronunciation; \eg, accented letters. You may either choose +% to \opt{Show}, \opt{Hide} or \opt{Decompose} them in AAT fonts. +% +% Some fonts include |O/| \etc\ as diacritics for writing \O. You'll +% want to turn this feature off (imagine typing |hello/goodbye| and +% getting `hell\o goodbye' instead!) by decomposing the two characters +% in the diacritic into the ones you actually +% want. I would recommend using +% the proper \TeX\ input conventions for obtaining such characters +% instead. +% \begin{aatexample} +% \fontspec[Diacritics=Show]{Palatino} +% O´ \quad O¨ \quad O/ \par +% \fontspec[Diacritics=Decompose]{Palatino} +% O´ \quad O¨ \quad O/ \par +% Better: \'O \"O \O % (requires xunicode) +% \end{aatexample} +% The \opt{Hide} option is for Arabic-like fonts which may be +% displayed either with or without vowel markings. +% +% No options for OpenType fonts. +% +% \subsection{Kerning}\label{sec:kerning} +% Well designed fonts contain kerning information that controls the spacing between +% letter pairs, on an individual basis. The \feat{Kerning} feature provides +% options to control this, for OpenType fonts only. +% +% The options provided for now are \opt{On}, \opt{Off} (don't know why you'd want to), and \opt{Uppercase}. +% \begin{opentypeexample} +% \fontspec{Warnock Pro} +% Ta AV \\ +% \fontspec[Kerning=Off]{Warnock Pro} +% Ta AV +% \end{opentypeexample} +% +% As briefly mentioned previously at the end of \vref{sec:letters}, +% the \opt{Uppercase} option will add a small amount of tracking between uppercase letters: +% \begin{opentypeexample} +% \fontspec{Warnock Pro} +% UPPER-CASE EXAMPLE \\ +% \addfontfeature{Kerning=Uppercase} +% UPPER-CASE EXAMPLE +% \end{opentypeexample} +% % \subsection{CJK shape} % There have been many standards for how CJK ideographic % glyphs are `supposed' to look. Some fonts will contain many alternate @@ -1285,7 +1402,9 @@ This work consists of the file fontspec.dtx % by \pkg{fontspec} before all others and will specifically select the \opt{ICU} % renderer for this font, as described in \vref{sec:renderer}. % -% In the following examples, the same font is used to typeset the +% \subsubsection{\feat{Script} examples} +% +%In the following examples, the same font is used to typeset the % verbatim input and the \XeTeX\ output. Because the \opt{Script} is % only specified for the output, the text is rendered incorrectly in % the verbatim input. Many examples of incorrect diacritic spacing as @@ -1329,19 +1448,30 @@ This work consists of the file fontspec.dtx % \end{opentypeexample} % \endgroup % -% And an example of the differences caused by the Vietnamese \feat{Language} feature: (thanks, JK) -%\begingroup -%\setmonofont[Scale=MatchLowercase]{Monaco} +% \subsubsection{\feat{Language} examples} +% +% Vietnamese requires careful diacritic placement: +% \begingroup +% \setmonofont[Scale=MatchLowercase]{Monaco} +% \setexsize\Large % \begin{opentypeexample} -% \def\viet{cung cấp một con số -% duy nhất cho mỗi ký tự} % \fontspec{Doulos SIL} -% \viet\\ -% \fontspec[Language=Vietnamese]{Doulos SIL} -% \viet +% cấp số mỗi \\ +% \addfontfeature{Language=Vietnamese} +% cấp số mỗi +% \end{opentypeexample} +% \noindent Moldavian, as a typical example from Ralf Stubner's FPL Neu font: +% \setexsize\Large +% \begin{opentypeexample} +% \fontspec{FPL Neu} +% Ş ş Ţ ţ \\ +% \addfontfeature{Language=Moldavian} +% Ş ş Ţ ţ % \end{opentypeexample} %\endgroup % +% \subsubsection{Defining new scripts and languages} +% % \DescribeMacro{\newfontscript} % \DescribeMacro{\newfontlanguage} % Further scripts and languages may be added with the \cmd\newfontscript\ @@ -1376,7 +1506,7 @@ This work consists of the file fontspec.dtx % \hrule % \begin{multicols}{6} % \everypar{\setlength\parindent{0pt}\setlength\hangindent{2em}} -% \sffamily\footnotesize\raggedright +% \fontspec{Optima}\footnotesize\raggedright % Abaza \par Abkhazian \par Adyghe \par Afrikaans \par Afar \par Agaw \par Altai \par Amharic \par Arabic \par Aari \par Arakanese \par Assamese \par Athapaskan \par Avar \par Awadhi \par Aymara \par Azeri \par Badaga \par Baghelkhandi \par Balkar \par Baule \par Berber \par Bench \par Bible Cree \par Belarussian \par Bemba \par Bengali \par Bulgarian \par Bhili \par Bhojpuri \par Bikol \par Bilen \par Blackfoot \par Balochi \par Balante \par Balti \par Bambara \par Bamileke \par Breton \par Brahui \par Braj Bhasha \par Burmese \par Bashkir \par Beti \par Catalan \par Cebuano \par Chechen \par Chaha Gurage \par Chattisgarhi \par Chichewa \par Chukchi \par Chipewyan \par Cherokee \par Chuvash \par Comorian \par Coptic \par Cree \par Carrier \par Crimean Tatar \par Church Slavonic \par Czech \par Danish \par Dargwa \par Woods Cree \par German \par Default \par Dogri \par Divehi \par Djerma \par Dangme \par Dinka \par Dungan \par Dzongkha \par Ebira \par Eastern Cree \par Edo \par Efik \par Greek \par English \par Erzya \par Spanish \par Estonian \par Basque \par Evenki \par Even \par Ewe \par French Antillean \par Farsi \par Finnish \par Fijian \par Flemish \par Forest Nenets \par Fon \par Faroese \par French \par Frisian \par Friulian \par Futa \par Fulani \par Ga \par Gaelic \par Gagauz \par Galician \par Garshuni \par Garhwali \par Ge'ez \par Gilyak \par Gumuz \par Gondi \par Greenlandic \par Garo \par Guarani \par Gujarati \par Haitian \par Halam \par Harauti \par Hausa \par Hawaiin \par Hammer-Banna \par Hiligaynon \par Hindi \par High Mari \par Hindko \par Ho \par Harari \par Croatian \par Hungarian \par Armenian \par Igbo \par Ijo \par Ilokano \par Indonesian \par Ingush \par Inuktitut \par Irish \par Irish Traditional \par Icelandic \par Inari Sami \par Italian \par Hebrew \par Javanese \par Yiddish \par Japanese \par Judezmo \par Jula \par Kabardian \par Kachchi \par Kalenjin \par Kannada \par Karachay \par Georgian \par Kazakh \par Kebena \par Khutsuri Georgian \par Khakass \par Khanty-Kazim \par Khmer \par Khanty-Shurishkar \par Khanty-Vakhi \par Khowar \par Kikuyu \par Kirghiz \par Kisii \par Kokni \par Kalmyk \par Kamba \par Kumaoni \par Komo \par Komso \par Kanuri \par Kodagu \par Korean Old Hangul \par Konkani \par Kikongo \par Komi-Permyak \par Korean \par Komi-Zyrian \par Kpelle \par Krio \par Karakalpak \par Karelian \par Karaim \par Karen \par Koorete \par Kashmiri \par Khasi \par Kildin Sami \par Kui \par Kulvi \par Kumyk \par Kurdish \par Kurukh \par Kuy \par Koryak \par Ladin \par Lahuli \par Lak \par Lambani \par Lao \par Latin \par Laz \par L-Cree \par Ladakhi \par Lezgi \par Lingala \par Low Mari \par Limbu \par Lomwe \par Lower Sorbian \par Lule Sami \par Lithuanian \par Luba \par Luganda \par Luhya \par Luo \par Latvian \par Majang \par Makua \par Malayalam Traditional \par Mansi \par Marathi \par Marwari \par Mbundu \par Manchu \par Moose Cree \par Mende \par Me'en \par Mizo \par Macedonian \par Male \par Malagasy \par Malinke \par Malayalam Reformed \par Malay \par Mandinka \par Mongolian \par Manipuri \par Maninka \par Manx Gaelic \par Moksha \par Moldavian \par Mon \par Moroccan \par Maori \par Maithili \par Maltese \par Mundari \par Naga-Assamese \par Nanai \par Naskapi \par N-Cree \par Ndebele \par Ndonga \par Nepali \par Newari \par Nagari \par Norway House Cree \par Nisi \par Niuean \par Nkole \par N'ko \par Dutch \par Nogai \par Norwegian \par Northern Sami \par Northern Tai \par Esperanto \par Nynorsk \par Oji-Cree \par Ojibway \par Oriya \par Oromo \par Ossetian \par Palestinian Aramaic \par Pali \par Punjabi \par Palpa \par Pashto \par Polytonic Greek \par Pilipino \par Palaung \par Polish \par Provencal \par Portuguese \par Chin \par Rajasthani \par R-Cree \par Russian Buriat \par Riang \par Rhaeto-Romanic \par Romanian \par Romany \par Rusyn \par Ruanda \par Russian \par Sadri \par Sanskrit \par Santali \par Sayisi \par Sekota \par Selkup \par Sango \par Shan \par Sibe \par Sidamo \par Silte Gurage \par Skolt Sami \par Slovak \par Slavey \par Slovenian \par Somali \par Samoan \par Sena \par Sindhi \par Sinhalese \par Soninke \par Sodo Gurage \par Sotho \par Albanian \par Serbian \par Saraiki \par Serer \par South Slavey \par Southern Sami \par Suri \par Svan \par Swedish \par Swadaya Aramaic \par Swahili \par Swazi \par Sutu \par Syriac \par Tabasaran \par Tajiki \par Tamil \par Tatar \par TH-Cree \par Telugu \par Tongan \par Tigre \par Tigrinya \par Thai \par Tahitian \par Tibetan \par Turkmen \par Temne \par Tswana \par Tundra Nenets \par Tonga \par Todo \par Turkish \par Tsonga \par Turoyo Aramaic \par Tulu \par Tuvin \par Twi \par Udmurt \par Ukrainian \par Urdu \par Upper Sorbian \par Uyghur \par Uzbek \par Venda \par Vietnamese \par Wa \par Wagdi \par West-Cree \par Welsh \par Wolof \par Tai Lue \par Xhosa \par Yakut \par Yoruba \par Y-Cree \par Yi Classic \par Yi Modern \par Chinese Hong Kong \par Chinese Phonetic \par Chinese Simplified \par Chinese Traditional \par Zande \par Zulu % \end{multicols} % \hspace{4pt} @@ -1410,10 +1540,18 @@ This work consists of the file fontspec.dtx % \DescribeMacro{\newICUfeature} % New OpenType features may be created with this command:\par % {\centering\cmd\newICUfeature\marg{feature}\marg{option}\marg{feature tag}\par} +% In the following example, the Moldavian language (see \vref{sec:ot}) must be activated to achieve the effect shown. +% \setexsize\Large +% \begingroup +% \setmonofont[Scale=MatchLowercase]{Monaco} % \begin{opentypeexample} -% \newICUfeature{Example}{NoKern}{-kern} -% \fontspec[Example=NoKern]{Warnock Pro} Ta AVA +% \newICUfeature{Style}{NoLocalForms}{-locl} +% \fontspec[Language=Moldavian]{FPL Neu} +% Ş ş Ţ ţ \\ +% \addfontfeature{Style=NoLocalForms} +% Ş ş Ţ ţ % \end{opentypeexample} +% \endgroup % % \DescribeMacro{\newfontfeature} % In case the above commands do not accommodate the desired font feature @@ -1462,7 +1600,7 @@ This work consists of the file fontspec.dtx % \aliasfontfeature{VerticalPosition}{Vert Pos} % \aliasfontfeatureoption{VerticalPosition}{ScientificInferior}{Sci Inf} % \fontspec[Vert Pos=Sci Inf]{Warnock Pro} -% Scientific~Inferior: 12345 +% Scientific Inferior: 12345 % \end{opentypeexample} % This example demonstrates an important point: when aliasing the feature % options, the \emph{original} feature name must be used when declaring @@ -1477,6 +1615,20 @@ This work consists of the file fontspec.dtx % \newfontfeature{PurpleColour}{color=550099BB} % \end{Verbatim} % +% \subsection{Going behind \pkg{fontspec}'s back} +% Expert users may wish not to use \pkg{fontspec}'s feature handling at all, +% while still taking advantage of its \LaTeX\ font selection conveniences. The +% \feat{RawFeature} \new{v1.13} font feature allows literal \XeTeX\ font feature selection +% when you happen to have the OpenType feature tag memorised. +% \begin{example} +% \fontspec[RawFeature=+smcp]{FPL Neu} +% FPL Neu small caps +% \end{example} +% Multiple features can either be included in a single declaration:\par +% {\centering|[RawFeature=+smcp;+onum]|\par} +% \noindent or with multiple declarations:\par +% {\centering|[RawFeature=+smcp, RawFeature=+onum]|\par} +% % \StopEventually{} % % \clearpage @@ -1493,33 +1645,45 @@ This work consists of the file fontspec.dtx % For some reason, I decided to prefix all the package internal % command names and variables with |zf|. I don't know why I chose % those letters, but I guess I just liked the look/feel of them -% together at the time. +% together at the time. (Possibly inspired by Hermann \emph{Z}ap\emph{f}.) % % \iffalse %<*fontspec> % \fi % Only proceed if it is \XeTeX\ that is doing the typesetting. % \begin{macrocode} -\unless\ifdefined\XeTeXversion - \@latex@error{^^J - *************************************************^^J - *** Sorry! ^^J - *** The fontspec package only works with XeTeX. ^^J - *************************************************} -\fi +\RequirePackage{ifxetex} +\RequireXeTeX % \end{macrocode} % \subsection{Bits and pieces} -% Counters, conditionals, \dots +% \paragraph{Conditionals} % \begin{macrocode} \newif\ifzf@firsttime +\newif\ifzf@nobf +\newif\ifzf@noit +\newif\ifzf@nosc \newif\ifzf@tfm \newif\ifzf@atsui -\newif\ifzf@icu +\newif\ifzf@icu \newif\ifzf@mm +% \end{macrocode} +% For dealing with legacy maths +% \begin{macrocode} \newif\ifzf@math@euler \newif\ifzf@math@lucida -\newif\ifzf@euler@package@loaded +\newif\ifzf@package@euler@loaded +% \end{macrocode} +% For, well, dealing with \pkg{babel}: +% \begin{macrocode} \newif\ifzf@package@babel@loaded +% \end{macrocode} +% For package options: +% \begin{macrocode} +\newif\if@zf@configfile +\newif\if@zf@euenc +% \end{macrocode} +% \paragraph{Counters} +% \begin{macrocode} \newcount\c@zf@newff \newcount\c@zf@index \newcount\c@zf@script @@ -1531,6 +1695,40 @@ This work consists of the file fontspec.dtx \newcommand\zf@PackageWarning[1]{\PackageWarning{fontspec}{#1}} \newcommand\zf@PackageInfo[1]{\PackageInfo{fontspec}{#1}} % \end{macrocode} +% +% \begin{macro}{\def@cx} +% \begin{macro}{\gdef@cx} +% \begin{macro}{\let@cc} +% \LaTeX3--like syntax for various low level commands. +% Makes life much easier; can't wait for the official interface |:)| +% \begin{macrocode} +\providecommand\def@cx[2]{\expandafter\edef\csname#1\endcsname{#2}} +\providecommand\gdef@cx[2]{\expandafter\xdef\csname#1\endcsname{#2}} +\providecommand\let@cc[2]{% + \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{Option processing} +% +% \begin{macrocode} +\DeclareOption{cm-default}{\@zf@euencfalse} +\DeclareOption{lm-default}{\@zf@euenctrue} +\DeclareOption{config}{\@zf@configfiletrue} +\DeclareOption{noconfig}{\@zf@configfilefalse} +\DeclareOption{quiet}{\let\zf@PackageWarning\zf@PackageInfo} +\ExecuteOptions{config,lm-default} +\ProcessOptions* +% \end{macrocode} +% \changes{v1.12}{2006/10/24}{Package option for disabling the EU1 encoding.} +% Only proceed if it is \XeTeX\ that is doing the typesetting. +% \begin{macrocode} +\RequirePackage{ifxetex} +\RequireXeTeX +% \end{macrocode} +% % \subsection{Packages} % We require the \pkg{calc} package for autoscaling and a recent version of the % \pkg{xkeyval} package for option processing. @@ -1542,34 +1740,44 @@ This work consists of the file fontspec.dtx % by this package!} % % \subsection{Encodings} -% While the business of encoding names is up in the air, I'll continue -% to use the |U| encoding. +% Frank Mittelbach has recommended using the `\texttt{EU}$x$' family of font encodings +% to experiment with unicode. +% Now that \XeTeX\ can find fonts in the |texmf| tree, the Latin Modern OpenType fonts +% can be used as the defaults. See the |euenc| collection of files for how this is implemented. % \begin{macrocode} -\def\zf@enc{U} -%\RequirePackage[\zf@enc]{fontenc} -\renewcommand\encodingdefault{\zf@enc} +\if@zf@euenc + \def\zf@enc{EU1} + \RequirePackage{lmodern} + \RequirePackage[\zf@enc]{fontenc} +\else + \def\zf@enc{U} + \let\encodingdefault\zf@enc +\fi +\let\UTFencname\zf@enc % \end{macrocode} -% Dealing with \pkg{babel}: +% \changes{v1.12}{2006/08/21}{Finally, use the \texttt{EU1} font encoding.} +% Dealing with a couple of the problems introduced by \pkg{babel}: % \begin{macrocode} -\def\cyrillicencoding{U}% -\def\latinencoding{U}% +\let\cyrillicencoding\zf@enc +\let\latinencoding\zf@enc \g@addto@macro\document{% - \def\cyrillicencoding{U}% - \def\latinencoding{U}} + \let\cyrillicencoding\zf@enc + \let\latinencoding\zf@enc} % \end{macrocode} % That latin encoding definition is repeated to suppress font warnings. % Something to do with \cmd\select@language\ ending up in the \texttt{.aux} % file which is read at the beginning of the document. +% % \changes{v1.10}{2006/05/04}{Some \pkg{babel} encoding problems resolved.} -% \subsection{User commands}\label{sec:codeuser} % % +% +% \subsection{User commands}\label{sec:codeuser} % This section contains the definitions of the commands detailed in % the user documentation. Only the `top level' definitions of the % commands are contained herein; they all use or define macros which % are defined or used later on in \vref{sec:codeinternal}. % -% % \subsubsection{Font selection} % \begin{macro}{\fontspec} % This is the main command of the package that @@ -1589,22 +1797,21 @@ This work consists of the file fontspec.dtx % \changes{v1.9}{2005/12/14}{Added \cs{ignorespaces} to make it invisible.} % \end{macro} % -% -% -% \begin{macro}{\setromanfont} +% \begin{macro}{\setmainfont} % \begin{macro}{\setsansfont} % \begin{macro}{\setmonofont} % The following three macros perform equivalent operations setting % the default font (using \cs{let} rather than \cs{renewcommand} % because \cs{zf@family} will change in the future) for a -% particular family: roman, sans serif, or typewriter +% particular family: `roman', sans serif, or typewriter % (monospaced). I end them with |\normalfont| so that if they're % used in the document, the change registers immediately. % \begin{macrocode} -\newcommand*\setromanfont[2][]{% +\newcommand*\setmainfont[2][]{% \zf@fontspec{#1}{#2}% \let\rmdefault\zf@family \normalfont} +\let\setromanfont\setmainfont \newcommand*\setsansfont[2][]{% \zf@fontspec{#1}{#2}% \let\sfdefault\zf@family @@ -1646,7 +1853,7 @@ This work consists of the file fontspec.dtx \@onlypreamble\setmathsf \@onlypreamble\setmathtt % \end{macrocode} -% If the commands above are not executed, then \cmd\rmdefault\ (etc.) +% If the commands above are not executed, then \cmd\rmdefault\ (\etc) % will be used. % \begin{macrocode} \def\zf@rmmaths{\rmdefault} @@ -1657,7 +1864,8 @@ This work consists of the file fontspec.dtx % \changes{v1.8}{2005/07/04}{Implemented (with friends).} % \end{macro} % -% \begin{macro}{\newfontinstance} +% \begin{macro}{\newfontfamily} +% \begin{macro}{\newfontface} % This macro takes the arguments of \cs{fontspec} with a prepended % \meta{instance cmd} (code for middle optional argument generated % by \name{Scott Pakin}'s \textsf{newcommand.py}). This command is used @@ -1667,18 +1875,34 @@ This work consists of the file fontspec.dtx % option arguments every time. % % \cs{zf@fontspec} defines a font family and saves its name in -% \cs{zf@family}. So then this value is expanded in a temporary -% macro also containing the \emph{unexpanded} commands to later -% select the font family to which it refers. Finally, the requested -% name for the font instance is \cs{let}ed from the temporary macro. -% \begin{macrocode} -\newcommand*\newfontinstance[1]{% - \@ifnextchar[{\newfontinstance@i#1}{\newfontinstance@i#1[]}} -\def\newfontinstance@i#1[#2]#3{% +% \cs{zf@family}. This family is then used in a typical NFSS \cmd\fontfamily\ +% declaration, saved in the macro name specified. +% \begin{macrocode} +\newcommand*\newfontfamily[1]{% + \@ifnextchar[{\newfontfamily@i#1}{\newfontfamily@i#1[]}} +\def\newfontfamily@i#1[#2]#3{% \zf@fontspec{#2}{#3}% - \edef#1{\noexpand\fontfamily{\zf@family}\noexpand\selectfont}} + \edef\@tempa{% + \noexpand\DeclareRobustCommand\noexpand#1 + {\noexpand\fontfamily{\zf@family}\noexpand\selectfont}}% + \@tempa} +% \end{macrocode} +% \cmd\newfontface\ uses an undocumented feature of the \feat{BoldFont} +% feature; if its argument is empty (\ie, |BoldFont={}|), then no bold +% font is searched for. +% \begin{macrocode} +\newcommand*\newfontface[1]{% + \@ifnextchar[{\newfontface@i#1}{\newfontface@i#1[]}} +\def\newfontface@i#1[#2]#3{% + \zf@fontspec{BoldFont={},ItalicFont={},SmallCapsFont={},#2}{#3}% + \edef\@tempa{% + \noexpand\DeclareRobustCommand\noexpand#1 + {\noexpand\fontfamily{\zf@family}\noexpand\selectfont}}% + \@tempa} % \end{macrocode} % \changes{v1.6}{2005/01/02}{Implemented.} +% \changes{v1.11}{2006/08/01}{Name change from \cmd\newfontfamily.} +% \end{macro} % \end{macro} % % \subsubsection{Font feature selection} @@ -1711,8 +1935,9 @@ This work consists of the file fontspec.dtx % font features to add to the already existing ones, and calls the % font again with the top level \cs{fontspec} command. % -% The default options are \emph{not} applied (which is why they're -% saved and restored with \cs{zf@default@options@old}), so this +% The default options are \emph{not} applied (which is why +% \cs{zf@default@options} is emptied inside the group; this is allowed +% as \cmd\zf@family\ is globally defined in \cmd\zf@fontspec), so this % means that the only added features to the font are strictly those % specified by this command. % @@ -1720,16 +1945,15 @@ This work consists of the file fontspec.dtx % often typed this instead when adding only a single font feature. % \begin{macrocode} \newcommand*\addfontfeatures[1]{% - \let\zf@default@options@old\zf@default@options - \let\zf@default@options\@empty - \edef\zf@thisinfo{}% - \edef\@tempa{% - \noexpand\zf@fontspec - {\csname zf@family@options\f@family\endcsname,#1}% - {\csname zf@family@fontname\f@family\endcsname}}% - \@tempa + \begingroup + \let\zf@default@options\@empty + \edef\@tempa{% + \noexpand\zf@fontspec + {\csname zf@family@options\f@family\endcsname,#1}% + {\csname zf@family@fontname\f@family\endcsname}}% + \@tempa + \endgroup \fontfamily\zf@family\selectfont - \let\zf@default@options\zf@default@options@old \ignorespaces} \let\addfontfeature\addfontfeatures % \end{macrocode} @@ -1739,6 +1963,7 @@ This work consists of the file fontspec.dtx % \changes{v1.9}{2005/12/14}{Changed \cs{fontspec} call to \cs{@fontspec} so that \cs{ignorespaces} isn't called unnecessarily.} % \changes{v1.9}{2005/12/15}{Removed space in \texttt{, \#1}; can't believe I made this mistake again!} % \changes{v1.10}{2006/04/14}{Saved family information macro changes.} +% \changes{v1.12}{2006/10/31}{Now use grouping to restore \cmd\zf@default@option\ change.} % \end{macro} % % @@ -1803,25 +2028,30 @@ This work consists of the file fontspec.dtx % % % \begin{macro}{\aliasfontfeature} -% \changes{v1.9}{2005/12/09}{Implemented.} % \begin{macro}{\aliasfontfeatureoption} -% \changes{v1.9}{2005/12/09}{Implemented.} % User commands for renaming font features and font feature options. % Provided I've been consistent, they should work for everything. % \begin{macrocode} \newcommand*\aliasfontfeature[2]{\multi@alias@key{#1}{#2}} \newcommand*\aliasfontfeatureoption[3]{\keyval@alias@key[zf@feat]{#1}{#2}{#3}} % \end{macrocode} +% \changes{v1.9}{2005/12/09}{Implemented.} % \end{macro} +% \changes{v1.9}{2005/12/09}{Implemented.} % \end{macro} % % \begin{macro}{\newfontscript} +% Mostly used internally, but also possibly useful for users, to define new OpenType +% `scripts', mapping logical names to OpenType script tags. +% Iterates though the scripts in the selected font to check that it's a valid +% feature choice, and then prepends the (\XeTeX) \cmd\font\ feature string with the appropriate +% script selection tag. % \begin{macrocode} \newcommand*\newfontscript[2]{% \define@key[zf@feat]{Script}{#1}[]{% \zf@check@ot@script{#2}% \if@tempswa - \c@zf@script\@tempcnta\relax + \global\c@zf@script\@tempcnta\relax \xdef\zf@script@name{#1}% \xdef\zf@family@long{\zf@family@long+script=#1}% \xdef\zf@pre@ff{script=#2,\zf@pre@ff}% @@ -1830,15 +2060,21 @@ This work consists of the file fontspec.dtx \fi}} % \end{macrocode} % \changes{v1.9}{2006/02/12}{Implemented.} +% \changes{v1.11}{2006/08/12}{Fixed \cmd\c@zf@script\ setting not being global.} % \end{macro} % % \begin{macro}{\newfontlanguage} +% Mostly used internally, but also possibly useful for users, to define new OpenType +% `languages', mapping logical names to OpenType language tags. +% Iterates though the languages in the selected font to check that it's a valid +% feature choice, and then prepends the (\XeTeX) \cmd\font\ feature string with the appropriate +% language selection tag. % \begin{macrocode} \newcommand*\newfontlanguage[2]{% \define@key[zf@feat]{Lang}{#1}[]{% \zf@check@ot@lang{#2}% \if@tempswa - \c@zf@language\@tempcnta\relax + \global\c@zf@language\@tempcnta\relax \xdef\zf@language@name{#1}% \xdef\zf@family@long{\zf@family@long+lang=#1}% \xdef\zf@pre@ff{\zf@pre@ff language=#2,}% @@ -1847,30 +2083,63 @@ This work consists of the file fontspec.dtx language '#1' for script '\zf@script@name'}% \fi}} % \end{macrocode} +% \changes{v1.9}{2006/02/12}{Implemented.} +% \changes{v1.11}{2006/08/12}{Fixed \cmd\c@zf@language\ setting not being global.} % \end{macro} % % \subsection{Internal macros}\label{sec:codeinternal} % -% \begin{macro}{\def@cx} -% \begin{macro}{\gdef@cx} -% Natural counterparts to \cmd\@namedef. -% \begin{macrocode} -\providecommand\def@cx[2]{\expandafter\edef\csname#1\endcsname{#2}} -\providecommand\gdef@cx[2]{\expandafter\xdef\csname#1\endcsname{#2}} -\providecommand\let@cc[2]{\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname} -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\zf@fontspec} -% This is the command that defines font families for use. Given a -% list of font features for a requested font (|#2|, stored +% This is the command that defines font families for use, the underlying +% procedure of all \cmd\fontspec-like commands. Given a +% list of font features (|#1|) for a requested font (|#2|, stored % in \cs{zf@fontname} globally for the % \cs{zf@make@aat@feature@string} macro), it will define an NFSS % family for that font and put the family name into \cs{zf@family}. % -% Then we check with \cs{zf@set@font@type} whether the font is AAT -% or OpenType, and convert the requested features to font definition +% This macro does its processing inside a group, but it's a bit worthless coz +% there's all sorts of \cmd\global\ action going on. Pity. Anyway, lots of things +% are branched out for the pure reason of splitting +% the code up into logical chunks. Some of it is never even re-used, so it +% all might be a bit obfuscating. (\Eg, \cmd\zf@init\ and \cmd\zf@set@font@type.) +% +% First off, initialise some bits and pieces and run the |preparse| feature +% processing. This catches font features such as |Renderer| that can change +% the way subsequent features are processed. All font features that `slip through' +% this stage are saved in the \cmd\zf@font@feat\ macro for future processing. +% \begin{macrocode} +\newcommand*\zf@fontspec[2]{% + \begingroup + \zf@init + \edef\zf@fontname{#2}% + \let\zf@family@long\zf@fontname + \setkeys*[zf]{prepreparse}{#1}% + \edef\@tempa{\noexpand\setkeys*[zf]{preparse}{\XKV@rm}}\@tempa + \let\zf@font@feat\XKV@rm +% \end{macrocode} +% Now check if the font is to be rendered with ATSUI or ICU. This will either +% be automatic (based on the font type), or specified by the user via a font feature. +% If automatic, the \cmd\zf@suffix\ macro will still be empty (other suffices that could +% be added will be later in the feature processing), and if it is indeed still empty, +% assign it a value so that the other weights of the font are specifically loaded with the +% same renderer. This fixes a bug in v1.10 for a mishmash of Lucida fonts. +% \begin{macrocode} + \font\zf@basefont="\zf@font@wrap\zf@fontname\zf@suffix" at \f@size pt + \unless\ifzf@icu + \zf@set@font@type + \fi + \ifx\zf@suffix\@empty + \ifzf@atsui + \def\zf@suffix{/AAT}% + \else + \ifzf@icu + \def\zf@suffix{/ICU}% + \fi + \fi + \font\zf@basefont="\zf@font@wrap\zf@fontname\zf@suffix" at \f@size pt + \fi +% \end{macrocode} +% Now convert the remaining requested features to font definition % strings. This is performed with \cs{zf@get@feature@requests}, in % which \cs{setkeys} retrieves the requested font features and % processes them. To build up the complex family name, it @@ -1882,25 +2151,7 @@ This work consists of the file fontspec.dtx % % In the future, this will be replaced by a dedicated \texttt{makefamily} % \pkg{xkeyval} \cmd\setkeys\ declaration. Probably. -% -% This macro does its processing inside a group, but it's a bit worthless coz -% there's all sorts of \cmd\global\ action going on. Pity. -% -% Finally, lots of things are branched out for the pure reason of splitting -% the code up into logical chunks. Some of it is never even re-used, so it -% all might be a bit worthless. (\Eg, \cmd\zf@init\ and \cmd\zf@set@font@type.) -% \begin{macrocode} -\newcommand*\zf@fontspec[2]{% - \begingroup - \zf@init - \edef\zf@fontname{#2}% - \let\zf@family@long\zf@fontname - \setkeys*[zf]{preparse}{#1}% - \edef\zf@font@feat{\zf@font@feat\XKV@rm}% - \unless\ifdefined\zf@basefont - \font\zf@basefont="\zf@fontname\zf@suffix" at \f@size pt - \fi - \zf@set@font@type +% \begin{macrocode} \zf@firsttimetrue \zf@get@feature@requests{\zf@font@feat}% \zf@firsttimefalse @@ -1911,7 +2162,7 @@ This work consists of the file fontspec.dtx % selecting. % \begin{macrocode} \unless\ifcsname zf@UID@\zf@family@long\endcsname - \ifcsname c@zf@famc@#2\endcsname + \ifcsname c@zf@famc@#2\endcsname \expandafter\stepcounter\else \expandafter\newcounter\fi {zf@famc@#2}% @@ -1929,11 +2180,12 @@ This work consists of the file fontspec.dtx % \cs{addfontfeatures}. % \begin{macrocode} \unless\ifcsname zf@family@fontname\zf@family\endcsname - \zf@PackageInfo{Defining font family for "#2" + \zf@PackageInfo{Defining font family for "#2" with options [\zf@default@options #1]}% \gdef@cx{zf@family@fontname\zf@family}{\zf@fontname}% \gdef@cx{zf@family@options\zf@family}{\zf@default@options #1}% - \gdef@cx{zf@family@fontdef\zf@family}{\zf@fontname\zf@suffix:\zf@pre@ff\zf@ff}% + \gdef@cx{zf@family@fontdef\zf@family} + {\zf@fontname\zf@suffix:\zf@pre@ff\zf@ff}% % \end{macrocode} % Next the font family and its shapes are defined in the NFSS. % @@ -1946,31 +2198,41 @@ This work consists of the file fontspec.dtx % custom bold, et al., font, if requested as user options. If they are % empty, the default fonts are used. % -% First we define the font family and define the normal shape: (the -% specified options are used implicitly) +% First we define the font family and define the normal shape: (any shape-specific +% features are appended to the generic font features requested in the last argument +% of \cmd\zf@make@font@shapes.) % \begin{macrocode} \DeclareFontFamily{\zf@enc}{\zf@family}{}% - \zf@make@font@shapes{\zf@fontname}{\mddefault}{\updefault}{\zf@font@feat\zf@up@feat}% + \zf@make@font@shapes{\zf@fontname} + {\mddefault}{\updefault}{\zf@font@feat\zf@up@feat}% % \end{macrocode} -% Secondly, bold. Start out by saving the current font features and -% appending to them, if any, the extra bold options defined with -% \feat{BoldFeatures}. Then, the bold font is defined either as the ATS +% Secondly, bold. Again, the extra bold options defined with +% \feat{BoldFeatures} are appended to the generic font features. +% Then, the bold font is defined either as the ATS % default (\cs{zf@make@font@shapes}' optional argument is to check if % there actually is one; if not, the bold NFSS series is left % undefined) or with the font specified with the \feat{BoldFont} feature. % \begin{macrocode} - \ifx\zf@bf\@empty - \zf@make@font@shapes[\zf@fontname]{/B}{\bfdefault}{\updefault}{\zf@font@feat\zf@bf@feat}% - \else - \zf@make@font@shapes{\zf@bf}{\bfdefault}{\updefault}{\zf@font@feat\zf@bf@feat}% + \unless\ifzf@nobf + \ifx\zf@bf\@empty + \zf@make@font@shapes[\zf@fontname]{/B} + {\bfdefault}{\updefault}{\zf@font@feat\zf@bf@feat}% + \else + \zf@make@font@shapes{\zf@bf} + {\bfdefault}{\updefault}{\zf@font@feat\zf@bf@feat}% + \fi \fi % \end{macrocode} % And italic in the same way: % \begin{macrocode} - \ifx\zf@it\@empty - \zf@make@font@shapes[\zf@fontname]{/I}{\mddefault}{\itdefault}{\zf@font@feat\zf@it@feat}% - \else - \zf@make@font@shapes{\zf@it}{\mddefault}{\itdefault}{\zf@font@feat\zf@it@feat}% + \unless\ifzf@noit + \ifx\zf@it\@empty + \zf@make@font@shapes[\zf@fontname]{/I} + {\mddefault}{\itdefault}{\zf@font@feat\zf@it@feat}% + \else + \zf@make@font@shapes{\zf@it} + {\mddefault}{\itdefault}{\zf@font@feat\zf@it@feat}% + \fi \fi % \end{macrocode} % If requested, the custom fonts take precedence when choosing the @@ -1979,22 +2241,30 @@ This work consists of the file fontspec.dtx % occurance, presumably), the new bold font is used to define the new % bold italic font. % \begin{macrocode} - \ifx\zf@bfit\@empty - \ifx\zf@bf\@empty - \ifx\zf@it\@empty - \zf@make@font@shapes[\zf@fontname]{/BI}{\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% + \@tempswatrue + \ifzf@nobf\@tempswafalse\fi + \ifzf@noit\@tempswafalse\fi + \if@tempswa + \ifx\zf@bfit\@empty + \ifx\zf@bf\@empty + \ifx\zf@it\@empty + \zf@make@font@shapes[\zf@fontname]{/BI} + {\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% + \else + \zf@make@font@shapes[\zf@it]{/B} + {\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% + \fi \else - \zf@make@font@shapes[\zf@it]{/B}{\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% + \zf@make@font@shapes[\zf@bf]{/I} + {\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% \fi \else - \zf@make@font@shapes[\zf@bf]{/I}{\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% + \zf@make@font@shapes{\zf@bfit} + {\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% \fi - \else - \zf@make@font@shapes{\zf@bfit}{\bfdefault}{\itdefault}{\zf@font@feat\zf@bfit@feat}% \fi \fi - \endgroup - } + \endgroup} % \end{macrocode} % \changes{v1.5}{2004/11/29}{NFSS specifiers now take the default values.} % \changes{v1.5}{2004/11/29}{Added code for choosing arbitrary bold/italic fonts.} @@ -2010,6 +2280,7 @@ This work consists of the file fontspec.dtx % \changes{v1.10}{2006/04/14}{Saved family info split into two (now three!) macros.} % \changes{v1.10}{2006/05/03}{Space zapped from \LaTeX\ family name due to various problems.} % \end{macro} +% \changes{v1.11}{2006/06/29}{Ensure bold/italic fonts are loaded with the same renderer as the regular font even if unspecified.} % % % \subsubsection{Fonts} @@ -2043,12 +2314,14 @@ This work consists of the file fontspec.dtx % % % \begin{macro}{\zf@make@font@shapes} -% This macro uses \cs{DeclareFontShape} to define the font shape in -% question. The arguments are: -% \begin{itemize}\itemsep0pt\parsep0pt -% \item |#1#2|~the font name, \item |#3|~the font series, -% \item |#4|~the font shape, and \item |#5|~the font features. -% \end{itemize} +% \doarg{Font name prefix} +% \darg{Font name} +% \darg{Font series} +% \darg{Font shape} +% \darg{Font features} +% This macro eventually uses \cs{DeclareFontShape} to define the font shape in +% question. +% % The optional first % argument is used when making the font shapes for bold, italic, and % bold italic fonts using \XeTeX's auto-recognition with |#2| as |/B|, |/I|, @@ -2057,13 +2330,13 @@ This work consists of the file fontspec.dtx % proceed and the font shape is not created for the NFSS. % \begin{macrocode} \newcommand*\zf@make@font@shapes[5][]{% - \bgroup + \begingroup \edef\@tempa{#1}% - \ifx\@tempa\@empty\else - \font\@tempfonta="#1\zf@suffix" at \f@size pt + \unless\ifx\@tempa\@empty + \font\@tempfonta="\zf@font@wrap{#1}\zf@suffix" at \f@size pt \edef\@tempa{\fontname\@tempfonta}% \fi - \font\@tempfontb="#1#2\zf@suffix" at \f@size pt + \font\@tempfontb="\zf@font@wrap{#1#2}\zf@suffix" at \f@size pt \edef\@tempb{\fontname\@tempfontb}% \ifx\@tempa\@tempb \zf@PackageInfo{Could not resolve font #1#2 (it might not exist)}% @@ -2081,10 +2354,12 @@ This work consists of the file fontspec.dtx % for the code that enables this usage. % \begin{macrocode} \ifx\zf@sc\@empty - \zf@make@smallcaps - \ifx\zf@smallcaps\@empty\else - \zf@DeclareFontShape[\zf@smallcaps]{#3} - {\ifx#4\itdefault\sidefault\else\scdefault\fi}{#5\zf@sc@feat}% + \unless\ifzf@nosc + \zf@make@smallcaps + \unless\ifx\zf@smallcaps\@empty + \zf@DeclareFontShape[\zf@smallcaps]{#3} + {\ifx#4\itdefault\sidefault\else\scdefault\fi}{#5\zf@sc@feat}% + \fi \fi \else \edef\zf@fontname{\zf@sc}% @@ -2092,7 +2367,7 @@ This work consists of the file fontspec.dtx {\ifx#4\itdefault\sidefault\else\scdefault\fi}{#5\zf@sc@feat}% \fi \fi - \egroup} + \endgroup} % \end{macrocode} % Note that the test for italics to choose the \cmd\sidefault\ shape % only works while \cmd\zf@fontspec\ passes single tokens to this macro\dots @@ -2111,34 +2386,69 @@ This work consists of the file fontspec.dtx % \cmd\DeclareFontShape\ argument directly now that it's fully expanded.} % \changes{v1.9}{2005/12/11}{Added code for \feat{SmallCaps...} features.} % \changes{v1.9}{2005/12/20}{Made local to hide \cs{zf@fontname} changes.} +% \changes{v1.12}{2006/10/28}{\cmd\bgroup\ changed to \cmd\begingroup. Thanks Chris!} % \end{macro} % % \begin{macro}{\zf@DeclareFontShape} -% Wrapper for \cmd\DeclareFontShape. Among omitting common arguments, it also -% fully expands its input upon execution. This is mostly (or only?) useful -% for the contents of \cmd\zf@adjust. -% -% The extra stuff for the slanted shape substitution is a little bit awkward, -% but I'd rather have it here than break out yet another macro. +% \doarg{Raw appended font feature} +% \darg{Font series} +% \darg{Font shape} +% \darg{Font features} +% Wrapper for \cmd\DeclareFontShape. % \begin{macrocode} \newcommand\zf@DeclareFontShape[4][]{% - \zf@get@feature@requests{#4}% - \def\@tempb{"\zf@fontname\zf@suffix:\zf@pre@ff\zf@ff#1"}% - \zf@PackageInfo{\string\font\space is \@tempb}% + \ifx\zf@size@feat\@empty + \zf@get@feature@requests{#4}% + \edef\zf@font@str{<->\zf@scale"\zf@font@wrap\zf@fontname\zf@suffix:% + \zf@pre@ff\zf@ff#1"}% + \else +% \end{macrocode} +% Default code, above, sets things up for no optical size fonts or features. +% On the other hand, loop through \feat{SizeFeatures} arguments, which +% are of the form +% +% {\centering |SizeFeatures={{<one>},{<two>},{<three>}}|.\par} +% \begin{macrocode} + \@for\zf@this@size:=\zf@size@feat\do{% + \let\zf@size\@empty + \let\zf@size@fnt\zf@fontname + \edef\@tempa{\noexpand + \setkeys*[zf]{sizing}{\expandafter\@firstofone\zf@this@size}}% + \@tempa + \ifx\zf@size\@empty\zf@PackageError + {Size information must be supplied} + {For example, SizeFeatures={Size={8-12},...},...}% + \fi + \zf@get@feature@requests{#4,\XKV@rm}% + \edef\zf@font@str{\zf@font@str <\zf@size>% + \zf@scale"\zf@size@fnt\zf@suffix:\zf@pre@ff\zf@ff#1"}}% + \fi +% \end{macrocode} +% And finally the actual font shape declaration using \cmd\zf@font@str\ defined above. +% \cmd\zf@adjust\ is defined in various places to deal with things like the hyphenation +% character and interword spacing. +% \begin{macrocode} \edef\@tempa{\noexpand - \DeclareFontShape{\zf@enc}{\zf@family}{#2}{#3} - {<->\zf@scale\@tempb}{\zf@adjust}}% + \DeclareFontShape{\zf@enc}{\zf@family}{#2}{#3}% + {\zf@font@str}{\zf@adjust}}% \@tempa - \edef\@tempa{#3}\edef\@tempb{\itdefault}% +% \end{macrocode} +% This extra stuff for the slanted shape substitution is a little bit awkward, +% but I'd rather have it here than break out yet another macro. Alternatively, +% one day I might just redefine \cmd\slshape. Why not, eh? +% \begin{macrocode} + \edef\@tempa{#3}% + \edef\@tempb{\itdefault}% \ifx\@tempa\@tempb \edef\@tempa{\noexpand - \DeclareFontShape{\zf@enc}{\zf@family}{#2}{\sldefault} + \DeclareFontShape{\zf@enc}{\zf@family}{#1}{\sldefault} {<->sub*\zf@family/#2/\itdefault}{\zf@adjust}}% - \@tempa + \@tempa \fi} % \end{macrocode} % \changes{v1.9}{2005/12/11}{Implemented as wrapper for \cmd\DeclareFontShape.} % \changes{v1.9}{2006/01/15}{Slanted/italic shape substitution implemented.} +% \changes{v1.13}{2006/11/12}{New feature \feat{SizeFeatures} implemented.} % \end{macro} % % @@ -2188,8 +2498,11 @@ This work consists of the file fontspec.dtx % because it's no longer the first thing that can affect these things. % \begin{macrocode} \newcommand*\zf@init{% + \zf@icufalse \let\zf@pre@ff \@empty \let\zf@font@feat \@empty + \let\zf@font@str \@empty + \let\zf@font@wrap \@firstofone \let\zf@suffix \@empty \let\zf@bf \@empty \let\zf@it \@empty @@ -2200,6 +2513,9 @@ This work consists of the file fontspec.dtx \let\zf@it@feat \@empty \let\zf@bfit@feat \@empty \let\zf@sc@feat \@empty + \let\zf@size\@empty + \let\zf@size@feat\@empty + \let\zf@size@fnt\@empty \c@zf@script 1818326126\relax \def\zf@script@name{Latin}% \c@zf@language 0\relax @@ -2209,7 +2525,7 @@ This work consists of the file fontspec.dtx % \changes{v1.9}{2005/12/20}{Taken from \cs{zf@get@feature@requests}.} % \end{macro} % -% \begin{macro}{\zf@make@smallcaps} +% \begin{macro}{\zf@make@smallcaps}\label{mac:zf@make@smallcaps} % This macro checks if the font contains small caps, and if so % creates the string for accessing them in \cmd{\zf@smallcaps}. % \begin{macrocode} @@ -2217,8 +2533,8 @@ This work consists of the file fontspec.dtx \let\zf@smallcaps\@empty \ifzf@atsui \zf@make@aat@feature@string{3}{3}% - \unless\ifx\zf@thisfontfeature\@empty - \edef\zf@smallcaps{\zf@thisfontfeature;}% + \unless\ifx\@tempa\@empty + \edef\zf@smallcaps{\@tempa;}% \fi \fi \ifzf@icu @@ -2256,33 +2572,54 @@ This work consists of the file fontspec.dtx % according to which type of font is selected. % \begin{macrocode} \newcommand*\zf@make@feature[3]{% +% \end{macrocode} +% For AAT fonts: +% \begin{macrocode} \ifzf@atsui - \zf@make@aat@feature@string{#1}{#2}% - \ifx\zf@thisfontfeature\@empty + \def\@tempa{#1}% + \ifx\@tempa\@empty \zf@PackageWarning{% - AAT feature '\XKV@tfam=\XKV@tkey' - (#1,#2) not available in font \fontname\zf@basefont}% + ‘\XKV@tfam=\XKV@tkey’ feature not supported + for AAT font ‘\fontname\zf@basefont’}% \else - \zf@update@family{+#1,#2}% - \zf@update@ff\zf@thisfontfeature + \zf@make@aat@feature@string{#1}{#2}% + \ifx\@tempa\@empty + \zf@PackageWarning{% + AAT feature '\XKV@tfam=\XKV@tkey' + (#1,#2) not available in font \fontname\zf@basefont}% + \else + \zf@update@family{+#1,#2}% + \zf@update@ff\@tempa + \fi \fi \fi +% \end{macrocode} +% For OpenType fonts: +% \begin{macrocode} \ifzf@icu - \zf@check@ot@feat{#3}% - \if@tempswa - \zf@update@family{#3}% - \zf@update@ff{#3}% - \else + \edef\@tempa{#3}% + \ifx\@tempa\@empty \zf@PackageWarning{% - OpenType feature '\XKV@tfam=\XKV@tkey' (#3) - not available in font \fontname\zf@basefont, script - '\zf@script@name', language '\zf@language@name'}% + ‘\XKV@tfam=\XKV@tkey’ feature not supported + for ICU font ‘ \fontname\zf@basefont’}% + \else + \expandafter\zf@check@ot@feat\expandafter{\@tempa}% + \if@tempswa + \zf@update@family{#3}% + \zf@update@ff{#3}% + \else + \zf@PackageWarning{% + OpenType feature '\XKV@tfam=\XKV@tkey' (#3) + not available in font \fontname\zf@basefont, script + '\zf@script@name', language '\zf@language@name'}% + \fi \fi \fi} % \end{macrocode} % \changes{v1.7}{2005/03/27}{Accommodation of the \cs{zf@thisfontfeature} change.} % \changes{v1.9}{2006/02/12}{Now checks for OpenType feature.} % \changes{v1.10}{2006/04/04}{Removed embarrassing space after warnings.} +% \changes{v1.13}{2006/12/24}{Warns (and fixes bug) when an AAT feature is requested for an ICU font and vice versa.} % \end{macro} % % \begin{macro}{\zf@define@font@feature} @@ -2327,34 +2664,55 @@ This work consists of the file fontspec.dtx % This macro takes the numerical codes for a font feature and % creates a specified macro containing the string required in the % font definition to turn that feature on or off. Used primarily in -% |\zf@make@aat@feature|, but also used to check if small caps -% exists in the requested font. +% \cmd\zf@make@aat@feature, but also used to check if small caps +% exists in the requested font (see page~\pageref{mac:zf@make@smallcaps}). +% % \begin{macrocode} \newcommand*\zf@make@aat@feature@string[2]{% - \edef\zf@this@featurename{\XeTeXfeaturename\zf@basefont #1}% - \ifx\zf@this@featurename\@empty - \let\zf@thisfontfeature\@empty - \else - \edef\zf@this@selectionname{\XeTeXselectorname\zf@basefont #1 #2}% - \ifx\zf@this@selectionname\@empty - \let\zf@thisfontfeature\@empty + \edef\@tempa{\XeTeXfeaturename\zf@basefont #1}% + \unless\ifx\@tempa\@empty +% \end{macrocode} +% For exclusive selectors, it's easy; just grab the string: +% \begin{macrocode} + \ifnum\XeTeXisexclusivefeature\zf@basefont #1 > 0 + \edef\@tempb{\XeTeXselectorname\zf@basefont #1 #2}% +% \end{macrocode} +% For \emph{non}-exclusive selectors, it's a little more complex. +% If the selector is even, it corresponds to switching the feature on: +% \begin{macrocode} \else - \edef\zf@thisfontfeature{% - \ifnum\XeTeXisexclusivefeature\zf@basefont #1 > 0 - \zf@this@featurename=\zf@this@selectionname - \else - \ifodd #2 - \zf@this@featurename=!\zf@this@selectionname - \else - \zf@this@featurename=\zf@this@selectionname - \fi - \fi}% + \unless\ifodd #2 + \edef\@tempb{\XeTeXselectorname\zf@basefont #1 #2}% +% \end{macrocode} +% If the selector is \emph{odd}, it corresponds to switching the feature off. +% But \XeTeX\ doesn't return a selector string for this number, since the +% feature is defined for the `switching on' value. So we need to check the +% selector of the previous number, and then prefix the feature string with |!| +% to denote the switch. +% \begin{macrocode} + \else + \edef\@tempb{\XeTeXselectorname\zf@basefont #1 \numexpr#2-1\relax}% + \unless\ifx\@tempb\@empty + \edef\@tempb{!\@tempb}% + \fi + \fi +% \end{macrocode} +% Finally, save out the complete feature string in \cmd\@tempa. +% If the selector doesn't exist, re-initialise the feature string to empty. +% \begin{macrocode} + \fi + \unless\ifx\@tempb\@empty + \edef\@tempa{\@tempa=\@tempb}% + \else + \let\@tempa\@empty \fi \fi} % \end{macrocode} % \changes{v1.7}{2005/03/22}{Changed some \cs{edef}s to \cs{let}} % \changes{v1.7}{2005/03/27}{Removed third argument; always saves % the feature string in \cs{zf@thisfontfeature}} +% \changes{v1.12}{2006/08/19}{Fixed result of \cmd\XeTeXfeaturename\ output change (empty string if odd non-exclusive selector).} +% \changes{v1.12}{2006/08/20}{Removed \cmd\@thisfontfeature\ macro; replaced with \cmd\@tempa.} % \end{macro} % % \begin{macro}{\zf@iv@strnum} @@ -2473,12 +2831,58 @@ This work consists of the file fontspec.dtx % This is the tedious section where we correlate all possible % (eventually) font feature requests with their \XeTeX\ representations. % +% \subsubsection{Pre-parsed features} +% +% These features are extracted from the font feature list before all others, using +% \pkg{xkeyval}'s \cmd\setkeys|*|. +% +% \paragraph{\feat{ExternalLocation}} +% For fonts that aren't installed in the system. If no argument is given, the font is located +% with |kpsewhich|; it's either in the current directory or the \TeX\ tree. Otherwise, the +% argument given defines the file path of the font. +% \begin{macrocode} +\define@key[zf]{prepreparse}{ExternalLocation}[]{% + \zf@icutrue + \zf@nobftrue\zf@noittrue + \gdef\zf@font@wrap##1{[#1##1]}} +% \end{macrocode} +% \changes{v1.12}{2006/11/02}{New feature \feat{ExternalLocation} for loading external fonts.} +% +% \paragraph{\feat{Renderer}} +% This feature must be processed before all others (the other font shape and features options are also pre-parsed for convenience) because the renderer determines the format of the features and even whether certain features are available. +% \begin{macrocode} +\define@choicekey[zf]{preparse}{Renderer}{AAT,ICU}{% + \edef\zf@suffix{\zf@suffix/#1}% + \font\zf@basefont="\zf@font@wrap\zf@fontname\zf@suffix" at \f@size pt + \edef\zf@family@long{\zf@family@long +rend:#1}} +% \end{macrocode} +% +% \paragraph{OpenType script/language} +% See later for the resolutions from \pkg{fontspec} features to OpenType definitions. +% \begin{macrocode} +\define@key[zf]{preparse}{Script}{% + \zf@icutrue + \edef\zf@suffix{\zf@suffix/ICU}% + \font\zf@basefont="\zf@font@wrap\zf@fontname\zf@suffix" at \f@size pt + \edef\zf@family@long{\zf@family@long +script:#1}% + {\setkeys[zf@feat]{Script}{#1}}} +% \end{macrocode} +% Exactly the same: +% \begin{macrocode} +\define@key[zf]{preparse}{Language}{% + \zf@icutrue + \edef\zf@suffix{\zf@suffix/ICU}% + \font\zf@basefont="\zf@font@wrap\zf@fontname\zf@suffix" at \f@size pt + \edef\zf@family@long{\zf@family@long +language:#1}% + {\setkeys[zf@feat]{Lang}{#1}}} +% \end{macrocode} +% % \subsubsection{Bold/italic choosing options} % -% The \opt{Bold}, \opt{Italic}, and \opt{BoldItalic} +% The \feat{Bold}, \feat{Italic}, and \feat{BoldItalic} % features are for defining explicitly the bold and italic fonts used % in a font family. \textsf{v1.6} introduced arbitrary font features -% for these shapes (\opt{BoldFeatures}, etc.), so the names of the +% for these shapes (\feat{BoldFeatures}, etc.), so the names of the % shape-selecting options were appended with \opt{Font} for % consistency. % @@ -2486,44 +2890,74 @@ This work consists of the file fontspec.dtx % \changes{v1.6}{2005/02/09}{\opt{Bold} option aliased to \opt{BoldFont}.} % \changes{v1.9}{2005/12/11}{New feature \feat{UprightFeatures}.} % \changes{v1.9}{2005/12/11}{New features \feat{SmallCapsFont} and \feat{SmallCapsFeatures}.} +% \changes{v1.12}{2006/11/02}{\feat{BoldFont}, etc., flags \cmd\zf@nobf\ conditional false rather than assuming it implicitly. This allows, \eg, empty \feat{BoldFont} to be overloaded.} % % \paragraph{Fonts} +% Bold: % \begin{macrocode} \define@key[zf]{preparse}{BoldFont}{% - \zf@partial@fontname#1\@nil - \let\zf@bf\@tempa - \edef\zf@family@long{\zf@family@long bf:#1}} + \edef\@tempa{#1}% + \ifx\@tempa\@empty + \zf@nobftrue + \edef\zf@family@long{\zf@family@long nobf}% + \else + \zf@nobffalse + \zf@partial@fontname#1\@nil=\zf@bf + \edef\zf@family@long{\zf@family@long bf:#1}% + \fi} +% \end{macrocode} +% Same for italic: +% \begin{macrocode} \define@key[zf]{preparse}{ItalicFont}{% - \zf@partial@fontname#1\@nil - \let\zf@it\@tempa - \edef\zf@family@long{\zf@family@long it:#1}} + \edef\@tempa{#1}% + \ifx\@tempa\@empty + \zf@noittrue + \edef\zf@family@long{\zf@family@long noit}% + \else + \zf@noitfalse + \zf@partial@fontname#1\@nil=\zf@it + \edef\zf@family@long{\zf@family@long it:#1}% + \fi} +% \end{macrocode} +% Simpler for bold+italic: +% \begin{macrocode} \define@key[zf]{preparse}{BoldItalicFont}{% - \zf@partial@fontname#1\@nil - \let\zf@bfit\@tempa + \zf@partial@fontname#1\@nil=\zf@bfit \edef\zf@family@long{\zf@family@long bfit:#1}} +% \end{macrocode} +% Small caps isn't pre-parsed because it can vary with others above: +% \begin{macrocode} \define@key[zf]{options}{SmallCapsFont}{% - \zf@partial@fontname#1\@nil - \let\zf@sc\@tempa - \zf@update@family{sc:\zap@space #1 \@empty}} + \edef\@tempa{#1}% + \ifx\@tempa\@empty + \zf@nosctrue + \edef\zf@family@long{\zf@family@long nosc}% + \else + \zf@noscfalse + \zf@partial@fontname#1\@nil=\zf@sc + \zf@update@family{sc:\zap@space #1 \@empty}% + \fi} % \end{macrocode} % % \begin{macro}{\zf@partial@fontname} -% This macro takes the next token and ends up defining \cmd\@tempa\ +% This macro takes the first token of its input and ends up defining |#3| % to the name of the font depending if it's been specified in full % (``\texttt{Baskerville Semibold}'') or in abbreviation (``\texttt{* Semibold}''). +% +% This could be done more flexibly by making |*| active; I'll change it later if I need to. % \begin{macrocode} -\def\zf@partial@fontname#1#2\@nil{% +\def\zf@partial@fontname#1#2\@nil=#3{% \if#1*\relax - \edef\@tempa{\zf@fontname#2}% + \edef#3{\zf@fontname#2}% \else - \edef\@tempa{#1#2}% + \edef#3{#1#2}% \fi} % \end{macrocode} % \changes{v1.9}{2006/02/03}{Implemented.} +% \changes{v1.13}{2006/12/20}{Folded in the \cmd\@tempa\ \cmd\let\ command, changing the syntax.} % \end{macro} % % \paragraph{Features} -% Note that small caps features can vary by shape, so these in fact \emph{aren't} pre-parsed. % \begin{macrocode} \define@key[zf]{preparse}{UprightFeatures}{% \def\zf@up@feat{,#1}% @@ -2537,37 +2971,29 @@ This work consists of the file fontspec.dtx \define@key[zf]{preparse}{BoldItalicFeatures}{% \def\zf@bfit@feat{,#1}% \edef\zf@family@long{\zf@family@long bfitfeat:#1}} +% \end{macrocode} +% Note that small caps features can vary by shape, so these in fact \emph{aren't} pre-parsed. +% \begin{macrocode} \define@key[zf]{options}{SmallCapsFeatures}{% \unless\ifzf@firsttime\def\zf@sc@feat{,#1}\fi \zf@update@family{scfeat:\zap@space #1 \@empty}} % \end{macrocode} % -% \subsubsection{The \feat{Renderer} pre-parsed feature} -% This feature must be processed before all others (the other font shape and features options are also pre-parsed for convenience) because the renderer determines the format of the features and even whether certain features are available. -% \begin{macrocode} -\define@choicekey[zf]{preparse}{Renderer}{AAT,ICU}{% - \edef\zf@suffix{\zf@suffix/#1}% - \font\zf@basefont="\zf@fontname\zf@suffix" at \f@size pt - \edef\zf@family@long{\zf@family@long +rend:#1}} -% \end{macrocode} -% -% \paragraph{OpenType script/language} -% See later for the resolutions from \pkg{fontspec} features to OpenType definitions. +% paragraph{Features varying by size} % \begin{macrocode} -\define@key[zf]{preparse}{Script}{% - \edef\zf@suffix{\zf@suffix/ICU}% - \font\zf@basefont="\zf@fontname\zf@suffix" at \f@size pt - \edef\zf@family@long{\zf@family@long +script:#1} - {\setkeys[zf@feat]{Script}{#1}}} +\define@key[zf]{preparse}{SizeFeatures}{% + \unless\ifzf@firsttime + \def\zf@size@feat{#1}% + \fi + \zf@update@family{sizefeat:\zap@space #1 \@empty}} % \end{macrocode} -% Exactly the same: +% % \begin{macrocode} -\define@key[zf]{preparse}{Language}{% - \edef\zf@suffix{\zf@suffix/ICU}% - \font\zf@basefont="\zf@fontname\zf@suffix" at \f@size pt - \edef\zf@family@long{\zf@family@long +language:#1} - {\setkeys[zf@feat]{Lang}{#1}}} +\define@key[zf]{sizing}{Size}{\def\zf@size{#1}} +\define@key[zf]{sizing}{Font}{\def\zf@size@fnt{#1}} % \end{macrocode} +% \changes{v1.13}{2006/11/12}{\feat{SizeFeatures}: Beginnings of support for different font features for different font sizes, required by \pkg{unimath}.} +% % % \subsubsection{Font-independent features} % @@ -2615,7 +3041,7 @@ This work consists of the file fontspec.dtx \setlength\@tempdima{\fontdimen#1\font}% \setlength\@tempdimb{\fontdimen#1\zf@basefont}% \setlength\@tempdimc{1pt*\ratio{\@tempdima}{\@tempdimb}}% - \xdef\zf@scale{\strip@pt\@tempdimc} + \xdef\zf@scale{\strip@pt\@tempdimc}% \zf@PackageInfo{\zf@fontname\space scale = \zf@scale}% \endgroup} % \end{macrocode} @@ -2642,18 +3068,21 @@ This work consists of the file fontspec.dtx \def\zf@wordspace@parse#1,#2,#3,#4\zf@@{% \def\@tempa{#4}% \ifx\@tempa\@empty - \g@addto@macro\zf@adjust{% - \fontdimen2\font#1\fontdimen2\font - \fontdimen3\font#1\fontdimen3\font - \fontdimen4\font#1\fontdimen4\font}% + \setlength\@tempdima{#1\fontdimen2\zf@basefont}% + \@tempdimb\@tempdima + \@tempdimc\@tempdima \else - \g@addto@macro\zf@adjust{% - \fontdimen2\font#1\fontdimen2\font - \fontdimen3\font#2\fontdimen3\font - \fontdimen4\font#3\fontdimen4\font}% - \fi} + \setlength\@tempdima{#1\fontdimen2\zf@basefont}% + \setlength\@tempdimb{#2\fontdimen3\zf@basefont}% + \setlength\@tempdimc{#3\fontdimen4\zf@basefont}% + \fi + \edef\zf@adjust{\zf@adjust + \fontdimen2\font\the\@tempdima + \fontdimen3\font\the\@tempdimb + \fontdimen4\font\the\@tempdimc}} % \end{macrocode} % \changes{v1.9}{2005/12/12}{Implemented.} +% \changes{v1.11}{2006/08/13}{Improved saving \cmd\fontdimen\ stuff to \cmd\zd@adjust (also see \feat{PunctuationSpace}).} % \end{macro} % % \paragraph{Punctuation space} @@ -2662,12 +3091,12 @@ This work consists of the file fontspec.dtx % \begin{macrocode} \define@key[zf]{options}{PunctuationSpace}{% \zf@update@family{+punctspace:#1}% - \g@addto@macro\zf@adjust{% - \fontdimen7\font#1\fontdimen7\font}} + \setlength\@tempdima{#1\fontdimen7\zf@basefont}% + \edef\zf@adjust{\zf@adjust\fontdimen7\font\the\@tempdima}} % \end{macrocode} % % \paragraph{Letterspacing} -% \changes{v1.10}{2006/06/07}{New feature \feat{LetterSpacing}.} +% \changes{v1.10}{2006/06/07}{New feature \feat{LetterSpace}.} % \begin{macrocode} \define@key[zf]{options}{LetterSpace}{% \zf@update@family{+tracking:#1}% @@ -2676,6 +3105,7 @@ This work consists of the file fontspec.dtx % % \paragraph{Hyphenation character} % \changes{v1.9}{2005/12/11}{New feature \feat{HyphenChar}.} +% \changes{v1.11}{2006/08/14}{\feat{HyphenChar} checks its input now.} % This feature takes one of three arguments: `\opt{None}', % \meta{glyph}, or \meta{slot}. If the input isn't the first, % and it's one character, then it's the second; otherwise, it's @@ -2690,13 +3120,25 @@ This work consists of the file fontspec.dtx \else \zf@check@one@char#1\zf@@ \ifx\@tempb\@empty - \g@addto@macro\zf@adjust{% - {\expandafter\hyphenchar\expandafter - \font\expandafter`#1}}% + {\zf@basefont\expandafter\ifnum\expandafter\XeTeXcharglyph\expandafter`#1 > 0 + \g@addto@macro\zf@adjust{% + {\expandafter\hyphenchar\expandafter + \font\expandafter`#1}}% + \else + \zf@PackageError + {\fontname\zf@basefont\space doesn't appear to have the glyph corresponding to #1.} + {You can't hyphenate with a character that's not available!} + \fi} \else - \g@addto@macro\zf@adjust{\hyphenchar\font#1\relax} + {\zf@basefont\ifnum\XeTeXcharglyph#1 > 0 + \g@addto@macro\zf@adjust{\hyphenchar\font#1\relax}% + \else + \zf@PackageError + {\fontname\zf@basefont\space doesn't appear to have the glyph corresponding to #1.} + {You can't hyphenate with a character that's not available!} + \fi} \fi - \fi} + \fi} \def\zf@check@one@char#1#2\zf@@{\def\@tempb{#2}} % \end{macrocode} % @@ -2737,17 +3179,17 @@ This work consists of the file fontspec.dtx \define@key[zf]{options}{OpticalSize}{% \ifzf@icu \edef\zf@suffix{\zf@suffix/S=#1}% - \zf@update@family{+size:#1} + \zf@update@family{+size:#1}% \fi \ifzf@mm \zf@update@family{+size:#1}% - \zf@update@ff{optical size=#1} + \zf@update@ff{optical size=#1}% \fi \ifzf@icu\else \ifzf@mm\else \ifzf@firsttime \zf@PackageWarning - {\fontname\zf@basefont\space doesn't appear to have an Optical Size axis} + {\fontname\zf@basefont\space doesn't appear to have an Optical Size axis}% \fi \fi \fi} @@ -2799,15 +3241,15 @@ This work consists of the file fontspec.dtx % to facilitate option normalisation (to come). Similarly for \opt{PETITECAPS}.} % \begin{macrocode} \zf@define@font@feature{Letters} -\zf@define@feature@option{Letters}{Normal}{3}{0}{} -\zf@define@feature@option{Letters}{Uppercase}{3}{1}{+case} -\zf@define@feature@option{Letters}{Lowercase}{3}{2}{} -\zf@define@feature@option{Letters}{SmallCaps}{3}{3}{+smcp} -\zf@define@feature@option{Letters}{PetiteCaps}{}{}{+pcap} -\zf@define@feature@option{Letters}{UppercaseSmallCaps}{}{}{+c2sc} -\zf@define@feature@option{Letters}{UppercasePetiteCaps}{}{}{+c2pc} -\zf@define@feature@option{Letters}{InitialCaps}{3}{4}{} -\zf@define@feature@option{Letters}{Unicase}{}{}{+unic} +\zf@define@feature@option{Letters}{Normal} {3}{0}{} +\zf@define@feature@option{Letters}{Uppercase} {3}{1}{+case} +\zf@define@feature@option{Letters}{Lowercase} {3}{2}{} +\zf@define@feature@option{Letters}{SmallCaps} {3}{3}{+smcp} +\zf@define@feature@option{Letters}{PetiteCaps} {} {} {+pcap} +\zf@define@feature@option{Letters}{UppercaseSmallCaps} {} {} {+c2sc} +\zf@define@feature@option{Letters}{UppercasePetiteCaps}{} {} {+c2pc} +\zf@define@feature@option{Letters}{InitialCaps} {3}{4}{} +\zf@define@feature@option{Letters}{Unicase} {} {} {+unic} % \end{macrocode} % % \subsubsection{Numbers} @@ -2821,39 +3263,39 @@ This work consists of the file fontspec.dtx % \changes{v1.7}{2005/04/18}{AAT \feat{Numbers}:\opt{SlashedZero}.} % \begin{macrocode} \zf@define@font@feature{Numbers} -\zf@define@feature@option{Numbers}{Monospaced}{6}{0}{+tnum} -\zf@define@feature@option{Numbers}{Proportional}{6}{1}{+pnum} -\zf@define@feature@option{Numbers}{Lowercase}{21}{0}{+onum} -\zf@define@feature@option{Numbers}{OldStyle}{21}{0}{+onum} -\zf@define@feature@option{Numbers}{Uppercase}{21}{1}{+lnum} -\zf@define@feature@option{Numbers}{Lining}{21}{1}{+lnum} -\zf@define@feature@option{Numbers}{SlashedZero}{14}{5}{+zero} +\zf@define@feature@option{Numbers}{Monospaced} {6} {0}{+tnum} +\zf@define@feature@option{Numbers}{Proportional} {6} {1}{+pnum} +\zf@define@feature@option{Numbers}{Lowercase} {21}{0}{+onum} +\zf@define@feature@option{Numbers}{OldStyle} {21}{0}{+onum} +\zf@define@feature@option{Numbers}{Uppercase} {21}{1}{+lnum} +\zf@define@feature@option{Numbers}{Lining} {21}{1}{+lnum} +\zf@define@feature@option{Numbers}{SlashedZero} {14}{5}{+zero} \zf@define@feature@option{Numbers}{NoSlashedZero}{14}{4}{-zero} % \end{macrocode} % % \subsubsection{Contextuals} % \changes{v1.9}{2005/12/21}{\feat{Swashes} feature changed to \feat{Contextuals}. Option of this feature \opt{Contextual} changed to \opt{Swash}, for obvious reasons.} % \begin{macrocode} -\zf@define@font@feature{Contextuals} -\zf@define@feature@option{Contextuals}{Swash}{}{}{+cswh} -\zf@define@feature@option{Contextuals}{NoSwash}{}{}{-cswh} -\zf@define@feature@option{Contextuals}{WordInitial}{8}{0}{+init} +\zf@define@font@feature {Contextuals} +\zf@define@feature@option{Contextuals}{Swash} {} {} {+cswh} +\zf@define@feature@option{Contextuals}{NoSwash} {} {} {-cswh} +\zf@define@feature@option{Contextuals}{WordInitial} {8}{0}{+init} \zf@define@feature@option{Contextuals}{NoWordInitial}{8}{1}{-init} -\zf@define@feature@option{Contextuals}{WordFinal}{8}{2}{+fina} -\zf@define@feature@option{Contextuals}{NoWordFinal}{8}{3}{-fina} -\zf@define@feature@option{Contextuals}{LineInitial}{8}{4}{} +\zf@define@feature@option{Contextuals}{WordFinal} {8}{2}{+fina} +\zf@define@feature@option{Contextuals}{NoWordFinal} {8}{3}{-fina} +\zf@define@feature@option{Contextuals}{LineInitial} {8}{4}{} \zf@define@feature@option{Contextuals}{NoLineInitial}{8}{5}{} -\zf@define@feature@option{Contextuals}{LineFinal}{8}{6}{+falt} -\zf@define@feature@option{Contextuals}{NoLineFinal}{8}{7}{-falt} -\zf@define@feature@option{Contextuals}{Inner}{8}{8}{+medi} -\zf@define@feature@option{Contextuals}{NoInner}{8}{9}{-medi} +\zf@define@feature@option{Contextuals}{LineFinal} {8}{6}{+falt} +\zf@define@feature@option{Contextuals}{NoLineFinal} {8}{7}{-falt} +\zf@define@feature@option{Contextuals}{Inner} {8}{8}{+medi} +\zf@define@feature@option{Contextuals}{NoInner} {8}{9}{-medi} % \end{macrocode} % % \subsubsection{Diacritics} % \begin{macrocode} \zf@define@font@feature{Diacritics} -\zf@define@feature@option{Diacritics}{Show}{9}{0}{} -\zf@define@feature@option{Diacritics}{Hide}{9}{1}{} +\zf@define@feature@option{Diacritics}{Show} {9}{0}{} +\zf@define@feature@option{Diacritics}{Hide} {9}{1}{} \zf@define@feature@option{Diacritics}{Decompose}{9}{2}{} % \end{macrocode} % @@ -2862,23 +3304,23 @@ This work consists of the file fontspec.dtx % \begin{macrocode} \zf@define@font@feature{Kerning} \zf@define@feature@option{Kerning}{Uppercase}{}{}{+cpsp} -\zf@define@feature@option{Kerning}{On}{}{}{+kern} -\zf@define@feature@option{Kerning}{Off}{}{}{-kern} +\zf@define@feature@option{Kerning}{On} {}{}{+kern} +\zf@define@feature@option{Kerning}{Off} {}{}{-kern} %\zf@define@feature@option{Kerning}{Vertical}{}{}{+vkrn} %\zf@define@feature@option{Kerning}{VerticalAlternateProportional}{}{}{+vpal} -%\zf@define@feature@option{Kerning}{VerticalAlternateHalfWidth}{}{}{+vhal} +%\zf@define@feature@option{Kerning}{VerticalAlternateHalfWidth} {}{}{+vhal} % \end{macrocode} % % \subsubsection{Vertical position} % \begin{macrocode} \zf@define@font@feature{VerticalPosition} -\zf@define@feature@option{VerticalPosition}{Normal}{10}{0}{} -\zf@define@feature@option{VerticalPosition}{Superior}{10}{1}{+sups} -\zf@define@feature@option{VerticalPosition}{Inferior}{10}{2}{+subs} +\zf@define@feature@option{VerticalPosition}{Normal} {10}{0}{} +\zf@define@feature@option{VerticalPosition}{Superior} {10}{1}{+sups} +\zf@define@feature@option{VerticalPosition}{Inferior} {10}{2}{+subs} +\zf@define@feature@option{VerticalPosition}{Ordinal} {10}{3}{+ordn} +\zf@define@feature@option{VerticalPosition}{Numerator} {} {} {+numr} +\zf@define@feature@option{VerticalPosition}{Denominator}{} {} {+dnom} \zf@define@feature@option{VerticalPosition}{ScientificInferior}{}{}{+sinf} -\zf@define@feature@option{VerticalPosition}{Ordinal}{10}{3}{+ordn} -\zf@define@feature@option{VerticalPosition}{Numerator}{}{}{+numr} -\zf@define@feature@option{VerticalPosition}{Denominator}{}{}{+dnom} % \end{macrocode} % % \subsubsection{Fractions} @@ -2886,24 +3328,26 @@ This work consists of the file fontspec.dtx % \changes{v1.7}{2005/03/25}{OpenType \opt{Alternate} \feat{Fractions} feature.} % \begin{macrocode} \zf@define@font@feature{Fractions} -\zf@define@feature@option{Fractions}{On}{11}{1}{+frac} -\zf@define@feature@option{Fractions}{Off}{11}{0}{-frac} -\zf@define@feature@option{Fractions}{Diagonal}{11}{2}{} -\zf@define@feature@option{Fractions}{Alternate}{}{}{+afrc} +\zf@define@feature@option{Fractions}{On} {11}{1}{+frac} +\zf@define@feature@option{Fractions}{Off} {11}{0}{-frac} +\zf@define@feature@option{Fractions}{Diagonal} {11}{2}{} +\zf@define@feature@option{Fractions}{Alternate}{} {} {+afrc} % \end{macrocode} % % \subsubsection{Alternates and variants} % Selected numerically because they don't have standard names. Very % easy to process, very annoying for the user! % -% \changes{v1.6}{2005/03/05}{OpenType stylistic sets supports under the \opt{Variant} option.} +% \changes{v1.6}{2005/03/05}{OpenType stylistic sets supports under the \feat{Variant} option.} % \changes{v1.7}{2005/03/26}{OpenType \feat{Alternate} now only AAT.} % \changes{v1.9}{2006/02/12}{Alternate/Variant options can be assigned names.} +% \changes{v1.11}{2006/06/17}{OpenType \feat{Variant} fixed.} % % \begin{macrocode} \define@key[zf]{options}{Alternate}{% \setkeys*[zf@feat]{Alternate}{#1}% - \unless\ifx\XKV@rm\@empty + \unless\ifx\XKV@rm\@empty + \def\XKV@tfam{Alternate}% \zf@make@feature{17}{#1}{}% \fi} % \end{macrocode} @@ -2911,42 +3355,43 @@ This work consists of the file fontspec.dtx % \begin{macrocode} \define@key[zf]{options}{Variant}{% \setkeys*[zf@feat]{Variant}{#1}% - \unless\ifx\XKV@rm\@empty + \unless\ifx\XKV@rm\@empty + \def\XKV@tfam{Variant}% \zf@make@feature{18}{#1}{+ss\two@digits{#1}}% \fi} % \end{macrocode} % % \subsubsection{Style} -% \changes{v1.7}{2005/03/26} -% {\feat{Style} feature renamed from \feat{StyleOptions}.} % \begin{macrocode} \zf@define@font@feature{Style} -\zf@define@feature@option{Style}{Alternate}{}{}{+salt} -\zf@define@feature@option{Style}{Italic}{32}{2}{+ital} -\zf@define@feature@option{Style}{Ruby}{28}{2}{+ruby} -\zf@define@feature@option{Style}{Swash}{}{}{+swsh} -\zf@define@feature@option{Style}{Historic}{}{}{+hist} -\zf@define@feature@option{Style}{Display}{19}{1}{} -\zf@define@feature@option{Style}{Engraved}{19}{2}{} -\zf@define@feature@option{Style}{TitlingCaps}{19}{4}{+titl} -\zf@define@feature@option{Style}{TallCaps}{19}{5}{} -\zf@define@feature@option{Style}{HorizontalKana}{}{}{+hkna} -\zf@define@feature@option{Style}{VerticalKana}{}{}{+vkna} +\zf@define@feature@option{Style}{Alternate} {} {} {+salt} +\zf@define@feature@option{Style}{Italic} {32}{2}{+ital} +\zf@define@feature@option{Style}{Ruby} {28}{2}{+ruby} +\zf@define@feature@option{Style}{Swash} {} {} {+swsh} +\zf@define@feature@option{Style}{Historic} {} {} {+hist} +\zf@define@feature@option{Style}{Display} {19}{1}{} +\zf@define@feature@option{Style}{Engraved} {19}{2}{} +\zf@define@feature@option{Style}{TitlingCaps} {19}{4}{+titl} +\zf@define@feature@option{Style}{TallCaps} {19}{5}{} +\zf@define@feature@option{Style}{HorizontalKana}{} {} {+hkna} +\zf@define@feature@option{Style}{VerticalKana} {} {} {+vkna} % \end{macrocode} +% \changes{v1.7}{2005/03/26} +% {\feat{Style} feature renamed from \feat{StyleOptions}.} % % \subsubsection{CJK shape} -% \changes{v1.7}{2005/03/26}{New feature: \feat{CharacterShape}} -% \changes{v1.9}{2006/02/12}{\feat{CharacterShape} now \feat{CJKShape}} % \begin{macrocode} \zf@define@font@feature{CJKShape} -\zf@define@feature@option{CJKShape}{Traditional}{20}{0}{+trad} -\zf@define@feature@option{CJKShape}{Simplified}{20}{1}{+smpl} -\zf@define@feature@option{CJKShape}{JIS1978}{20}{2}{+jp78} -\zf@define@feature@option{CJKShape}{JIS1983}{20}{3}{+jp83} -\zf@define@feature@option{CJKShape}{JIS1990}{20}{4}{+jp90} -\zf@define@feature@option{CJKShape}{Expert}{20}{10}{+expt} -\zf@define@feature@option{CJKShape}{NLC}{20}{13}{+nlck} +\zf@define@feature@option{CJKShape}{Traditional}{20}{0} {+trad} +\zf@define@feature@option{CJKShape}{Simplified} {20}{1} {+smpl} +\zf@define@feature@option{CJKShape}{JIS1978} {20}{2} {+jp78} +\zf@define@feature@option{CJKShape}{JIS1983} {20}{3} {+jp83} +\zf@define@feature@option{CJKShape}{JIS1990} {20}{4} {+jp90} +\zf@define@feature@option{CJKShape}{Expert} {20}{10}{+expt} +\zf@define@feature@option{CJKShape}{NLC} {20}{13}{+nlck} % \end{macrocode} +% \changes{v1.7}{2005/03/26}{New feature: \feat{CharacterShape}} +% \changes{v1.9}{2006/02/12}{\feat{CharacterShape} now \feat{CJKShape}} % % \subsubsection{Character width} % \changes{v1.7}{2005/04/18}{New feature: \feat{CharacterWidth}} @@ -3004,7 +3449,7 @@ This work consists of the file fontspec.dtx \newfontscript{Bopomofo}{bopo} \newfontscript{Braille}{brai} \newfontscript{Buginese}{bugi} \newfontscript{Buhid}{buhd} \newfontscript{Byzantine Music}{byzm} \newfontscript{Canadian Syllabics}{cans} -\newfontscript{Cherokee}{cher} +\newfontscript{Cherokee}{cher} \newfontscript{CJK Ideographic}{hani} \newfontscript{Coptic}{copt} \newfontscript{Cypriot Syllabary}{cprt} \newfontscript{Cyrillic}{cyrl} \newfontscript{Default}{DFLT} \newfontscript{Deseret}{dsrt} @@ -3014,7 +3459,7 @@ This work consists of the file fontspec.dtx \newfontscript{Gujarati}{gujr} \newfontscript{Gurmukhi}{guru} \newfontscript{Hangul Jamo}{jamo} \newfontscript{Hangul}{hang} \newfontscript{Hanunoo}{hano} \newfontscript{Hebrew}{hebr} -\newfontscript{Hiragana and Katakana}{kana} +\newfontscript{Hiragana and Katakana}{kana} \newfontscript{Javanese}{java} \newfontscript{Kannada}{knda} \newfontscript{Kharosthi}{khar} \newfontscript{Khmer}{khmr} \newfontscript{Lao}{lao } \newfontscript{Latin}{latn} @@ -3156,7 +3601,7 @@ This work consists of the file fontspec.dtx \newfontlanguage{Tigre}{TGR} \newfontlanguage{Tigrinya}{TGY} \newfontlanguage{Thai}{THA} \newfontlanguage{Tahitian}{THT} \newfontlanguage{Tibetan}{TIB} \newfontlanguage{Turkmen}{TKM} \newfontlanguage{Temne}{TMN} \newfontlanguage{Tswana}{TNA} \newfontlanguage{Tundra Nenets}{TNE} -\newfontlanguage{Tonga}{TNG} \newfontlanguage{Todo}{TOD} \newfontlanguage{Turkish}{TUR} +\newfontlanguage{Tonga}{TNG} \newfontlanguage{Todo}{TOD} \newfontlanguage{Tsonga}{TSG} \newfontlanguage{Turoyo Aramaic}{TUA} \newfontlanguage{Tulu}{TUL} \newfontlanguage{Tuvin}{TUV} \newfontlanguage{Twi}{TWI} \newfontlanguage{Udmurt}{UDM} \newfontlanguage{Ukrainian}{UKR} \newfontlanguage{Urdu}{URD} \newfontlanguage{Upper Sorbian}{USB} @@ -3170,6 +3615,40 @@ This work consists of the file fontspec.dtx \newfontlanguage{Chinese Traditional}{ZHT} \newfontlanguage{Zande}{ZND} \newfontlanguage{Zulu}{ZUL} % \end{macrocode} % +% \paragraph{Turkish} Turns out that many fonts use `TUR' as their Turkish language tag rather than the specified `TRK'. So we check for both: +% \begin{macrocode} +\define@key[zf@feat]{Lang}{Turkish}[]{% + \zf@check@ot@lang{TRK}% + \if@tempswa + \c@zf@language\@tempcnta\relax + \xdef\zf@language@name{Turkish}% + \xdef\zf@family@long{\zf@family@long+lang=Turkish}% + \xdef\zf@pre@ff{\zf@pre@ff language=TRK,}% + \else + \zf@check@ot@lang{TUR}% + \if@tempswa + \c@zf@language\@tempcnta\relax + \xdef\zf@language@name{Turkish}% + \xdef\zf@family@long{\zf@family@long+lang=Turkish}% + \xdef\zf@pre@ff{\zf@pre@ff language=TUR,}% + \else + \zf@PackageWarning{Font \fontname\zf@basefont does not contain + language '#1' for script '\zf@script@name'}% + \fi + \fi} +% \end{macrocode} +% \changes{v1.11}{2006/07/08}{Added better support for Turkish language selection.} +% +% \subsubsection{Raw feature string} +% This allows savvy \XeTeX-ers to input font features manually if they have +% already memorised the OpenType abbreviations and don't mind not having error checking. +% \begin{macrocode} +\define@key[zf]{options}{RawFeature}{% + \zf@update@family{+Raw:#1}% + \zf@update@ff{#1}} +% \end{macrocode} +% \changes{v1.13}{2006/12/24}{\feat{RawFeature} added} +% % \subsection{Italic small caps} \label{sec:sishape} % The following code for utilising italic small caps sensibly is % inspired from Philip Lehman's \textit{The Font Installation @@ -3203,7 +3682,7 @@ This work consists of the file fontspec.dtx \ifcsname\f@encoding/\f@family/\f@series/#3\endcsname \edef\@tempa{#3}% \fi - \fi + \fi \fontshape{\@tempa}\selectfont} % \end{macrocode} % \end{macro} @@ -3214,12 +3693,12 @@ This work consists of the file fontspec.dtx \DeclareRobustCommand{\itshape}{% \not@math@alphabet\itshape\mathit \zf@merge@shape\itdefault\scdefault\sidefault} -\DeclareRobustCommand{\slshape}{% +\DeclareRobustCommand{\slshape}{% \not@math@alphabet\slshape\relax \zf@merge@shape\sldefault\scdefault\sidefault} \DeclareRobustCommand{\scshape}{% \not@math@alphabet\scshape\relax - \zf@merge@shape\scdefault\itdefault\sidefault} + \zf@merge@shape\scdefault\itdefault\sidefault} \DeclareRobustCommand{\upshape}{% \not@math@alphabet\upshape\relax \zf@merge@shape\updefault\sidefault\scdefault} @@ -3228,24 +3707,9 @@ This work consists of the file fontspec.dtx % % \begin{macro}{\em} % \begin{macro}{\emph} -% It's not 100\% reliable to use the \cmd\fontdimen\ of the italic shapes defined -% by \XeTeX, I think, so copy \cmd\em's definition from \pkg{fixltx2e}. -% \begin{macrocode} -\AtBeginDocument{% - \DeclareRobustCommand\em - {\@nomath\em - \edef\@tempa{\f@shape}% - \edef\@tempb{\itdefault}% - \ifx\@tempa\@tempb - \eminnershape - \else - \emshape - \fi}} -\DeclareTextFontCommand{\emph}{\em} -\let\emshape\itshape -\let\eminnershape\upshape -% \end{macrocode} +% Redefinitions moved to the \pkg{xltxtra} package. % \changes{v1.9}{2005/10/27}{Redefined \cmd\em\ in order for nested emphases to work.} +% \changes{v1.11}{2006/08/12}{Redefinitions moved to \pkg{xltxtra}.} % \end{macro} \end{macro} % % \subsection{Selecting maths fonts} @@ -3281,18 +3745,18 @@ This work consists of the file fontspec.dtx % either. But I'm pretty sure they are. % % \begin{macrocode} -\@ifpackageloaded{euler}{\zf@euler@package@loadedtrue} - {\zf@euler@package@loadedfalse} +\@ifpackageloaded{euler}{\zf@package@euler@loadedtrue} + {\zf@package@euler@loadedfalse} \AtBeginDocument{% \let\zf@font@warning\@font@warning \let\@font@warning\@font@info \@ifpackageloaded{euler}{% - \ifzf@euler@package@loaded + \ifzf@package@euler@loaded \zf@math@eulertrue \else \zf@PackageError{The euler package must be loaded BEFORE fontspec} {fontspec only overwrites euler's attempt to \MessageBreak - define the maths text fonts if fontspec is \MessageBreak + define the maths text fonts if fontspec is \MessageBreak loaded after euler. Type <return> to proceed\MessageBreak with incorrect \protect\mathit, \protect\mathbf, etc} \fi}{} @@ -3324,7 +3788,7 @@ This work consists of the file fontspec.dtx \DeclareMathAccent{\breve} {\mathalpha}{legacymaths}{21} \DeclareMathAccent{\check} {\mathalpha}{legacymaths}{20} \DeclareMathAccent{\hat} {\mathalpha}{legacymaths}{94} % too bad, euler - \DeclareMathAccent{\dot} {\mathalpha}{legacymaths}{95} + \DeclareMathAccent{\dot} {\mathalpha}{legacymaths}{95} \DeclareMathAccent{\mathring}{\mathalpha}{legacymaths}{23} % \end{macrocode} % \paragraph{\cmd\colon: what's going on?} Okay, so \verb":" and \cmd\colon\ in maths mode are defined in a few places, so I need to work out what does what. Respectively, we have: @@ -3426,7 +3890,7 @@ This work consists of the file fontspec.dtx \ifdefined\zf@rmboldmaths \SetMathAlphabet\mathrm{bold}\zf@enc\zf@rmboldmaths\mddefault\updefault \SetMathAlphabet\mathbf{bold}\zf@enc\zf@rmboldmaths\bfdefault\updefault - \SetMathAlphabet\mathit{bold}\zf@enc\zf@rmboldmaths\mddefault\itdefault + \SetMathAlphabet\mathit{bold}\zf@enc\zf@rmboldmaths\mddefault\itdefault \else \SetMathAlphabet\mathrm{bold}\zf@enc\zf@rmmaths\bfdefault\updefault \SetMathAlphabet\mathit{bold}\zf@enc\zf@rmmaths\bfdefault\itdefault @@ -3437,17 +3901,14 @@ This work consists of the file fontspec.dtx % \end{macrocode} % \changes{v1.9}{2006/01/31}{Suppresses harmless maths font encoding warnings.} % \end{macro} -% \subsection{Option processing} +% \subsection{Finishing up} % Now we just want to set up loading the \texttt{.cfg} file, if it exists. % \begin{macrocode} -\DeclareOption{config}{% +\if@zf@configfile \InputIfFileExists{fontspec.cfg} {\typeout{fontspec.cfg loaded.}} - {\typeout{fontspec.cfg would be loaded now if it existed.}}} -\DeclareOption{noconfig}{} -\DeclareOption{quiet}{\let\zf@PackageWarning\zf@PackageInfo} -\ExecuteOptions{config} -\ProcessOptions + {\typeout{No fontspec.cfg file found; no configuration loaded.}} +\fi % \end{macrocode} % \changes{v1.9}{2006/01/31}{Package options \opt{(no)config}, \opt{quiet} implemented.} % The end! Thanks for coming. @@ -3467,6 +3928,8 @@ This work consists of the file fontspec.dtx %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% FOR BACKWARDS COMPATIBILITY WITH PREVIOUS VERSIONS %%% +\let\newfontinstance\newfontfamily + \newcommand\newfeaturecode[3]{% \define@key{zf}{#1}[]{\zf@make@feature{#2}{#3}{}}} @@ -3494,34 +3957,29 @@ This work consists of the file fontspec.dtx %<*example> % \fi % -% \part{fontspec-example.tex} +% \part{fontspec-example.ltx} % % \begin{macrocode} -%!TEX TS-program =xelatex -\documentclass[12pt]{article} +\documentclass{article} -\usepackage{euler,fontspec,graphicx} +\usepackage{euler} +\usepackage[cm-default]{fontspec} +\usepackage{xltxtra} -\defaultfontfeatures{Scale=MatchLowercase ,Mapping=tex-text} -\setromanfont{Hoefler Text} -\setsansfont{Gill Sans} +\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text} +\setromanfont[Numbers=Lowercase]{FPL Neu} +\setsansfont{Lucida Sans} \setmonofont{Lucida Sans Typewriter} -%% Define the \XeTeX logo: -\DeclareRobustCommand\XeTeX{% - \mbox{\smash{% - X\lower.5ex\hbox{\kern-.12em\reflectbox{E}}\kern-.1667em - T\kern -.1667em\lower .5ex\hbox {E}\kern -.12em X}}\@} -%% The logo should be defined on a per-document basis -%% so that its parameters may be fine tuned for the fonts used. +\frenchspacing % TeX's default is a little old-fashioned... \begin{document} \pagestyle{empty} -\section{The basics of the \textsf{fontspec} package} +\section*{The basics of the \textsf{fontspec} package} The \textsf{fontspec} package enables automatic font selection for \LaTeX{} documents typeset with \XeTeX{}. The basic command is\\ -\indent \verb|\fontspec[font features]{Mac OS X font display name}|.\\ +\indent \verb|\fontspec[font features]{font display name}|.\\ As an example: \begin{center} @@ -3538,13 +3996,13 @@ As an example: The default roman, sans serif, and typewriter fonts may be set with the \verb|\setromanfont|, \verb|\setsansfont| and \verb|\setmonofont| commands, respectively, as shown in the preamble. They take the same syntax as the \verb|\fontspec| package. All expected font shapes are available: \begin{center} - {\scshape Small caps and \itshape small caps italic\dots}\\ + {\itshape Italics and \scshape small caps\dots}\\ {\sffamily\bfseries Bold sans serif and \itshape bold italic sans serif\dots} \end{center} -With the roman and sans serif fonts set in the preamble, text fonts in math mode are also changed: $\cos(n\pi)=\pm 1$. The maths typeface `Euler' has been used in this document (with the \textsf{euler} package---note that the \textsf{eulervm} package will not work in \XeTeX{} because it uses virtual fonts), since the default Computer Modern maths font is rather light. +With the roman and sans serif fonts set in the preamble, text fonts in math mode are also changed: $\cos(n\pi)=\pm 1$. The maths typeface `Euler' has been used in this document (with the \textsf{euler} package---or the \textsf{eulervm} package if the |xpdfdvimx| driver is being used), since the default Computer Modern maths font is rather light. \[ - \mathcal F(s) = \int^\infty_0\! f(t) e^{-st}\,\mathrm{d}t + \mathcal F(s) = \int^\infty_0 f(t) \exp(-st)\,\mathrm{d}t \] You'll also notice the \verb|\defaultfontfeatures| command in the preamble. This command takes a single argument of font features that are then applied to every subsequent instance of font selection. The first argument in this case, \verb|Mapping=tex-text|, enables regular \TeX{} ligatures like \verb|``---''| for ``---''. The second automatically scales the fonts to the same x-height. @@ -3572,8 +4030,8 @@ Please see the documentation for font feature explanation and further package ni % \begin{macrocode} \ProvidesPackage{fontspec-doc-style} -\RequirePackage{booktabs,calc,color,euler,fancyvrb,fontspec, - graphicx,ifthen,url,varioref,xelatex,xunicode} +\RequirePackage{booktabs,calc,color,enumitem,euler,fancyvrb,fontspec, + graphicx,ifthen,ifxetex,url,varioref,xltxtra,xunicode} %% Titlepage \renewcommand\maketitle{% @@ -3683,7 +4141,7 @@ Please see the documentation for font feature explanation and further package ni \end{minipage} \end{list} \global\let\examplesize\normalsize - \gdef\firstline{1}\gdef\lastline{}} + \gdef\firstline{1}\gdef\lastline{}\par\noindent} \let\examplesize\normalsize \let\auxwidth\relax @@ -3696,18 +4154,23 @@ Please see the documentation for font feature explanation and further package ni %% Sidenotes: \newcommand\warn[2]{% \edef\thisversion{#1}% - \ifhmode\unskip~\fi({\ifx\thisversion\fileversion\color{red}\fi - $\leftarrow$})% + \ifhmode\unskip~\fi{\ifx\thisversion\fileversion\color{red}\fi + $\leftarrow$}% + \marginpar{\raggedleft + \small% + {\ifx\thisversion\fileversion\color{red}\fi$\rightarrow$}% + \,{\notefont #1:~#2}}} + +\newcommand\new[1]{% + \edef\thisversion{#1}% + \ifhmode\unskip~\fi{\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi + $\leftarrow$}% \marginpar{\raggedleft - \scriptsize({\ifx\thisversion\fileversion\color{red}\fi - $\rightarrow$}\,\notefont #1:~#2)}} + \small\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi + $\rightarrow$\,{\notefont #1:~New!}}} %% Sidenote font -\newfontinstance\notefont[ - Width=1.3, - BoldFont={Skia}, - BoldFeatures={Width=1.3,Weight=1.5} - ]{Skia} +\newfontfamily\notefont[Scale=MatchLowercase]{Optima} %% Various labelling commands: \newcommand*\name[1]{{#1}} @@ -3725,17 +4188,13 @@ Please see the documentation for font feature explanation and further package ni \newcommand\note[1]{\unskip\footnote{#1}} %% LOGOS, tuned for Palatino: -\def\TeX{T\kern-.15em\lower.5ex\hbox{E}\kern-.07em X\spacefactor1000\relax} -\def\reflect#1{{\setbox0=\hbox{#1}\rlap{\kern0.5\wd0 - \special{x:gsave}\special{x:scale -1 1}}\box0 \special{x:grestore}}} -\def\XeTeX{\raisebox{0pt}[0pt][0pt] - {X\lower.5ex\hbox{\kern-.07em\reflect{E}}\kern-.15em \TeX}} +\TeX@logo@spacing{-0.12em}{-0.12em}% + {0.5ex}{-0.3em}{-0.12em}{-0.1em} + \def\MacOSX{Mac~OS~X} -\let\oldTeX\TeX\def\TeX{\raisebox{0pt}[0pt][0pt]{\oldTeX}} -\let\oldLaTeX\LaTeX\def\LaTeX{\raisebox{0pt}[0pt][0pt]{\oldLaTeX}} %% fontspec declarations: -\setromanfont[Diacritics=Decompose,Mapping=tex-text]{Palatino} +\setromanfont[Mapping=tex-text,Numbers=OldStyle]{FPL Neu} \defaultfontfeatures{Scale=MatchLowercase} \setsansfont[Weight=1.2, Width=1.1, Mapping=tex-text, @@ -3751,6 +4210,17 @@ Please see the documentation for font feature explanation and further package ni \lineskiplimit=-5pt % Osaka is really tall so this prevents ugly lines \frenchspacing % Remove ugly extra space after punctuation +\makeatletter +\newcounter{argument} +\g@addto@macro\endmacro{\setcounter{argument}{0}} +\newcommand*\darg[1]{% + \stepcounter{argument}% + \noindent{\ttfamily\char`\#\theargument~:~}#1\par} +\newcommand*\doarg[1]{% + \stepcounter{argument}% + \noindent{\ttfamily\makebox[0pt][r]{[}\char`\#\theargument]:~}#1\par} +\makeatother + % \end{macrocode} %</doc-style> % \fi |