Skip to content

Commit

Permalink
allow nested .fontspec files to specify a font name
Browse files Browse the repository at this point in the history
  • Loading branch information
wspr committed Jul 31, 2018
1 parent 5e100ee commit d108fdb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
24 changes: 22 additions & 2 deletions fontspec-doc-fontsel.tex
Expand Up @@ -207,7 +207,7 @@ \subsection{By custom file name}
This mechanism can be used to define custom names or aliases for your font collections.
The syntax within this file follows from the \cs{defaultfontfeatures}, defined in more detail later but mirroring the standard \pkg{fontspec} font loading syntax.
As an example, suppose we're defining a font family to be loaded with \verb|\setmainfont{My Charis}|.
The corresponding \texttt{MyCharis.fontspec} file would containing, say,
The corresponding \texttt{MyCharis.fontspec} file would contain, say,
\begin{Verbatim}
\defaultfontfeatures[My Charis]
{
Expand All @@ -227,8 +227,28 @@ \subsection{By custom file name}
\defaultfontfeatures[CharisSILR]{Color=blue}
\defaultfontfeatures[CharisSILB]{Color=red}
\end{Verbatim}
Such configuration lines could be stored either inline inside \texttt{My Charis.fontspec} or within their own \texttt{.fontspec} files; in this way, \pkg{fontspec} is designed to handle `nested' configuration options.
Such configuration lines could be stored either inline inside \texttt{My Charis.fontspec}
or within their own \texttt{.fontspec} files; in this way, \pkg{fontspec} is designed to
handle `nested' configuration options.

Where \cs{defaultfontfeatures} is being used to specify font faces by a custom name,
the \feat{Font} feature is used to set the filename of the font face. For example:
\begin{Verbatim}
\defaultfontfeatures[charis]
{
UprightFont = charis-regular,
% <other desired options for all font faces in the family>
}
\defaultfontfeatures[charis-regular]
{
Font = CharisSILR
% <other desired options just for the `upright' font>
}
\end{Verbatim}
The \pkg{fontspec} interface here is designed to be flexible to accomodate a variety
of use cases; there is more than one way to achieve the same outcome when font faces are
collected together into a larger font family.


\subsection{Querying whether a font `exists'}
Expand Down
9 changes: 9 additions & 0 deletions fontspec-internal.dtx
Expand Up @@ -676,10 +676,19 @@
\@@_load_external_fontoptions:Nn \l_fontspec_fontname_tl {#1}
\prop_get:NVNF \g_@@_fontopts_prop \l_fontspec_fontname_tl \l_@@_fontopts_clist
{ \clist_clear:N \l_@@_fontopts_clist }
\keys_set_groups:nnV {fontspec} {getfontname} \l_@@_fontopts_clist
\@@_primitive_font_set:Nnn \l_fontspec_font { \@@_construct_font_call:nn {\l_fontspec_fontname_tl} {} } {\f@size pt}
\@@_primitive_font_if_null:NT \l_fontspec_font { \@@_error:nx {font-not-found} {#1} }
}
% \end{macrocode}
%
% \begin{macrocode}
\keys_define:nn {fontspec}
{
Font .tl_set:N = \l_fontspec_fontname_tl ,
Font .groups:n = {getfontname} ,
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_declare_shape:nnnn}
Expand Down
4 changes: 0 additions & 4 deletions fontspec-keyval.dtx
Expand Up @@ -171,10 +171,6 @@
{
\fontspec_complete_fontname:Nn \l_@@_fontname_up_tl {#1}
}
\@@_keys_define_code:nnn {fontspec-preparse-external} {FontName}
{
\fontspec_complete_fontname:Nn \l_@@_fontname_up_tl {#1}
}
% \end{macrocode}
%
% \paragraph{Italic and slanted}
Expand Down

0 comments on commit d108fdb

Please sign in to comment.