LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bruno Le Floch <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Tue, 9 Jul 2013 22:25:14 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (43 lines)
Hi,

As you described, using a clist to store the set of available fonts
and using \str_case to provide the various codes is a bit error-prone,
and the correct structure is a property list matching directly each
font name to the corresponding code.

> \prop_new:N \g_jcs_fontcode_prop
>
> \prop_gput:Nnn \g_jcs_fontcode_prop { lmodern } {  }
>
> \bool_if:nT { \xetex_if_engine_p: || \luatex_if_engine_p: }
>   { \prop_gput:Nnn \g_jcs_fontcode_prop { fontin } {  } }

If you have many fonts, it makes sense to introduce a function that
puts code into the prop (that's a very simple wrapper, but helps to
see what you are doing).

    \prop_new:N \g_jcs_fontcode_prop
    \cs_new_protected:Npn \jcs_define_font:nn #1
      { \prop_gput:Nnn \g_ics_fontcode_prop {#1} }
    \jcs_define_font:nn { lmodern } {  }
    \bool_if:nT { \xetex_if_engine_p: || \luatex_if_engine_p: }
      { \jcs_define_font:nn { fontin } {  } }
    ...

The part of your code where you extract the code for the font and
store it in order to apply it after all options have been processed is
indeed the correct way to go.  However, since you are giving an
".initial:V" value which always sets \g_jcs_fontcode_tl at key
definition time, you can simplify the F branch of \prop_get:NnNTF as
follows

         \prop_get:NnNTF \g_jcs_fontcode_prop {#1} \l_jcs_fontcode_tl
           { \tl_gset_eq:NN \g_jcs_fontcode_tl \l_jcs_fontcode_tl }
           { \msg_warning:nnn { jcsres } { unknown-font-option } { #1 } }

> Does this begin to sound like the way forward?

Yes

Bruno

ATOM RSS1 RSS2