| 1 |
%%^^A%% fontspec-code-fontload.dtx -- part of FONTSPEC <latex3.github.io/fontspec> |
| 2 |
|
| 3 |
% \section{expl3 interface for primitive font loading} |
| 4 |
% |
| 5 |
% \begin{function}{\@@_primitive_font_set:Nnn,\@@_primitive_font_gset:Nnn} |
| 6 |
% \begin{syntax} |
| 7 |
% |\@@_primitive_font_set:Nnn| \meta{font cs} \Arg{file/name} \Arg{size (dim.\ expr)} |
| 8 |
% \end{syntax} |
| 9 |
% Wrapper around \TeX\ \cs{font} primitive. |
| 10 |
% \end{function} |
| 11 |
% |
| 12 |
% \begin{function}{\@@_font_suppress_not_found_error:} |
| 13 |
% Wrapper around \XeTeX\/Lua\TeX\ primitive, used to be able to programmatically query font existence. |
| 14 |
% \end{function} |
| 15 |
% |
| 16 |
% \begin{function}[pTF]{\@@_primitive_font_if_null:N} |
| 17 |
% \begin{syntax} |
| 18 |
% |\@@_primitive_font_if_null:NTF| \meta{font cs} \Arg{true code} \Arg{false code} |
| 19 |
% \end{syntax} |
| 20 |
% Query whether the \meta{font cs} is the \cs{nullfont}. |
| 21 |
% \end{function} |
| 22 |
% |
| 23 |
% \begin{function}[TF]{\@@_primitive_font_set:Nnn,\@@_primitive_font_gset:Nnn} |
| 24 |
% \begin{syntax} |
| 25 |
% |\@@_primitive_font_set:NnnTF| \meta{font cs} \Arg{file/name} \Arg{size (dim.\ expr)} \Arg{true code} \Arg{false code} |
| 26 |
% \end{syntax} |
| 27 |
% Attempts to set the \meta{font cs} and provide branching for success or failure according to whether the font exists. |
| 28 |
% \end{function} |
| 29 |
% |
| 30 |
% \begin{function}[TF]{\@@_primitive_font_if_exist:n} |
| 31 |
% \begin{syntax} |
| 32 |
% |\@@_primitive_font_if_exist:nTF| \Arg{file/name} \Arg{true code} \Arg{false code} |
| 33 |
% \end{syntax} |
| 34 |
% Attempts to load the font at the current font size minus 1\,sp with a dummy meta{font cs} |
| 35 |
% (\verb|\l_@@_primitive_font|), and branches according to whether the font exists. |
| 36 |
% This is intended to be used speculatively before potentially performing additional processing |
| 37 |
% steps (e.g., an analysis of available font features) before setting up the `true' font. |
| 38 |
% \end{function} |
| 39 |
% |
| 40 |
% \begin{function}[pTF]{\@@_primitive_font_glyph_if_exist:Nn} |
| 41 |
% \begin{syntax} |
| 42 |
% |\@@_primitive_font_glyph_if_exist:nTF| \meta{font cs} \Arg{char. number (int.\ expr)} \Arg{true code} \Arg{false code} |
| 43 |
% \end{syntax} |
| 44 |
% Wrapper around primitive \cs{iffontchar}. |
| 45 |
% \end{function} |
| 46 |
% |
| 47 |
% \begin{function}{\@@_primitive_font_set_hyphenchar:Nn} |
| 48 |
% \begin{syntax} |
| 49 |
% |\@@_primitive_font_set_hyphenchar:Nn| \meta{font cs} \Arg{char. number (int.\ expr)} |
| 50 |
% \end{syntax} |
| 51 |
% Setter function around primitive \cs{hyphenchar}. |
| 52 |
% \end{function} |
| 53 |
% |
| 54 |
% \begin{function}{\@@_primitive_font_get_name:N,\@@_primitive_font_current_name:} |
| 55 |
% \begin{syntax} |
| 56 |
% |\@@_primitive_font_get_name:N| \meta{font cs} |
| 57 |
% \end{syntax} |
| 58 |
% Wrapper function around \TeX\ primitive \cs{fontname}. The no-argument version is |
| 59 |
% equivalent to \verb|\fontname\font|. |
| 60 |
% \end{function} |
| 61 |
% |
| 62 |
% \section{Implementation} |
| 63 |
% |
| 64 |
% \iffalse |
| 65 |
% \begin{macrocode} |
| 66 |
%<*fontspec> |
| 67 |
% \end{macrocode} |
| 68 |
% \fi |
| 69 |
% |
| 70 |
% \begin{macro}{\@@_primitive_font_set:Nnn,\@@_primitive_font_gset:Nnn} |
| 71 |
% \begin{macrocode} |
| 72 |
\cs_set:Npn \@@_primitive_font_set:Nnn #1#2#3 |
| 73 |
{ |
| 74 |
\font #1 = #2 ~at~ \dim_eval:n {#3} \scan_stop: |
| 75 |
} |
| 76 |
% \end{macrocode} |
| 77 |
% \begin{macrocode} |
| 78 |
\cs_set:Npn \@@_primitive_font_gset:Nnn #1#2#3 |
| 79 |
{ |
| 80 |
\global \font #1 = #2 ~at~ \dim_eval:n {#3} \scan_stop: |
| 81 |
} |
| 82 |
% \end{macrocode} |
| 83 |
% \end{macro} |
| 84 |
% |
| 85 |
% \begin{macro}{\@@_font_suppress_not_found_error:} |
| 86 |
% \begin{macrocode} |
| 87 |
\cs_set:Npn \@@_font_suppress_not_found_error: |
| 88 |
{ |
| 89 |
\int_set:Nn \suppressfontnotfounderror {1} |
| 90 |
} |
| 91 |
% \end{macrocode} |
| 92 |
% \end{macro} |
| 93 |
% |
| 94 |
% \begin{macro}[pTF]{\@@_primitive_font_if_null:N} |
| 95 |
% \begin{macrocode} |
| 96 |
\prg_new_conditional:Nnn \@@_primitive_font_if_null:N {p,TF,T,F} |
| 97 |
{ |
| 98 |
\ifx #1 \nullfont |
| 99 |
\prg_return_true: |
| 100 |
\else |
| 101 |
\prg_return_false: |
| 102 |
\fi |
| 103 |
} |
| 104 |
% \end{macrocode} |
| 105 |
% \end{macro} |
| 106 |
% |
| 107 |
% \begin{macro}[TF]{\@@_primitive_font_set:Nnn,\@@_primitive_font_gset:Nnn} |
| 108 |
% \begin{macrocode} |
| 109 |
\prg_new_conditional:Nnn \@@_primitive_font_set:Nnn {TF,T,F} |
| 110 |
{ |
| 111 |
\@@_primitive_font_set:Nnn #1 {#2} {#3} |
| 112 |
\@@_primitive_font_if_null:NTF #1 {\prg_return_false:} {\prg_return_true:} |
| 113 |
} |
| 114 |
\prg_new_conditional:Nnn \@@_primitive_font_gset:Nnn {TF,T,F} |
| 115 |
{ |
| 116 |
\@@_primitive_font_gset:Nnn #1 {#2} {#3} |
| 117 |
\@@_primitive_font_if_null:NTF #1 {\prg_return_false:} {\prg_return_true:} |
| 118 |
} |
| 119 |
\cs_set:Npn \@@_primitive_font_set:Onn { \exp_last_unbraced:No \@@_primitive_font_set:Nnn } |
| 120 |
\cs_set:Npn \@@_primitive_font_set:OnnF { \exp_last_unbraced:No \@@_primitive_font_set:NnnF } |
| 121 |
\cs_set:Npn \@@_primitive_font_gset:Onn { \exp_last_unbraced:No \@@_primitive_font_gset:Nnn } |
| 122 |
\cs_set:Npn \@@_primitive_font_gset:OnnF { \exp_last_unbraced:No \@@_primitive_font_gset:NnnF } |
| 123 |
% \end{macrocode} |
| 124 |
% \end{macro} |
| 125 |
% |
| 126 |
% \begin{macro}[TF]{\@@_primitive_font_if_exist:n} |
| 127 |
% \begin{macrocode} |
| 128 |
\prg_new_conditional:Nnn \@@_primitive_font_if_exist:n {TF,T,F} |
| 129 |
{ |
| 130 |
\group_begin: |
| 131 |
\@@_font_suppress_not_found_error: |
| 132 |
\@@_primitive_font_set:Nnn \l_@@_primitive_font {#1} { \f@size pt - 1sp } |
| 133 |
\@@_primitive_font_if_null:NTF \l_@@_primitive_font |
| 134 |
{ \group_end: \prg_return_false: } |
| 135 |
{ \group_end: \prg_return_true: } |
| 136 |
} |
| 137 |
% \end{macrocode} |
| 138 |
% \end{macro} |
| 139 |
% |
| 140 |
% \begin{macro}[pTF]{\@@_primitive_font_glyph_if_exist:Nn} |
| 141 |
% \begin{macrocode} |
| 142 |
\prg_new_conditional:Nnn \@@_primitive_font_glyph_if_exist:Nn {p,TF,T,F} |
| 143 |
{ |
| 144 |
\tex_iffontchar:D #1 \int_eval:n {#2} \scan_stop: |
| 145 |
\prg_return_true: |
| 146 |
\else: |
| 147 |
\prg_return_false: |
| 148 |
\fi: |
| 149 |
} |
| 150 |
% \end{macrocode} |
| 151 |
% \end{macro} |
| 152 |
% |
| 153 |
% \begin{macro}{\@@_primitive_font_set_hyphenchar:Nn} |
| 154 |
% \begin{macrocode} |
| 155 |
\cs_new:Nn \@@_primitive_font_set_hyphenchar:Nn |
| 156 |
{ |
| 157 |
\tex_hyphenchar:D #1 = \int_eval:n {#2} \scan_stop: |
| 158 |
} |
| 159 |
% \end{macrocode} |
| 160 |
% \end{macro} |
| 161 |
% |
| 162 |
% \begin{macro}{\@@_primitive_font_get_name:N} |
| 163 |
% \begin{macro}{\@@_primitive_font_current_name:} |
| 164 |
% \begin{macrocode} |
| 165 |
\cs_new_eq:NN \@@_primitive_font_get_name:N \fontname |
| 166 |
\cs_new:Npn \@@_primitive_font_current_name: |
| 167 |
{ |
| 168 |
\@@_primitive_font_get_name:N \tex_font:D |
| 169 |
} |
| 170 |
% \end{macrocode} |
| 171 |
% \end{macro} |
| 172 |
% \end{macro} |
| 173 |
% |
| 174 |
% \iffalse |
| 175 |
% \begin{macrocode} |
| 176 |
%</fontspec> |
| 177 |
% \end{macrocode} |
| 178 |
% \fi |
| 179 |
|
| 180 |
\endinput |
| 181 |
|
| 182 |
% /© |
| 183 |
% ------------------------------------------------ |
| 184 |
% The FONTSPEC package <latex3.github.io/fontspec> |
| 185 |
% ------------------------------------------------ |
| 186 |
% Copyright 2022-2025 The LaTeX project, LPPL "maintainer" |
| 187 |
% Copyright 2004-2022 Will Robertson |
| 188 |
% Copyright 2009-2015 Khaled Hosny |
| 189 |
% Copyright 2013 Philipp Gesang |
| 190 |
% Copyright 2013-2016 Joseph Wright |
| 191 |
% ------------------------------------------------ |
| 192 |
% This package is free software and may be redistributed and/or modified under |
| 193 |
% the conditions of the LaTeX Project Public License, version 1.3c or higher |
| 194 |
% (your choice): <http://www.latex-project.org/lppl/>. |
| 195 |
% ------------------------------------------------ |
| 196 |
% ©/ |