summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/optex/base/fonts-resize.opm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/optex/base/fonts-resize.opm')
-rw-r--r--Master/texmf-dist/tex/optex/base/fonts-resize.opm72
1 files changed, 52 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/optex/base/fonts-resize.opm b/Master/texmf-dist/tex/optex/base/fonts-resize.opm
index e49303f3775..34885d44bd7 100644
--- a/Master/texmf-dist/tex/optex/base/fonts-resize.opm
+++ b/Master/texmf-dist/tex/optex/base/fonts-resize.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \setfontsize {Font resizing macros <2022-02-22>} % preloaded in format
+\_codedecl \setfontsize {Font resizing macros <2022-11-08>} % preloaded in format
\_doc -----------------------------
\`\initunifonts` macro extends \LuaTeX's font capabilities,
@@ -10,19 +10,22 @@
from \LaTeX's `luatexbase` namespace, we provide our own replacements.
\^`\initunifonts` sets itself to relax because we don't want to do
this work twice.
+ \`\ufont` is a shortcut of \^`\initunifonts`~`\font`.
\_cod -----------------------------
-\_def\_initunifonts {%
+\_protected\_def \_initunifonts {%
\_directlua{%
require('luaotfload-main')
luaotfload.main()
- optex_hook_into_luaotfload()
+ optex.hook_into_luaotfload()
}%
\_glet \_fmodtt=\_unifmodtt % use \_ttunifont for \tt
\_glet \_initunifonts=\_relax % we need not to do this work twice
\_glet \initunifonts=\_relax
}
-\_public \initunifonts ;
+\_protected\_def \_ufont {\_initunifonts \_font}
+
+\_public \initunifonts \ufont ;
\_doc -----------------------------
The \`\setfontsize` `{<size spec>}` saves the `<size spec>` to the \`\_sizespec` macro.
@@ -74,7 +77,8 @@
Note, that the `\_xfontname` output is converted due to optical size data using `\_optfn`.
\_cod -----------------------------
-\_def\_fontlet#1#2{\_ifx #2=\_ea\_fontlet \_ea#1\_else \_font #1{\_optfn{\_xfontname#2}}\_fi}
+\_protected\_def \_fontlet #1#2{\_ifx #2=\_ea\_fontlet \_ea#1\_else
+ \_ea\_font \_ea#1\_expanded{{\_optfn{\_xfontname#2}}}\_fi}
\_public \xfontname \fontlet ;
\_doc -----------------------------
@@ -83,17 +87,21 @@
It changes the current font at the given <size spec>.
\nl
\`\resizethefont` is implemented by \^`\newcurrfontsize` using data from
- the \^`\_sizespec` macro.
+ the \^`\_sizespec` macro.\nl
+ \`\sfont` has the same syntax like `\font` primitive, but declares a
+ macro which selects the font and sets its size properly dependent on the
+ current size.
\_cod -----------------------------
-\_def \_newcurrfontsize #1{% \newcurrfontsize{at25pt}
- \_ea\_def \_ea\_tmp \_ea{\_csname \_ea\_csstring \_the\_font \_endcsname}%
- \_ea\_fontlet \_tmp \_font #1\_relax
- \_ea\_fontloaded \_tmp
- \_tmp
+% \newcurrfontsize{at25pt}
+\_def \_newcurrfontsize {\_ea\_newcurrfontsizeA \_csname \_ea\_csstring \_the\_font \_endcsname}
+\_def \_newcurrfontsizeA #1#2{\_fontlet #1\_font #2\_relax \_fontloaded#1#1}
+\_protected\_def \_resizethefont {\_newcurrfontsize\_sizespec}
+\_protected\_def \_sfont #1{%
+ \_protected\_edef #1{\_csname _sfont:\_csstring#1\_endcsname \_resizethefont}%
+ \_initunifonts \_ea\_font \_csname _sfont:\_csstring#1\_endcsname
}
-\_protected\_def \_resizethefont{\_newcurrfontsize\_sizespec}
-\_public \newcurrfontsize \resizethefont ;
+\_public \newcurrfontsize \resizethefont \sfont ;
\_doc -----------------------------
The \`\_regtfm` `<font id> <optical size data>`
@@ -169,7 +177,8 @@ The <size spec> can be empty or `at<dimen>` or `scaled<scale factor>`. The
\OpTeX/ starts with `\font` primitive which is able to read only `tfm` files.
i.e.\ the `<font file name>.tfm` (and additional data for glyphs)
must be correctly installed in your system. If you want to load
-OpenType `otf` or `ttf` font files, use the declarator \^`\initunifonts`.
+OpenType `otf` or `ttf` font files, use the declarator \^`\initunifonts`
+before first `\font` primitive.
This command adds additional features to the `\font` primitive which
gives the extended syntax:
\begtt \catcode`\<=13
@@ -193,8 +202,9 @@ The original syntax for `tfm` files is also available. Example:
primitive from `luaotfload` package. More information is available
in the `luaotfload-latex.pdf` file.
-Note, that \^`\fontfam` does (among other things) \^`\initunifonts`
-internally. You need not to specify it if \^`\fontfam` is used.
+You can use \^`\ufont` macro which runs \^`\initunifonts` followed by `\font`
+primitive. And \^`\fontfam` does (among other things) \^`\initunifonts`
+too. You need not to specify \^`\initunifonts` if \^`\fontfam` or \^`\ufont` is used.
It seems that you must decide about final size of the font before it is
loaded by the `\font` primitive. It is not exactly true; \OpTeX/ offers
@@ -245,8 +255,7 @@ The \^`\resizethefont` works with arbitrary current font, for example with the
font loaded directly by `\font` primitive. For example:
\begtt
-\initunifonts
-\font\tencrimson=[Crimson-Roman]:+onum % font Crimson-Regular at 10 pt is loaded
+\ufont\tencrimson=[Crimson-Roman]:+onum % font Crimson-Regular at 10 pt is loaded
\def\crimson{\tencrimson\resizethefont} % \crimson uses the font size on demand
\crimson The 10 pt text is here.
@@ -258,6 +267,26 @@ behaves like variant selector in the Font Selection System (section~\ref[fontsys
It takes only information about size from the font context, but it is
sufficient. You can use it in titles, footnotes, etc. The font size
depending on surrounding size is automatically selected.
+There is a shortcut \^`\sfont` with the same syntax like `\font` primitive,
+it declares a macro which selects the font and does resizing depending on
+the current size. So, the example above can be realized by
+`\sfont\crimson=[Crimson-Roman]:+onum`.
+
+\secc The `\font`-like commands summary
+
+\begitems
+* `\font` is \TeX/ primitive. When \OpTeX/ starts, then it accepts only
+ classical \TeX/ syntax and doesn't allow to load Unicode fonts.
+ Once \^`\initunifonts` (or \^`\fontfam`) is used, the `\font` primitive is
+ re-initialized: now it accepts extended syntax and it is able to load Unicode
+ OpenType fonts.
+* \^`\ufont` is a shortcut of `\initunifonts \font`. I.e.\ it behaves like
+ `\font` and accepts extended syntax immediatelly.
+* \^`\sfont` has syntax like extended `\font`. It declares a macro which
+ selects the given font and resizes it to the current size (given by
+ \^`\setfontsize`). In various part of document (text, footnotes, titles), the
+ size of this font is selected by the declared macro properly.
+\enditems
\secc[fontlet] The \code{\\fontlet} declarator
@@ -288,13 +317,13 @@ able to choose right file if various optical sizes and corresponding file
names are declared for the font by \^`\_regtfm` or \^`\_regoptsizes` command.
The command \^`\setfontsize` sets the internal reuirements for
optical size if the parameter is in the format `at<dimen>` or `mag<factor>`.
-Then the command \^`\resizethefont` or variant selectors try to choose
+Then the command \^`\resizethefont` or \^`\fontlet` or variant selectors try to choose
the font suitable for the required optical size. For example
\begtt
\fontfam[lm]
The text is printed in font [lmroman10-regular] at 10 pt.
\setfontsize{at13pt}\rm
- Now in the text is printed in [lmroman12-regular] at 13 pt.
+ Now, the text is printed in [lmroman12-regular] at 13 pt.
\endtt
See also section~\ref[optsizes].
@@ -322,6 +351,9 @@ Luaotfload documentation for more information.
\_endinput
+2022-11-08 \sfont introduced, \protected: \initunifont, \ufont, \fontlet
+2022-11-07 \fontlet \a\a: bug fixed
+2022-10-14 \ufont introduced
2022-02-22 Font Selection System reimplemented, \fontsel introduced
2021-05-02 better concept of doc, moving parts to fonts-select
2021-04-17 \_fontloaded, \_newfontloaded introduced