[latex3-commits] [latex3/fontspec] l3color: check for xcolor and l3color names, WIP (7f61fa4)
github at latex-project.org
github at latex-project.org
Sat Nov 4 16:36:48 CET 2023
Repository : https://github.com/latex3/fontspec
On branch : l3color
Link : https://github.com/latex3/fontspec/commit/7f61fa413e97894a9fe7de07813809f49aa71428
>---------------------------------------------------------------
commit 7f61fa413e97894a9fe7de07813809f49aa71428
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sat Nov 4 16:36:48 2023 +0100
check for xcolor and l3color names, WIP
>---------------------------------------------------------------
7f61fa413e97894a9fe7de07813809f49aa71428
fontspec-code-keyval.dtx | 41 +++++++++++++++++++++++++++++++----------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git a/fontspec-code-keyval.dtx b/fontspec-code-keyval.dtx
index e4dc19f..84bb91a 100644
--- a/fontspec-code-keyval.dtx
+++ b/fontspec-code-keyval.dtx
@@ -697,30 +697,51 @@
% \end{macrocode}
%
% \paragraph{Color}
-% Hooks into pkg{xcolor}, which names its colours \texttt{\char`\\color@<name>}.
+% Test first if the color is a named l3color, then if it is a color from
+% \pkg{xcolor}, which names its colours \texttt{\char`\\color@<name>}.
+% If this fails the argument is assumed to be a hex color.
+%
% \begin{macrocode}
\@@_keys_define_code:nnn {fontspec} {Color}
{
%<*XE>
- \cs_if_exist:cTF { \token_to_str:N \color@ #1 }
+ \color_if_exist:nTF {#1}
{
- \convertcolorspec{named}{#1}{HTML}\l_@@_hexcol_tl
+ \color_export:nnN {#1} {HTML}\l_@@_hexcol_tl
}
{
- \int_compare:nTF { \tl_count:n {#1} == 6 }
- { \tl_set:Nn \l_@@_hexcol_tl {#1} }
+ \cs_if_exist:cTF { \token_to_str:N \color@ #1 }
+ {
+ \convertcolorspec{named}{#1}{HTML}\l_@@_hexcol_tl
+ }
{
- \int_compare:nTF { \tl_count:n {#1} == 8 }
- { \fontspec_parse_colour:viii #1 }
+ \int_compare:nTF { \tl_count:n {#1} == 6 }
+ { \tl_set:Nn \l_@@_hexcol_tl {#1} }
{
- \bool_if:NF \l_@@_firsttime_bool
- { \@@_warning:nx {bad-colour} {#1} }
+ \int_compare:nTF { \tl_count:n {#1} == 8 }
+ { \fontspec_parse_colour:viii #1 }
+ {
+ \bool_if:NF \l_@@_firsttime_bool
+ { \@@_warning:nx {bad-colour} {#1} }
+ }
}
}
}
%</XE>
%<*LU>
- \tl_set:Nn \l_@@_hexcol_tl {#1}
+ \color_if_exist:nTF {#1}
+ {
+ \tl_set:Nn \l_@@_hexcol_tl {#1}
+ }
+ {
+ \cs_if_exist:cTF { \token_to_str:N \color@ #1 }
+ {
+ \convertcolorspec{named}{#1}{HTML}\l_@@_hexcol_tl
+ }
+ {
+ \tl_set:Nn \l_@@_hexcol_tl {#1}
+ }
+ }
%</LU>
}
% \end{macrocode}
More information about the latex3-commits
mailing list.