Skip to content

Commit

Permalink
check for xcolor and l3color names, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Nov 4, 2023
1 parent ca5dd83 commit 7f61fa4
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions fontspec-code-keyval.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 7f61fa4

Please sign in to comment.