diff options
author | Karl Berry <karl@freefriends.org> | 2010-06-09 00:22:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-06-09 00:22:21 +0000 |
commit | e75495f92d91038a568dec3fd1cc854d51daf4c7 (patch) | |
tree | 99417371e2a2c104d8082b24e8f1a0faef2be81e /Master/texmf-dist/tex/latex/fontspec | |
parent | aac86e6df7bc5de903798b0c8a7f6b49cf4e9b75 (diff) |
fontspec v2 (8jun10)
git-svn-id: svn://tug.org/texlive/trunk@18825 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/fontspec')
4 files changed, 169 insertions, 104 deletions
diff --git a/Master/texmf-dist/tex/latex/fontspec/fontspec-patches.sty b/Master/texmf-dist/tex/latex/fontspec/fontspec-patches.sty index 5298ad11cc0..9a228421de2 100644 --- a/Master/texmf-dist/tex/latex/fontspec/fontspec-patches.sty +++ b/Master/texmf-dist/tex/latex/fontspec/fontspec-patches.sty @@ -14,7 +14,9 @@ %% %% \ProvidesPackage{fontspec-patches} - [2010/06/03 v2.0b2 Advanced font selection for XeLaTeX/LuaLaTeX] + [2010/06/08 v2.0 Advanced font selection for XeLaTeX/LuaLaTeX] + + \ExplSyntaxOn \RequirePackage{fixltx2e}[2006/03/24] \DeclareRobustCommand \em { diff --git a/Master/texmf-dist/tex/latex/fontspec/fontspec.cfg b/Master/texmf-dist/tex/latex/fontspec/fontspec.cfg index bc1be91d447..7ecb2df2c4d 100644 --- a/Master/texmf-dist/tex/latex/fontspec/fontspec.cfg +++ b/Master/texmf-dist/tex/latex/fontspec/fontspec.cfg @@ -1,4 +1,6 @@ + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% FOR BACKWARDS COMPATIBILITY WITH PREVIOUS VERSIONS %%% diff --git a/Master/texmf-dist/tex/latex/fontspec/fontspec.lua b/Master/texmf-dist/tex/latex/fontspec/fontspec.lua index c67d56c2702..b777424cfeb 100644 --- a/Master/texmf-dist/tex/latex/fontspec/fontspec.lua +++ b/Master/texmf-dist/tex/latex/fontspec/fontspec.lua @@ -13,6 +13,8 @@ -- License information appended. -- -- + + fontspec = { } fontspec.module = { @@ -142,38 +144,16 @@ function fontspec.check_ot_feat(fnt, feat, lang, script) end end - -function fontspec.get_dimen(fontdimen, csname) - local id, h, em, pt - if csname == "font" then - id = font.current() - else - id = font_id(csname) - end - if fontdimen == 8 then - h = fonts.ids[id].shared.otfdata.pfminfo.os2_capheight - elseif fontdimen == 5 then - h = fonts.ids[id].shared.otfdata.pfminfo.os2_xheight - end - em = fonts.ids[id].shared.otfdata.metadata.units_per_em - pt = fonts.ids[id].size / 65536 - tex.sprint(string.format("%spt", (h/em)*pt)) -end - -function fontspec.charglyph(char, csname) - local id, c +function fontspec.charglyph(char) if char then + local id, c if utf.len(char) > 1 then c = utf.byte(utf.char(char:gsub('"', '0x'))) else c = utf.byte(char) end - if csname then - id = font_id(csname) - else - id = font.current() - end + id = font.current() if font.fonts[id]["characters"][c] then return font.fonts[id]["characters"][c].index diff --git a/Master/texmf-dist/tex/latex/fontspec/fontspec.sty b/Master/texmf-dist/tex/latex/fontspec/fontspec.sty index b129b935e05..afb20ff702c 100644 --- a/Master/texmf-dist/tex/latex/fontspec/fontspec.sty +++ b/Master/texmf-dist/tex/latex/fontspec/fontspec.sty @@ -14,8 +14,11 @@ %% %% \ProvidesPackage{fontspec} - [2010/06/03 v2.0b2 Advanced font selection for XeLaTeX/LuaLaTeX] + [2010/06/08 v2.0 Advanced font selection for XeLaTeX/LuaLaTeX] + + \RequirePackage{expl3,xparse} +\input binhex.tex % before expl syntax! \ExplSyntaxOn \msg_new:nnn {fontspec} {not-pdftex} { @@ -60,6 +63,8 @@ \newcount\c@zf@language \int_new:N \l_fontspec_strnum_int \cs_set:Npn \use:x #1 { \edef\@tempa{#1}\@tempa } +\cs_set:Npn \use_v:nnnnn #1#2#3#4#5 {#5} +\cs_set:Npn \use_iv:nnnnn #1#2#3#4#5 {#4} \cs_new:Npn \fontspec_setkeys:xx #1#2 { \use:x { \exp_not:N \setkeys*[zf]{#1}{#2} } @@ -111,7 +116,22 @@ loaded~ after~ euler.~ Type~ <return>~ to~ proceed\\ with~ incorrect~ \string\mathit,~ \string\mathbf,~ etc. } - +\msg_new:nnnn {fontspec} {no-xcolor} +{ + Cannot~ load~ named~ colours~ without~ the~ xcolor~ package. +} +{ + Sorry,~ I~ can't~ do~ anything~ to~ help.~ Instead~ of~ loading\\ + the~ color~ package,~ use~ xcolor~ instead.~ It's~ better. +} +\msg_new:nnnn {fontspec} {unknown-color-model} +{ + Error~ loading~ colour~ `#1';~ unknown~ colour~ model. +} +{ + Sorry,~ I~ can't~ do~ anything~ to~ help.~ Please~ report~ this~ error\\ + to~ my~ developer~ with~ a~ minimal~ example~ that~ causes~ the~ problem. +} \msg_new:nnn {fontspec} {addfontfeatures-ignored} { \string\addfontfeature (s)~ ignored;\\ @@ -195,7 +215,7 @@ } \msg_new:nnn {fontspec} {no-scripts} { - Font~ \zf@fontname~ does not contain any OpenType `Script' information. + Font~ \zf@fontname\space does~ not~ contain~ any~ OpenType~ `Script'~ information. } \DeclareOption{cm-default}{ \fontspec_warning:n {cm-default-obsolete} @@ -520,57 +540,100 @@ \edef\zf@fontname{#2} \let\zf@family@long\zf@fontname \let\zf@up\zf@fontname + \fontspec_preparse_features:nn {#1}{#2} + \fontspec_set_scriptlang: + \fontspec_get_features:n {\zf@font@feat} + \zf@firsttimefalse + \fontspec_save_family:nT {#2} { + \fontspec_info:nxx {defining-font} {#1} {#2} + \fontspec_save_fontinfo:nn {#1} {#2} + \DeclareFontFamily{\zf@enc}{\zf@family}{} + \fontspec_set_upright: + \fontspec_set_bold: + \fontspec_set_italic: + \fontspec_set_slanted: + \fontspec_set_bold_italic: + \fontspec_set_bold_slanted: + } + \endgroup +} +\cs_set_eq:NN \zf@fontspec \fontspec_select:nn +\cs_new:Npn \fontspec_preparse_features:nn #1#2 { \fontspec_if_detect_external:nT {#2} { \setkeys[zf]{preparse-external}{ExternalLocation} } \fontspec_setkeys:xx {preparse-external} {\zf@default@options #1} \let\zf@fontname\zf@up \fontspec_setkeys:xx {preparse} {\XKV@rm} \let\zf@font@feat\XKV@rm - \global\font\zf@basefont="\fontspec_fullname:n {\zf@up}"~at~\f@size pt + \font\zf@basefont="\fontspec_fullname:n {\zf@up}"~at~\f@size pt \fontspec_set_font_type: \global\font\zf@basefont="\fontspec_fullname:n {\zf@up}"~at~\f@size pt - \zf@firsttimetrue - \ifzf@icu - \tl_if_empty:NTF \l_fontspec_script_name_tl { - \fontspec_check_script:nTF {latn} - { - \tl_set:Nn \l_fontspec_script_name_tl {Latin} - \tl_set:Nn \l_fontspec_script_tl {latn} - \tl_if_empty:NT \l_fontspec_lang_tl { - \tl_set:Nn \l_fontspec_lang_name_tl {Default} - \tl_set:Nn \l_fontspec_lang_tl {DFLT} - } - \fontspec_setkeys:xxx {feat} {Script} {\l_fontspec_script_name_tl} - \fontspec_setkeys:xxx {feat} {Lang} {\l_fontspec_lang_name_tl} - } - { - \fontspec_info:n {no-scripts} - } - } - { - \fontspec_setkeys:xxx {feat} {Script} {\l_fontspec_script_name_tl} - \fontspec_setkeys:xxx {feat} {Lang} {\l_fontspec_lang_name_tl} - } - \fi - \fontspec_get_features:n{\zf@font@feat} - \zf@firsttimefalse + \zf@basefont % this is necessary for LuaLaTeX to check the scripts properly +} +\prg_new_conditional:Nnn \fontspec_if_detect_external:n {T} + { + \clist_map_inline:Nn \l_fontspec_extensions_clist + { + \bool_set_false:N \l_tmpa_bool + \tl_if_in:nnT {#1 <= end_of_string} {##1 <= end_of_string} + { \bool_set_true:N \l_tmpa_bool \clist_map_break: } + } + \bool_if:NTF \l_tmpa_bool \prg_return_true: \prg_return_false: + } +\cs_set:Npn \fontspec_fullname:n #1 { + \fontspec_namewrap:n { #1 \l_fontspec_extension_tl } + \l_fontspec_renderer_tl + \l_fontspec_optical_size_tl +} +%% Now we have a unique (in fact, too unique!) string that contains +\prg_new_conditional:Nnn \fontspec_save_family:n {T} { \unless\ifcsname zf@UID@\zf@family@long\endcsname - \ifcsname c@zf@famc@#2\endcsname + \ifcsname c@zf@famc@#1\endcsname \expandafter\global\expandafter\advance - \csname c@zf@famc@#2\endcsname\@ne + \csname c@zf@famc@#1\endcsname\@ne \else \expandafter\global\expandafter\newcount - \csname c@zf@famc@#2\endcsname + \csname c@zf@famc@#1\endcsname \fi - \edef\@tempa{#2~} + \edef\@tempa{#1~} \cs_gset:cpx{zf@UID@\zf@family@long}{ \expandafter\zap@space\@tempa\@empty - (\expandafter\the\csname c@zf@famc@#2\endcsname) + (\expandafter\the\csname c@zf@famc@#1\endcsname) } \fi \xdef\zf@family{\@nameuse{zf@UID@\zf@family@long}} - \unless\ifcsname zf@family@fontname\zf@family\endcsname - \fontspec_info:nxx {defining-font} {#1} {#2} + \cs_if_exist:cTF {zf@family@fontname\zf@family} + \prg_return_false: \prg_return_true: +} +\cs_new:Npn \fontspec_set_scriptlang: { + \ifzf@icu + \tl_if_empty:NTF \l_fontspec_script_name_tl { + \fontspec_check_script:nTF {latn} + { + \tl_set:Nn \l_fontspec_script_name_tl {Latin} + \tl_set:Nn \l_fontspec_script_tl {latn} + \tl_if_empty:NT \l_fontspec_lang_tl { + \tl_set:Nn \l_fontspec_lang_name_tl {Default} + \tl_set:Nn \l_fontspec_lang_tl {DFLT} + } + \fontspec_setkeys:xxx {feat} {Script} {\l_fontspec_script_name_tl} + \fontspec_setkeys:xxx {feat} {Lang} {\l_fontspec_lang_name_tl} + } + { + \fontspec_info:n {no-scripts} + } + } + { + \tl_if_empty:NT \l_fontspec_lang_tl { + \tl_set:Nn \l_fontspec_lang_name_tl {Default} + \tl_set:Nn \l_fontspec_lang_tl {DFLT} + } + \fontspec_setkeys:xxx {feat} {Script} {\l_fontspec_script_name_tl} + \fontspec_setkeys:xxx {feat} {Lang} {\l_fontspec_lang_name_tl} + } + \fi +} +\cs_new:Npn \fontspec_save_fontinfo:nn #1#2 { \tl_gset:cx {zf@family@fontname\zf@family} {#2} \tl_gset:cx {zf@family@options\zf@family} {\zf@default@options #1} \tl_gset:cx {zf@family@fontdef\zf@family} { @@ -582,31 +645,10 @@ { \int_use:N \c@zf@language } \tl_gset_eq:cN {g_fontspec_script_(\zf@family)_tl} \l_fontspec_script_tl \tl_gset_eq:cN {g_fontspec_lang_(\zf@family)_tl} \l_fontspec_lang_tl - \DeclareFontFamily{\zf@enc}{\zf@family}{} - \zf@make@font@shapes{\zf@fontname} - {\mddefault}{\updefault}{\zf@font@feat\zf@up@feat} - \fontspec_set_bold: - \fontspec_set_italic: - \fontspec_set_slanted: - \fontspec_set_bold_italic: - \fontspec_set_bold_slanted: - \fi - \endgroup } -\prg_new_conditional:Nnn \fontspec_if_detect_external:n {T} - { - \clist_map_inline:Nn \l_fontspec_extensions_clist - { - \bool_set_false:N \l_tmpa_bool - \tl_if_in:nnT {#1 <= end_of_string} {##1 <= end_of_string} - { \bool_set_true:N \l_tmpa_bool \clist_map_break: } - } - \bool_if:NTF \l_tmpa_bool \prg_return_true: \prg_return_false: - } -\cs_set:Npn \fontspec_fullname:n #1 { - \fontspec_namewrap:n { #1 \l_fontspec_extension_tl } - \l_fontspec_renderer_tl - \l_fontspec_optical_size_tl +\cs_new:Npn \fontspec_set_upright: { + \zf@make@font@shapes{\zf@fontname} + {\mddefault}{\updefault}{\zf@font@feat\zf@up@feat} } \cs_new:Npn \fontspec_set_bold: { \unless\ifzf@nobf @@ -640,6 +682,7 @@ \@tempswatrue \ifzf@nobf\@tempswafalse\fi \ifzf@noit\@tempswafalse\fi + \bool_if:NT \l_fontspec_external_bool \@tempswafalse \if@tempswa \ifx\zf@bfit\@empty \ifx\zf@bf\@empty @@ -709,24 +752,24 @@ \else \edef\zf@fontname{#1#2} \let\zf@basefont\@tempfontb - \zf@DeclareFontShape{#3}{#4}{#5} + \fontspec_declare_shape:nnnn {}{#3}{#4}{#5} \ifx\zf@sc\@empty \unless\ifzf@nosc \zf@make@smallcaps \unless\ifx\zf@smallcaps\@empty - \zf@DeclareFontShape[\zf@smallcaps]{#3} + \fontspec_declare_shape:nnnn {\zf@smallcaps}{#3} {\ifx#4\itdefault\sidefault\else\scdefault\fi}{#5\zf@sc@feat} \fi \fi \else \edef\zf@fontname{\zf@sc} - \zf@DeclareFontShape{#3} + \fontspec_declare_shape:nnnn {}{#3} {\ifx#4\itdefault\sidefault\else\scdefault\fi}{#5\zf@sc@feat} \fi \fi \endgroup } -\newcommand\zf@DeclareFontShape[4][]{ +\cs_new:Npn \fontspec_declare_shape:nnnn #1#2#3#4 { \clist_if_empty:NTF \l_fontspec_sizefeat_clist { \fontspec_get_features:n{#4} @@ -751,6 +794,10 @@ } } } + \PackageInfo{fontspec}{ + Defining~ shape~ #2/#3~ with~ raw~ font~ features: + \MessageBreak \l_fontspec_rawfeatures_sclist + \@gobble} \use:x{ \exp_not:N\DeclareFontShape{\zf@enc}{\zf@family}{#2}{#3} {\l_fontspec_nfss_tl}{\zf@adjust} @@ -794,7 +841,9 @@ \tl_if_empty:NF \XKV@rm { \fontspec_error:nx {unknown-options} { \exp_not:V \XKV@rm } } - \PackageInfo{fontspec}{Raw~ font~ features~ "\l_fontspec_rawfeatures_sclist"} + \cs_if_exist:NT \l_fontspec_hexcol_tl { + \zf@update@ff{color=\l_fontspec_hexcol_tl\l_fontspec_opacity_tl} + } } \tl_clear:N \zf@bf \tl_clear:N \zf@it @@ -816,9 +865,13 @@ \tl_clear:N \l_fontspec_lang_name_tl \tl_clear:N \l_fontspec_lang_tl \clist_clear:N \l_fontspec_sizefeat_clist +\tl_set:Nn \l_fontspec_opacity_tl {FF} \newcommand*\fontspec_init:{ \zf@icufalse - \cs_set_eq:NN \fontspec_namewrap:n \use:n + \zf@firsttimetrue + \xetex_or_luatex:nnn { \cs_set:Npn \fontspec_namewrap:n ##1 } + { ##1 } + { name:##1 } \tl_clear:N \l_fontspec_optical_size_tl \tl_clear:N \l_fontspec_renderer_tl \luatex_if_engine:T { @@ -873,6 +926,7 @@ \fontspec_make_ICU_feature:n {#3} } } +\cs_generate_variant:Nn \fontspec_make_feature:nnn {nnx} \cs_new:Npn \fontspec_make_AAT_feature:nn #1#2 { \tl_if_empty:nTF {#1} { @@ -1045,7 +1099,9 @@ \zf@nobftrue \zf@noittrue \bool_set_true:N \l_fontspec_external_bool - \cs_gset:Npn \fontspec_namewrap:n ##1 { [ #1 ##1 ] } + \xetex_or_luatex:nnn { \cs_gset:Npn \fontspec_namewrap:n ##1 } + { [ #1 ##1 ] } + { file: #1 ##1 } \xetex_if_engine:T { \setkeys[zf]{preparse}{Renderer=ICU} } } \aliasfontfeature{ExternalLocation}{Path} @@ -1171,7 +1227,7 @@ \zf@update@family{scfeat:\zap@space #1~\@empty} } \define@key[zf]{preparse}{SizeFeatures}{ - \unless\ifzf@firsttime\def\l_fontspec_sizefeat_clist{#1}\fi + \tl_set:Nn \l_fontspec_sizefeat_clist {#1} \zf@update@family{sizefeat:\zap@space #1~\@empty} } \define@key[zf]{sizing}{Size}{ \tl_set:Nn \l_fontspec_size_tl {#1} } @@ -1198,16 +1254,16 @@ \fontspec_info:n {set-scale} \group_end: } -\xetex_or_luatex:nnn { \cs_new:Npn \fontspec_set_font_dimen:NnN #1#2#3 } +\cs_new:Npn \fontspec_set_font_dimen:NnN #1#2#3 { \dim_set:Nn #1 { \fontdimen #2 #3 } -} -{ - \dim_set:Nn #1 { \directlua{ fontspec.get_dimen(#2, "\cs_to_str:N #3") } } \dim_compare:nNnT #1 = {0pt} { \settoheight #1 { \tl_if_eq:nnTF {#3} {\font} \rmfamily #3 - \prg_case_int:nnn #2 { 5 x 8 X } {?} + \prg_case_int:nnn #2 { + {5} {x} % x-height + {8} {X} % cap-height + } {?} % "else" clause; never reached. } } } @@ -1295,9 +1351,23 @@ \def\zf@check@one@char#1#2\zf@@{\def\@tempb{#2}} \define@key[zf]{options}{Color}{ \zf@update@family{+col:#1} - \zf@update@ff{color=#1} + \cs_if_exist:cTF {\token_to_str:N\color@#1} + { + \convertcolorspec{named}{#1}{HTML}\l_fontspec_hexcol_tl + } + { + \tl_set:Nn \l_fontspec_hexcol_tl {#1} + } } \keyval@alias@key[zf]{options}{Color}{Colour} +\newcounter{fontspec_tmp_int} +\define@key[zf]{options}{Opacity}{ + \zf@update@family{+opac:#1} + \setcounter {fontspec_tmp_int} { 255*\real{#1} } + \tl_set:Nx \l_fontspec_opacity_tl { + \nhex2 { \value{fontspec_tmp_int} } + } +} \xetex_or_luatex:nnn { \define@key[zf]{options}{Mapping} }{ @@ -1486,18 +1556,22 @@ \zf@define@feature@option{Fractions}{Diagonal} {11}{2}{} \zf@define@feature@option{Fractions}{Alternate}{} {} {+afrc} \define@key[zf]{options}{Alternate}[0]{ + \clist_set_eq:NN \l_fontspec_tmpa_clist \XKV@rm \setkeys*[zf@feat]{Alternate}{#1} \unless\ifx\XKV@rm\@empty \def\XKV@tfam{Alternate} \fontspec_make_feature:nnn{17}{#1}{+salt=#1} \fi + \clist_set_eq:NN \XKV@rm \l_fontspec_tmpa_clist } \define@key[zf]{options}{Variant}{ + \clist_set_eq:NN \l_fontspec_tmpa_clist \XKV@rm \setkeys*[zf@feat]{Variant}{#1} \unless\ifx\XKV@rm\@empty \def\XKV@tfam{Variant} - \fontspec_make_feature:nnn{18}{#1}{+ss\two@digits{#1}} + \fontspec_make_feature:nnx{18}{#1}{+ss\two@digits{#1}} \fi + \clist_set_eq:NN \XKV@rm \l_fontspec_tmpa_clist } \aliasfontfeature{Variant}{StylisticSet} \zf@define@font@feature{Style} @@ -1529,9 +1603,7 @@ \zf@define@feature@option{CharacterWidth}{AlternateProportional}{22}{5}{+palt} \zf@define@feature@option{CharacterWidth}{AlternateHalf}{22}{6}{+halt} \zf@define@feature@option{CharacterWidth}{Default}{22}{7}{} -\zf@define@font@feature{Annotation} -\zf@define@feature@option{Annotation}{Off}{24}{0}{-nalt} -\zf@define@feature@option{Annotation}{On}{}{}{+nalt} +\zf@define@feature@option{Annotation}{Off}{24}{0}{} \zf@define@feature@option{Annotation}{Box}{24}{1}{} \zf@define@feature@option{Annotation}{RoundedBox}{24}{2}{} \zf@define@feature@option{Annotation}{Circle}{24}{3}{} @@ -1543,6 +1615,15 @@ \zf@define@feature@option{Annotation}{BlackSquare}{24}{9}{} \zf@define@feature@option{Annotation}{BlackRoundSquare}{24}{10}{} \zf@define@feature@option{Annotation}{DoubleCircle}{24}{11}{} +\define@key[zf]{options}{Annotation}[0]{ + \clist_set_eq:NN \l_fontspec_tmpa_clist \XKV@rm + \setkeys*[zf@feat]{Annotation}{#1} + \unless\ifx\XKV@rm\@empty + \def\XKV@tfam{Alternate} + \fontspec_make_feature:nnn{}{}{+nalt=#1} + \fi + \clist_set_eq:NN \XKV@rm \l_fontspec_tmpa_clist +} \zf@define@font@feature{Vertical} \define@key[zf@feat]{Vertical}{RotatedGlyphs}[]{ \ifzf@icu |