summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fontspec
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-02-26 23:47:28 +0000
committerKarl Berry <karl@freefriends.org>2011-02-26 23:47:28 +0000
commitf07534a834462ff702e6d3a52dbd795f4f7262ad (patch)
tree80f1ba95ba5652c9a76c4a2e7851395649a5c6f1 /Master/texmf-dist/source/latex/fontspec
parentddb39646bb545ff15c6a16a71e32ad697cddf11a (diff)
fontspec (26feb11)
git-svn-id: svn://tug.org/texlive/trunk@21527 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/fontspec')
-rw-r--r--Master/texmf-dist/source/latex/fontspec/fontspec.dtx157
1 files changed, 107 insertions, 50 deletions
diff --git a/Master/texmf-dist/source/latex/fontspec/fontspec.dtx b/Master/texmf-dist/source/latex/fontspec/fontspec.dtx
index 8f57befd73b..e020f651bed 100644
--- a/Master/texmf-dist/source/latex/fontspec/fontspec.dtx
+++ b/Master/texmf-dist/source/latex/fontspec/fontspec.dtx
@@ -9,7 +9,7 @@
_________________________________________
The fontspec package for XeLaTeX/LuaLaTeX
- (C) 2004--2010 Will Robertson and Khaled Hosny
+ (C) 2004--2011 Will Robertson and Khaled Hosny
License information appended.
@@ -17,7 +17,7 @@
\endpreamble
\postamble
-Copyright 2004--2010 Will Robertson <wspr81@gmail.com>
+Copyright 2004--2011 Will Robertson <wspr81@gmail.com>
Copyright 2009--2010 Khaled Hosny <khaledhosny@eglug.org>
Distributable under the LaTeX Project Public License,
@@ -62,7 +62,7 @@ This work consists of this file fontspec.dtx
%<fontspec>\ProvidesPackage{fontspec}
%<patches>\ProvidesPackage{fontspec-patches}
%<*fontspec|patches>
- [2010/11/17 v2.1e Advanced font selection for XeLaTeX/LuaLaTeX]
+ [2011/02/26 v2.1f Advanced font selection for XeLaTeX/LuaLaTeX]
%</fontspec|patches>
%
%<*driver>
@@ -1226,7 +1226,8 @@ This work consists of this file fontspec.dtx
%
% \subsection{Contextuals}
% This feature refers to substitutions of glyphs that vary `contextually' by their relative position in a word or string of characters;
-% features such as contextual swashes are accessed here.
+% features such as contextual swashes are accessed via the options shown in \ref{feat:Contextuals}.
+% See \exref{swash} for an, er, example.
%
% \begin{features}{Contextuals}
% \otf{Swash}{cswh}
@@ -1460,6 +1461,10 @@ This work consists of this file fontspec.dtx
%
% \subsection{Kerning}\label{sec:kerning}
% Specifies how inter-glyph spacing should behave.
+% Well-made fonts include information for how differing
+% amounts of space should be inserted between separate character pairs.
+% This kerning space is inserted automatically but in rare
+% circumstances you may wish to turn it off.
%
% \begin{features}{Kerning}
% \otf{Uppercase}{cpsp}
@@ -1467,7 +1472,12 @@ This work consists of this file fontspec.dtx
% \end{features}
%
% 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, seen in \exref{kernup}, which uses the Romande fonts\note{\url{http://arkandis.tuxfamily.org/adffonts.html}} (thanks to Clea F. Rees for the suggestion).
+% the \opt{Uppercase} option will add a small amount of tracking between
+% uppercase letters, seen in \exref{kernup}, which uses the Romande
+% fonts\note{\url{http://arkandis.tuxfamily.org/adffonts.html}}
+% (thanks to Clea F. Rees for the suggestion).
+% The \opt{Uppercase} option acts separately to the regular kerning
+% controlled by the \opt{On}/\opt{Off} options.
%
% \begin{Xexample}[firstline=2]{kernup}{Adding extra kerning for uppercase letters. (The difference is usually very small.)}
% \large
@@ -1637,12 +1647,15 @@ This work consists of this file fontspec.dtx
%
% \subsubsection{\feat{Script} and \feat{Language} examples}
%
-% In the following examples, the Code2000 font\note{\url{http://www.code2000.net/}}
-% is used to typeset the input with and without the OpenType Script
-% applied. The text is only rendered correctly in the second case;
+% In the examples shown in \exref{script-lang},
+% the Code2000 font\note{\url{http://www.code2000.net/}}
+% is used to typeset various input texts with and without the OpenType Script
+% applied for various alphabets.
+% The text is only rendered correctly in the second case;
% many examples of incorrect diacritic spacing as
% well as a lack of contextual ligatures and rearrangement can be
-% seen. Thanks to \name{Jonathan Kew}, \name{Yves Codet} and
+% seen.
+% Thanks to \name{Jonathan Kew}, \name{Yves Codet} and
% \name{Gildas Hamel} for their contributions towards these examples.
%
% \begin{Xexample}[firstline=14,lastline=23]{script-lang}{An example of various Scripts and Languages.}
@@ -2469,16 +2482,20 @@ This work consists of this file fontspec.dtx
% \pkg{luaotfload} which loads \pkg{luatexbase} and \pkg{lualibs} too.
%
% \begin{macrocode}
-\msg_new:nnn {fontspec} {not-pdftex}
+\msg_new:nnn {fontspec} {cannot-use-pdftex}
{
- Requires~ XeTeX~ or~ LuaTeX~ to~ function!
+ The~ fontspec~ package~ requires~ either~ XeTeX~ or~ LuaTeX~ to~ function.
+ \\\\
+ You~ must~ change~ your~ typesetting~ engine~ to,~
+ e.g.,~ "xelatex"~ or~ "lualatex"\\
+ instead~ of~ plain~ "latex"~ or~ "pdflatex".
}
\xetex_if_engine:F {
\luatex_if_engine:TF {
\RequirePackage{luaotfload}
\RequireLuaModule{fontspec}
}{
- \msg_fatal:nn {fontspec} {not-pdftex}
+ \msg_fatal:nn {fontspec} {cannot-use-pdftex}
}
}
% \end{macrocode}
@@ -2601,6 +2618,15 @@ This work consists of this file fontspec.dtx
Size~ information~ must~ be~ supplied.\\
For~ example,~ SizeFeatures={Size={8-12},...}.
}
+\msg_new:nnnn {fontspec} {font-not-found}
+{
+ The~ font~ "#1"~ cannot~ be~ found.
+}
+{
+ A~font~might~not~be~found~for~many~reasons.\\
+ Check~the~spelling,~where~the~font~is~installed~etc.~etc.\\\\
+ When~in~doubt,~ask~someone~for~help!
+}
\msg_new:nnnn {fontspec} {rename-feature-not-exist}
{
The~ feature~ #1~ doesn't~ appear~ to~ be~ defined.
@@ -3235,7 +3261,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_aat_feature:nn {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\use:c{zf@family@fontdef\f@family}} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\use:c{zf@family@fontdef\f@family}} {\f@size pt}
\bool_if:NTF \l_fontspec_atsui_bool {
\fontspec_make_AAT_feature_string:nnTF {#1}{#2}
\prg_return_true: \prg_return_false:
@@ -3256,7 +3282,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_opentype: {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
\fontspec_set_font_type:
\bool_if:NTF \l_fontspec_icu_bool \prg_return_true: \prg_return_false:
}{
@@ -3274,7 +3300,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_feature:n {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
\fontspec_set_font_type:
\bool_if:NTF \l_fontspec_icu_bool {
\int_set:Nv \l_fontspec_script_int {g_fontspec_script_num_(\f@family)_tl}
@@ -3299,7 +3325,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_feature:nnn {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
\fontspec_set_font_type:
\bool_if:NTF \l_fontspec_icu_bool {
\fontspec_iv_str_to_num:Nn \l_fontspec_script_int {#1}
@@ -3323,7 +3349,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_script:n {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
\fontspec_set_font_type:
\bool_if:NTF \l_fontspec_icu_bool {
\fontspec_check_script:nTF {#1} \prg_return_true: \prg_return_false:
@@ -3345,7 +3371,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_language:n {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
\fontspec_set_font_type:
\bool_if:NTF \l_fontspec_icu_bool {
\tl_set:Nv \l_fontspec_script_tl {g_fontspec_script_(\f@family)_tl}
@@ -3369,7 +3395,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_language:nn {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
\fontspec_set_font_type:
\bool_if:NTF \l_fontspec_icu_bool {
\tl_set:Nn \l_fontspec_script_tl {#1}
@@ -3392,7 +3418,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_current_script:n {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
\fontspec_set_font_type:
\bool_if:NTF \l_fontspec_icu_bool {
\str_if_eq:nvTF {#1} {g_fontspec_script_(\f@family)_tl}
@@ -3413,7 +3439,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\prg_new_conditional:Nnn \fontspec_if_current_language:n {TF,T,F} {
\fontspec_if_fontspec_font:TF {
- \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
\fontspec_set_font_type:
\bool_if:NTF \l_fontspec_icu_bool {
\str_if_eq:nvTF {#1} {g_fontspec_lang_(\f@family)_tl}
@@ -3455,9 +3481,6 @@ This work consists of this file fontspec.dtx
%
% \subsection{expl3 interface for font loading}
%
-% Using |\font\1={xyz}| notation doesn't work at present with LuaLaTeX,
-% although it should be the correct way to do things. Continue to use
-% |\font\1="xyz"| for now for both engines.
% \begin{macrocode}
\xetex_or_luatex:nnn { \cs_set:Npn \fontspec_fontwrap:n #1 } { "#1" } { {#1} }
\cs_set:Npn \fontspec_fontwrap:n #1 { "#1" }
@@ -3465,14 +3488,40 @@ This work consists of this file fontspec.dtx
%
% Beginnings of an `l3font', I guess:
% \begin{macrocode}
-\cs_set_eq:NN \font_set_eq:NN \tex_let:D
-\cs_new:Npn \font_set:Nnn #1#2#3 {
- \font #1 = \fontspec_fontwrap:n {#2} ~at~#3\scan_stop:
+\cs_if_free:NT \font_set_eq:NN {
+ \cs_set_eq:NN \font_set_eq:NN \tex_let:D
+ \cs_set:Npn \font_set:Nnn #1#2#3 {
+ \font #1 = #2 ~at~ #3\scan_stop:
+ }
+ \cs_set:Npn \font_gset:Nnn #1#2#3 {
+ \global \font #1 = #2 ~at~ #3 \scan_stop:
+ }
+ \xetex_or_luatex:nnn {\cs_set:Npn \font_suppress_not_found_error:}
+ {\suppressfontnotfounderror=1}
+ {\luatexsuppressfontnotfounderror=1}
+ \prg_set_conditional:Nnn \font_if_null:N {p,TF,T,F} {
+ \ifx #1 \nullfont
+ \prg_return_true:
+ \else
+ \prg_return_false:
+ \fi
+ }
+}
+% \end{macrocode}
+%
+%
+% \begin{macro}{\fontspec_set:Nnn,\fontspec_gset:Nnn}
+% Wrapper around \cs{font_set:Nnn} and \cs{font_gset:Nnn}.
+% \begin{macrocode}
+\cs_new:Nn \fontspec_font_set:Nnn {
+ \font_set:Nnn #1 {\fontspec_fontwrap:n {#2}} {#3}
}
-\cs_new:Npn \font_gset:Nnn #1#2#3 {
- \global \font #1 = \fontspec_fontwrap:n {#2} ~at~#3\scan_stop:
+\cs_new:Nn \fontspec_font_gset:Nnn {
+ \font_gset:Nnn #1 {\fontspec_fontwrap:n {#2}} {#3}
}
% \end{macrocode}
+% \end{macro}
+%
%
% \begin{macro}{\font_glyph_if_exist:NnTF}
% \begin{macrocode}
@@ -3508,6 +3557,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\cs_set:Npn \fontspec_select:nn #1#2 {
\group_begin:
+ \font_suppress_not_found_error:
\fontspec_init:
% \end{macrocode}
% \cmd{\l_fontspec_fontname_tl} is used as the generic name of the font being defined.
@@ -3537,6 +3587,17 @@ This work consists of this file fontspec.dtx
% conditional.
% \begin{macrocode}
\fontspec_preparse_features:nn {#1}{#2}
+% \end{macrocode}
+% Finally save the `confirmed' font definition.
+% \begin{macrocode}
+ \fontspec_font_set:Nnn \zf@basefont {\fontspec_fullname:n {\l_fontspec_fontname_up_tl}} {\f@size pt}
+ \font_if_null:NT \zf@basefont { \fontspec_error:nx {font-not-found} {\l_fontspec_fontname_up_tl} }
+ \fontspec_set_font_type:
+ \fontspec_font_gset:Nnn \zf@basefont {\fontspec_fullname:n {\l_fontspec_fontname_up_tl}} {\f@size pt}
+ \zf@basefont % this is necessary for LuaLaTeX to check the scripts properly
+% \end{macrocode}
+% Continue:
+% \begin{macrocode}
\fontspec_set_scriptlang:
\fontspec_get_features:n {}
\bool_set_false:N \l_fontspec_firsttime_bool
@@ -3593,13 +3654,6 @@ This work consists of this file fontspec.dtx
\tl_set_eq:NN \l_fontspec_fontname_tl \l_fontspec_fontname_up_tl
\fontspec_setkeys:xx {preparse} {\XKV@rm}
\clist_set_eq:NN \l_fontspec_fontfeat_clist \XKV@rm
-% \end{macrocode}
-% Finally save the `confirmed' font definition.
-% \begin{macrocode}
- \font_set:Nnn \zf@basefont {\fontspec_fullname:n {\l_fontspec_fontname_up_tl}} {\f@size pt}
- \fontspec_set_font_type:
- \font_gset:Nnn \zf@basefont {\fontspec_fullname:n {\l_fontspec_fontname_up_tl}} {\f@size pt}
- \zf@basefont % this is necessary for LuaLaTeX to check the scripts properly
}
% \end{macrocode}
% \end{macro}
@@ -3756,7 +3810,7 @@ This work consists of this file fontspec.dtx
\cs_new:Npn \fontspec_set_bold: {
\bool_if:NF \l_fontspec_nobf_bool {
\tl_if_empty:NTF \l_fontspec_fontname_bf_tl {
- \fontspec_make_font_shapes:nnnnn \l_fontspec_fontname_tl {/B}
+ \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_tl {/B}
\bfdefault \updefault \l_fontspec_fontfeat_bf_clist
}{
\fontspec_make_font_shapes:nnnn \l_fontspec_fontname_bf_tl
@@ -3773,7 +3827,7 @@ This work consists of this file fontspec.dtx
\cs_new:Npn \fontspec_set_italic: {
\bool_if:NF \l_fontspec_noit_bool {
\tl_if_empty:NTF \l_fontspec_fontname_it_tl
- { \fontspec_make_font_shapes:nnnnn \l_fontspec_fontname_tl {/I} }
+ { \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_tl {/I} }
{ \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_it_tl }
\mddefault \itdefault \l_fontspec_fontfeat_it_clist
}
@@ -3808,14 +3862,14 @@ This work consists of this file fontspec.dtx
{
\tl_if_empty:NTF \l_fontspec_fontname_it_tl
{
- \fontspec_make_font_shapes:nnnnn \l_fontspec_fontname_tl {/BI}
+ \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_tl {/BI}
}
{
- \fontspec_make_font_shapes:nnnnn \l_fontspec_fontname_it_tl {/B}
+ \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_it_tl {/B}
}
}
{
- \fontspec_make_font_shapes:nnnnn \l_fontspec_fontname_bf_tl {/I}
+ \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_bf_tl {/I}
}
}
{
@@ -3833,7 +3887,7 @@ This work consists of this file fontspec.dtx
\cs_new:Npn \fontspec_set_bold_slanted: {
\tl_if_empty:NTF \l_fontspec_fontname_bfsl_tl {
\tl_if_empty:NF \l_fontspec_fontname_sl_tl {
- \fontspec_make_font_shapes:nnnnn \l_fontspec_fontname_sl_tl {/B}
+ \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_sl_tl {/B}
\bfdefault \sldefault \l_fontspec_fontfeat_bfsl_clist
}
}{
@@ -3900,7 +3954,7 @@ This work consists of this file fontspec.dtx
%
%
%
-% \begin{macro}{\fontspec_make_font_shapes:nnnn,\fontspec_make_font_shapes:nnnnn}
+% \begin{macro}{\fontspec_make_font_shapes:nnnn,\fontspec_make_auto_font_shapes:nnnnn}
% \darg{Font name prefix (in the 5-arg case)}
% \darg{Font name}
% \darg{Font series}
@@ -3924,9 +3978,9 @@ This work consists of this file fontspec.dtx
% italic small caps by their own identifier. See \vref{sec:sishape}
% for the code that enables this usage.
% \begin{macrocode}
-\cs_new:Nn \fontspec_make_font_shapes:nnnnn {
- \font_set:Nnn \l_tmpa_font {\fontspec_fullname:n {#1}} {\f@size pt}
- \font_set:Nnn \l_tmpb_font {\fontspec_fullname:n {#1#2}} {\f@size pt}
+\cs_new:Nn \fontspec_make_auto_font_shapes:nnnnn {
+ \fontspec_font_set:Nnn \l_tmpa_font {\fontspec_fullname:n {#1}} {\f@size pt}
+ \fontspec_font_set:Nnn \l_tmpb_font {\fontspec_fullname:n {#1#2}} {\f@size pt}
\str_if_eq:xxTF { \fontname \l_tmpa_font } { \fontname \l_tmpb_font }
{ \fontspec_info:nx {no-font-shape} {#1#2} }
{
@@ -3936,7 +3990,8 @@ This work consists of this file fontspec.dtx
\cs_new:Nn \fontspec_make_font_shapes:nnnn {
\group_begin:
\tl_set:Nx \l_fontspec_fontname_tl {#1}
- \font_set:Nnn \zf@basefont {\fontspec_fullname:n {#1}} {\f@size pt}
+ \fontspec_font_set:Nnn \zf@basefont {\fontspec_fullname:n {#1}} {\f@size pt}
+ \font_if_null:NT \zf@basefont { \fontspec_error:nx {font-not-found} {#1} }
\fontspec_declare_shape:nnnn {}{#2}{#3}{#4}
\tl_if_empty:NTF \l_fontspec_fontname_sc_tl {
\bool_if:NF \l_fontspec_nosc_bool {
@@ -4201,9 +4256,10 @@ This work consists of this file fontspec.dtx
%
% \begin{macro}{\sclist_put_right:Nn}
% I'm hardly going to write an `sclist' module but a couple of functions are
-% useful.
+% useful. Here, items in semi-colon lists are always followed by a semi-colon
+% (as opposed to the s.-c's being placed between elements) so we can append
+% sclists without worrying about it.
% \begin{macrocode}
-\cs_set_eq:NN \sclist_new:N \tl_new:N
\cs_set_eq:NN \sclist_clear:N \tl_clear:N
\cs_new:Npn \sclist_gput_right:Nn #1#2 {
\tl_gput_right:Nn #1 {#2;}
@@ -4222,7 +4278,7 @@ This work consists of this file fontspec.dtx
% \begin{macrocode}
\cs_new:Nn \fontspec_update_featstr:n {
\bool_if:NF \l_fontspec_firsttime_bool {
- \sclist_gput_right:Nx \l_fontspec_rawfeatures_sclist {#1;}
+ \sclist_gput_right:Nx \l_fontspec_rawfeatures_sclist {#1}
}
}
% \end{macrocode}
@@ -5151,6 +5207,7 @@ This work consists of this file fontspec.dtx
\fontspec_define_feature_option:nnnnn{Letters}{UppercasePetiteCaps}{} {} {+c2pc}
\fontspec_define_feature_option:nnnnn{Letters}{InitialCaps} {3}{4}{}
\fontspec_define_feature_option:nnnnn{Letters}{Unicase} {} {} {+unic}
+\fontspec_define_feature_option:nnnnn{Letters}{Random} {} {} {+rand}
% \end{macrocode}
%
% \subsubsection{Numbers}