From 324a2262e8dc03ec5a2252d7fbcd7c8b702bb4d3 Mon Sep 17 00:00:00 2001 From: Will Robertson Date: Sun, 21 Apr 2024 00:50:07 +0930 Subject: [PATCH] plan with scripts needed tweaking for test suite to pass --- fontspec-code-feat-opentype.dtx | 50 ++++++++++++++++++++++++++++++-- fontspec-code-opentype.dtx | 2 +- fontspec-code-vars.dtx | 2 +- testfiles/script-lang.luatex.tlg | 2 +- testfiles/script-lang.tlg | 2 +- 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/fontspec-code-feat-opentype.dtx b/fontspec-code-feat-opentype.dtx index deec25f..39de58d 100644 --- a/fontspec-code-feat-opentype.dtx +++ b/fontspec-code-feat-opentype.dtx @@ -470,14 +470,16 @@ \clist_map_break: } } - +% \end{macrocode} +% If not found give a warning but load it anyway: +% \begin{macrocode} \bool_if:NF \l_@@_scriptlang_exist_bool { %\typeout{Script~not~found!} \@@_warning:nxx {no-script} {\l_fontspec_fontname_tl} {#1} \clist_set:Nn \l_tmpa_clist {#2} \clist_get:NN \l_tmpa_clist \l_@@_script_tl - \exp_args:Noo \@@_check_script:NnT \l_@@_fontface_cs_tl \l_@@_script_tl + \exp_args:Noo \@@_check_script:NnF \l_@@_fontface_cs_tl \l_@@_script_tl { \tl_set:Nn \l_@@_script_name_tl {#1} \int_set:Nn \l_@@_script_int {\l_@@_strnum_int} @@ -487,6 +489,37 @@ } } } +\cs_new:Nn \fontspec_default_script:nn + { + \keys_define:nn {fontspec-opentype} { Script / #1 .code:n = + { +%\typeout{Trying~[Script=#1:#2]} + \bool_set_false:N \l_@@_scriptlang_exist_bool + \clist_map_inline:nn {#2} + { + \exp_args:No \@@_check_script:NnT \l_@@_fontface_cs_tl {####1} + { +%\typeout{Script~tag~found:~####1} + \tl_set:Nn \l_@@_script_name_tl {#1} + \tl_set:Nn \l_@@_script_tl {####1} + \int_set:Nn \l_@@_script_int {\l_@@_strnum_int} + \bool_set_true:N \l_@@_scriptlang_exist_bool + \tl_gset:Nx \g_@@_single_feat_tl { script=####1 } + \clist_map_break: + } + } + \bool_if:NF \l_@@_scriptlang_exist_bool + { +%\typeout{Script~not~found!} + \tl_clear:Nn \l_@@_script_name_tl + } + } + } + } +% \end{macrocode} +% When script is not explicitly requested, use this list: +% \begin{macrocode} +\fontspec_default_script:nn {CustomDefault} {latn,DFLT} % \end{macrocode} % % @@ -514,10 +547,21 @@ \clist_map_break: } } +% \end{macrocode} +% If not found give a warning but load it anyway: +% \begin{macrocode} \bool_if:NF \l_@@_scriptlang_exist_bool { +%\typeout{Lang~not~found!} \@@_warning:nx {language-not-exist} {#1} - \keys_set:nn {fontspec-opentype} { Language = Default } + \clist_set:Nn \l_tmpa_clist {#2} + \clist_get:NN \l_tmpa_clist \l_@@_lang_tl + \exp_args:Noo \@@_check_script:NnF \l_@@_fontface_cs_tl \l_@@_script_tl + { + \tl_set:Nn \l_@@_script_name_tl {#1} + \int_set:Nn \l_@@_language_int {\l_@@_strnum_int} + \tl_gset:Nx \g_@@_single_feat_tl { language=####1 } + } } } } diff --git a/fontspec-code-opentype.dtx b/fontspec-code-opentype.dtx index f80111f..5a38be8 100644 --- a/fontspec-code-opentype.dtx +++ b/fontspec-code-opentype.dtx @@ -159,7 +159,7 @@ % font. \cmd\l_@@_script_int\ is used to store % the number corresponding to the script tag string. % \begin{macrocode} -\prg_new_conditional:Nnn \@@_check_script:Nn {TF,T} +\prg_new_conditional:Nnn \@@_check_script:Nn {TF,T,F} { %\typeout{:: _check_script:Nn~#1~/~#2} \bool_if:NTF \l_@@_never_check_bool diff --git a/fontspec-code-vars.dtx b/fontspec-code-vars.dtx index 1f7ee82..c2be037 100644 --- a/fontspec-code-vars.dtx +++ b/fontspec-code-vars.dtx @@ -273,7 +273,7 @@ % \begin{macrocode} \tl_new:N \l_@@_script_tl \tl_new:N \l_@@_script_name_tl -\tl_set:Nn \l_@@_script_name_tl {Default} +\tl_set:Nn \l_@@_script_name_tl {CustomDefault} % \end{macrocode} % % \begin{macrocode} diff --git a/testfiles/script-lang.luatex.tlg b/testfiles/script-lang.luatex.tlg index c3ab1d5..d9779af 100644 --- a/testfiles/script-lang.luatex.tlg +++ b/testfiles/script-lang.luatex.tlg @@ -11,6 +11,6 @@ TU/texgyrepagella-regular.otf(2)/m/n: [texgyrepagella-regular.otf]:mode=node;script=latn;language=ROM;+tlig; LANG DFLT TU/texgyrepagella-regular.otf(3)/m/n: - [texgyrepagella-regular.otf]:mode=node;script=cyrl;language=dflt;+tlig; + [texgyrepagella-regular.otf]:mode=node;script=cyrl;language=ROM;+tlig; *************** Compilation 1 of test file completed with exit status 0 diff --git a/testfiles/script-lang.tlg b/testfiles/script-lang.tlg index a198435..322c5f3 100644 --- a/testfiles/script-lang.tlg +++ b/testfiles/script-lang.tlg @@ -11,6 +11,6 @@ TU/texgyrepagella-regular.otf(2)/m/n: "[texgyrepagella-regular.otf]/OT:script=latn;language=ROM;mapping=tex-text;" at 10.0pt LANG DFLT TU/texgyrepagella-regular.otf(3)/m/n: - "[texgyrepagella-regular.otf]/OT:script=cyrl;language=dflt;mapping=tex-text;" at 10.0pt + "[texgyrepagella-regular.otf]/OT:script=cyrl;language=ROM;mapping=tex-text;" at 10.0pt *************** Compilation 1 of test file completed with exit status 0