[latex3-commits] [git/LaTeX3-latex3-fontspec] variable: Add infrastructure for variable fonts (b66a05f)

Marcel Fabian Krüger tex at 2krueger.de
Mon May 23 23:32:35 CEST 2022


Repository : https://github.com/latex3/fontspec
On branch  : variable
Link       : https://github.com/latex3/fontspec/commit/b66a05f956420287337fd83692be84e13396e9f1

>---------------------------------------------------------------

commit b66a05f956420287337fd83692be84e13396e9f1
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Wed Aug 11 16:42:34 2021 +0200

    Add infrastructure for variable fonts


>---------------------------------------------------------------

b66a05f956420287337fd83692be84e13396e9f1
 fontspec-code-internal.dtx | 32 +++++++++++++++++++++++++++++---
 fontspec-code-opentype.dtx | 16 ++++++++++++++++
 fontspec-code-vars.dtx     |  2 ++
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/fontspec-code-internal.dtx b/fontspec-code-internal.dtx
index ee7e36c..86e2a4b 100644
--- a/fontspec-code-internal.dtx
+++ b/fontspec-code-internal.dtx
@@ -445,7 +445,7 @@
     \prop_gput:cnx {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {fontdef}
       {
         \@@_construct_font_call:nn {\l_fontspec_fontname_tl}
-          { \l_@@_pre_feat_sclist \g_@@_rawfeatures_sclist }
+          { \l_@@_pre_feat_sclist \g_@@_rawfeatures_sclist \@@_get_variations: }
       }
     \prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {script-num} \l_@@_script_int
     \prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {lang-num}   \l_@@_language_int
@@ -790,7 +790,7 @@
 %<debug>\typeout{====~Setup~NFSS~shape:~<\l_@@_size_tl>~\l_fontspec_fontname_tl}
 
     \@@_get_features:n { #2 , #3 , #4 }
-%<debug>\typeout{====~Gathered~features:~\g_@@_rawfeatures_sclist}
+%<debug>\typeout{====~Gathered~features:~\g_@@_rawfeatures_sclist \@@_get_variations:}
 
     \tl_if_empty:NF \l_@@_scale_tl
       {
@@ -801,7 +801,7 @@
       {
         <\l_@@_size_tl> \l_@@_scale_tl
         \@@_construct_font_call:nn { \l_fontspec_fontname_tl }
-          { \l_@@_pre_feat_sclist \g_@@_rawfeatures_sclist }
+          { \l_@@_pre_feat_sclist \g_@@_rawfeatures_sclist \@@_get_variations: }
       }
   }
 %    \end{macrocode}
@@ -1052,6 +1052,30 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_get_variations:}
+% \cmd{\@@_get_variations:} builds the feature string representing the
+% current variation instance and/or axis settings.
+%    \begin{macrocode}
+\cs_new:Nn \@@_format_axis:nn
+  {
+    #1 = #2 ,
+  }
+\cs_new:Nn \@@_get_variations:
+  {
+    \tl_if_empty:NF \g_@@_instance_tl
+      {
+        instance = { \g_@@_instance_tl };
+      }
+      \prop_if_empty:NF \g_@@_rawvariations_prop
+      {
+        axis = {
+          \prop_map_function:NN \g_@@_rawvariations_prop \@@_format_axis:nn
+        };
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Initialisation}
 %
 % \begin{macro}{\@@_init:}
@@ -1089,6 +1113,8 @@
 \cs_new:Nn \@@_init_fontface:
   {
     \tl_gclear:N \g_@@_rawfeatures_sclist
+    \prop_gclear:N \g_@@_rawvariations_prop
+    \tl_gclear:N \g_@@_instance_tl
     \tl_clear:N \l_@@_scale_tl
     \tl_set_eq:NN \l_@@_opacity_tl \c_@@_opacity_tl
     \tl_set_eq:NN \l_@@_hexcol_tl \c_@@_hexcol_tl
diff --git a/fontspec-code-opentype.dtx b/fontspec-code-opentype.dtx
index 94be4ac..7fabb1e 100644
--- a/fontspec-code-opentype.dtx
+++ b/fontspec-code-opentype.dtx
@@ -10,6 +10,22 @@
 %
 %
 %
+% \begin{macro}{\@@_define_opentype_variation_axis:nn}
+%    \begin{macrocode}
+\cs_new:Nn \@@_define_opentype_variation_axis:nn
+  {
+    \keys_define:nn {fontspec-opentype}
+      {
+        #1 .code:n = {
+          \prop_gput:Nnn \g_@@_rawvariations_prop { #2 } { ##1 }
+        },
+        #1 .value_required:n = true,
+        #1 .groups:n = {opentype},
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\@@_define_opentype_feature_group:n}
 %    \begin{macrocode}
 \cs_new:Nn \@@_define_opentype_feature_group:n
diff --git a/fontspec-code-vars.dtx b/fontspec-code-vars.dtx
index d247762..5f2df69 100644
--- a/fontspec-code-vars.dtx
+++ b/fontspec-code-vars.dtx
@@ -151,6 +151,7 @@
 \prop_new:N \g_@@_strong_prop
 \prop_new:N \g_@@_fontid_family_prop
 \prop_new:N \g_@@_family_int_prop
+\prop_new:N \g_@@_rawvariations_prop
 %    \end{macrocode}
 %
 % \paragraph{Token lists}
@@ -288,6 +289,7 @@
 \tl_new:N \l_@@_punctspace_adjust_tl
 \tl_new:N \l_@@_wordspace_adjust_tl
 \tl_new:N \l_@@_postadjust_tl
+\tl_new:N \g_@@_instance_tl
 %    \end{macrocode}
 %
 %    \begin{macrocode}





More information about the latex3-commits mailing list.