Skip to content

Commit

Permalink
Revised options for SizeFeatures--see package doc for details.
Browse files Browse the repository at this point in the history
  • Loading branch information
psb1558 committed Dec 30, 2023
1 parent 6d0f32e commit d282d2c
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 84 deletions.
Binary file modified TeX/elstob-package.pdf
Binary file not shown.
104 changes: 53 additions & 51 deletions TeX/elstob-package.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

\usepackage[
weightadjustment=-50,opticalsizeadjustment=-2,slant=12,
MainFeatures={StylisticSet=3,Numbers=Monospaced}
MainFeatures={StylisticSet=3},
]{elstob}

\setfontface\samplefootnote{Elstob}[
Renderer = HarfBuzz,
SizeFeatures = {{Size={5-}, RawFeature={axis={wght=490,opsz=6}}}},
SizeFeatures = {{Size={5-}, RawFeature={axis={wght=460,opsz=6}}}},
]
\setfontface\sampleheader{Elstob}[
Renderer = HarfBuzz,
Expand Down Expand Up @@ -68,8 +68,9 @@ \section{Introduction}
\textbf{Weight} (Light, Bold, etc.) and \textbf{Width} (Condensed, Expanded). A traditional
“static” font family also has axes, but as every style requires a separate font file,
the number of available styles is severely constrained. A variable font, by contrast,
offers a practically limitless number of styles in a single file: you select from these styles
by making a selection of number values from the axes, of which Elstob has four (five in the italic):
offers a practically limitless number of styles in a single file: you choose a style
by making a selection of number values (usually called “coordinates”) from the axes,
of which Elstob has four (five in the italic):

\begin{description}
\item[Weight] Possible weights run from ExtraLight (200) to ExtraBold (800). By
Expand Down Expand Up @@ -179,64 +180,69 @@ \section{Customizing the Main Font}

\noindent If you want to use these conventions only for italic text, use
\textbf{MainItalicFeatures} instead of \textbf{MainFeatures}. All of the
features you pass via these options must be valid for \fspec: indeed,
features you pass via these options must be valid for \fspec: in fact,
they are passed straight through to \fspec.

If you want to customize the four basic styles of the main text, use
\textbf{MainRegularSizeFeatures}, \textbf{MainItalicSizeFeatures}, and so on.
For example, here are the \textbf{SizeFeatures} for an early version of
this document (they were used to test these features):
Each of these defines a list of associative arrays, in which each array in the
list prescribes axis coordinates for a range of sizes.
For example, here is a hypothetical set of \textbf{SizeFeatures}:

\footnotesize
\begin{verbatim}
MainRegularSizeFeatures={
SizeFeatures={
{Size={-10},
RawFeature={axis={wght=450,opsz=8}}},
{Size={10-13},
RawFeature={axis={wght=370,opsz=10}}},
{Size={13-},
RawFeature={axis={wght=350,opsz=16}}}
}
{size=10,wght=380,opsz=8},
{size=13,wght=370,opsz=10},
{size=13,wght=350,opsz=16}
},
MainItalicSizeFeatures={
SizeFeatures={
{Size={-10},
RawFeature={axis={wght=450,opsz=8,slnt=12}}},
{Size={10-13},
RawFeature={axis={wght=370,opsz=10,slnt=12}}},
{Size={13-},
RawFeature={axis={wght=350,opsz=16,slnt=12}}}
}
{size=10,wght=380,opsz=8,slnt=12},
{size=13,wght=370,opsz=10,slnt=12},
{size=13,wght=350,opsz=16,slnt=12}
},
MainBoldSizeFeatures={
SizeFeatures={
{Size={-10},
RawFeature={axis={wght=650,opsz=8}}},
{Size={10-13},
RawFeature={axis={wght=600,opsz=10}}},
{Size={13-},
RawFeature={axis={wght=5700,opsz=16}}}
}
{size=10,wght=620,opsz=8},
{size=13,wght=600,opsz=10},
{size=13,wght=700,opsz=16}
},
MainBoldItalicSizeFeatures={
SizeFeatures={
{Size={-10},
RawFeature={axis={wght=650,opsz=8,slnt=12}}},
{Size={10-13},
RawFeature={axis={wght=600,opsz=10,slnt=12}}},
{Size={13-},
RawFeature={axis={wght=5700,opsz=16,slnt=12}}}
}
{size=10,wght=620,opsz=8,slnt=12},
{size=13,wght=600,opsz=10,slnt=12},
{size=13,wght=700,opsz=16,slnt=12}
}
\end{verbatim}\normalsize

\noindent Because there's no way to know in advance what and how many sizes of type a document
will use, the Elstob package defines thirteen size-ranges. Here, however, we
need only three---for footnotes (less than 10pt),
main text (10-13pt), and headers (greater than 13pt). For each of these sizes, the
weight is a little lighter than the default, and the optical size a little less, giving
the page an open look. \textit{Italic type is relatively upright}.
\noindent For each array, a \src{size} key is mandatory: any array without one
is ignored. The arrays should be in order of point size. The first array
prescribes axis coordinates for all sizes up to \src{size}, the last array for all sizes
greater than \src{size}, and any intermediate items a range from the previous to the
current \src{size}.\footnote{%
If you want only one size array, make \src{size} improbably low (e.g. 5) and place
a comma after the closing brace of the array.%
} So the ranges covered in each list above are \src{-10}, \src{10-13},
and \src{13-}.\footnote{Any modification of the default text size (e.g. in the
\src{\textbackslash documentclass} command) can affect the size definitions in these
arrays, with the result that (for example)
\src{10} no longer means exactly “ten points.” You may have to experiment to get these numbers
right.}

The keys other than \src{size} are the four-letter tags for the font's axes: \src{wght}
(Weight), \src{opsz} (Optical Size), \src{slnt} (Slant, italic only), \src{GRAD} (Grade),
and \src{SPAC} (Spacing).\footnote{%
By convention, tags for axes defined in the OpenType standard are lowercase; custom axes
are uppercase. Elstob’s \src{GRAD} and \src{SPAC} are custom axes.%
} When a key
is omitted, the default value for that axis is used. It is up to you to make sure the values
given for each axis are valid---the package does no checking (but {\fspec} will do a good bit
of checking for you). When SizeFeatures are given in
this way, they override any other options that set or change axis coordinates
(e.g. \textbf{weightadjustment}).

This example defines three sizes, since the (hypothetical) document in question uses
only three sizes of type---for footnotes, main text, and headers. For each of these sizes, the
weight is a little lighter than the default of 400, and the optical size a little less, giving
the page a slightly more spacious look than the default. \textit{Italic type is relatively upright}.

\section{Selecting Alternate Styles}

Expand Down Expand Up @@ -356,11 +362,7 @@ \section{Selecting Alternate Styles}
Language=English,
StylisticSet=2
},
EightPtSemiboldSizeFeatures={
SizeFeatures={
Size={5-},RawFeature={axis={wght=620,opsz=8.5}}
}
}
EightPtSemiboldSizeFeatures={{size=5,wght=650,opsz=8.5},}
]{elstob}
\end{verbatim}\normalsize

Expand All @@ -376,7 +378,7 @@ \section{Other Commands}
mnemonic than the {\fspec} commands they invoke (though of course all {\fspec} commands
remain available). Each of these commands
also has a corresponding “text” command that works like
{\verb|\textit{}|}—that is, it takes
{\color{BrickRed}\verb|\textit{}|}—that is, it takes
as its sole argument the text to which the command will be applied. Each “text” command
consists of the main command with “text” prefixed—for example,
{\color{BrickRed}\verb|\textInsularLetterForms{}|}
Expand Down
82 changes: 68 additions & 14 deletions TeX/elstob.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@

-- 1. Reg 2. Light 3. Medium 4. ExtraLight
regular_weights = {
elstob_at_RwghtOne = { 490, 390, 560, 290 },
elstob_at_IwghtOne = { 490, 390, 560, 290 },
elstob_at_RwghtTwo = { 477.5, 377.5, 550, 277.5 },
elstob_at_IwghtTwo = { 477.5, 377.5, 550, 277.5 },
elstob_at_RwghtThree = { 465, 365, 540, 265 },
elstob_at_IwghtThree = { 465, 365, 540, 265 },
elstob_at_RwghtFour = { 452.5, 352.5, 530, 252.5 },
elstob_at_IwghtFour = { 452.5, 352.5, 530, 252.5 },
elstob_at_RwghtFive = { 440, 340, 520, 240 },
elstob_at_IwghtFive = { 440, 340, 520, 240 },
elstob_at_RwghtSix = { 415, 315, 510, 215 },
elstob_at_IwghtSix = { 415, 315, 510, 215 },
elstob_at_RwghtOne = { 460, 390, 560, 290 },
elstob_at_IwghtOne = { 460, 390, 560, 290 },
elstob_at_RwghtTwo = { 452.5, 377.5, 550, 277.5 },
elstob_at_IwghtTwo = { 452.5, 377.5, 550, 277.5 },
elstob_at_RwghtThree = { 445, 365, 540, 265 },
elstob_at_IwghtThree = { 445, 365, 540, 265 },
elstob_at_RwghtFour = { 437.5, 352.5, 530, 252.5 },
elstob_at_IwghtFour = { 437.5, 352.5, 530, 252.5 },
elstob_at_RwghtFive = { 430, 340, 520, 240 },
elstob_at_IwghtFive = { 430, 340, 520, 240 },
elstob_at_RwghtSix = { 410, 315, 510, 215 },
elstob_at_IwghtSix = { 410, 315, 510, 215 },
elstob_at_RwghtSeven = { 390, 290, 500, 200 },
elstob_at_IwghtSeven = { 390, 290, 500, 200 },
elstob_at_RwghtEight = { 370, 270, 490, 170 },
Expand Down Expand Up @@ -195,8 +195,8 @@ function mkaltcommands()
tex.print("\\newcommand{\\" .. italsizedef .. "}{SizeFeatures={{Size={5-}, RawFeature={axis={wght=" ..
v[1] .. ",opsz=" .. v[2] .. ",slnt=\\elstob@Islnt}}}}}")
tex.print("\\DeclareOptionX{" .. romfeat .. "}{\\renewcommand*{\\" .. romdef .. "}{#1,}}")
tex.print("\\DeclareOptionX{" .. romsizefeat .. "}{\\renewcommand*{\\" .. romsizedef .. "}{#1}}")
tex.print("\\DeclareOptionX{" .. italsizefeat .. "}{\\renewcommand*{\\" .. italsizedef .. "}{#1}}")
tex.print("\\DeclareOptionX{" .. romsizefeat .. "}{\\renewcommand*{\\" .. romsizedef .. "}{\\directlua{mksizecommand({#1})}}}")
tex.print("\\DeclareOptionX{" .. italsizefeat .. "}{\\renewcommand*{\\" .. italsizedef .. "}{\\directlua{mksizecommand({#1})}}}")
end
end

Expand Down Expand Up @@ -255,3 +255,57 @@ function mkboldcommands(wtidx, adjustment)
tex.print("\\newcommand*{\\" .. cmd .. "}{" .. adjustwght(wt[wtidx],adjustment) .. "}")
end
end

function mksizecommand(sizetable)
result = "Nothing yet"
if #sizetable > 0 then
result = "SizeFeatures={"
lastsize = 0
for i, v in ipairs(sizetable) do
if v["size"] then
axiscount = 0
sizeitem = "{Size={"
currentsize = v["size"]
csnum = v["size"]
if i == #sizetable then
currentsize = currentsize .. "-"
elseif lastsize == 0 then
currentsize = "-" .. currentsize
else
currentsize = lastsize .. "-" .. currentsize
end
lastsize = csnum
sizeitem = sizeitem .. currentsize .. "},RawFeature={axis={"
if v["wght"] then
sizeitem = sizeitem .. "wght=" .. v["wght"]
axiscount = axiscount + 1
end
if v["opsz"] then
if axiscount >= 1 then sizeitem = sizeitem .. "," end
sizeitem = sizeitem .. "opsz=" .. v["opsz"]
axiscount = axiscount + 1
end
if v["slnt"] then
if axiscount >= 1 then sizeitem = sizeitem .. "," end
sizeitem = sizeitem .. "slnt=" .. v["slnt"]
axiscount = axiscount + 1
end
if v["GRAD"] then
if axiscount >= 1 then sizeitem = sizeitem .. "," end
sizeitem = sizeitem .. "GRAD=" .. v["GRAD"]
axiscount = axiscount + 1
end
if v["SPAC"] then
if axiscount >= 1 then sizeitem = sizeitem .. "," end
sizeitem = sizeitem .. "SPAC=" .. v["SPAC"]
end
sizeitem = sizeitem .. "}}},"
result = result .. sizeitem
end
end
result = result .. "}"
tex.print(result)
end
end


41 changes: 22 additions & 19 deletions TeX/elstob.sty
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
\DeclareOptionX{MainBoldFeatures}{\renewcommand*{\MainBoldDef}{#1,}}
\DeclareOptionX{MainBoldItalicFeatures}{\renewcommand*{\MainBoldItalicDef}{#1,}}

\DeclareOptionX{MainRegularSizeFeatures}{\newcommand*{\MainRegSizeDef}{#1}}
\DeclareOptionX{MainItalicSizeFeatures}{\newcommand*{\MainItalicSizeDef}{#1}}
\DeclareOptionX{MainBoldSizeFeatures}{\newcommand*{\MainBoldSizeDef}{#1}}
\DeclareOptionX{MainBoldItalicSizeFeatures}{\newcommand*{\MainBoldItalicSizeDef}{#1}}
\DeclareOptionX{MainRegularSizeFeatures}{\newcommand*{\MainRegSizeDef}{\directlua{mksizecommand({#1})}}}
\DeclareOptionX{MainItalicSizeFeatures}{\newcommand*{\MainItalicSizeDef}{\directlua{mksizecommand({#1})}}}
\DeclareOptionX{MainBoldSizeFeatures}{\newcommand*{\MainBoldSizeDef}{\directlua{mksizecommand({#1})}}}
\DeclareOptionX{MainBoldItalicSizeFeatures}{\newcommand*{\MainBoldItalicSizeDef}{\directlua{mksizecommand({#1})}}}

% ALTERNATE STYLES

Expand Down Expand Up @@ -109,32 +109,35 @@ mkboldcommands(wtidx, adjustment)}}

\def\elstob@spac{0}
\ifelstob@oldspacing
\renewcommand*{\MainDef}{StylisticSet=18,}
% Append StylisticSet=18 to existing \MainDef (which may be empty).
\let\tttemp\MainDef
\renewcommand*{\MainDef}{\tttemp StylisticSet=18,}
\def\elstob@spac{1}
\fi

% GENERATE SizeFeatures FOR THE FOUR MAIN STYLES
% (won't be done if user has supplied custom SizeFeatures)

\@ifundefined{MainRegSizeDef}{
\typeout{Constructing MainRegSizeDef}
\newcommand*{\MainRegSizeDef}{
SizeFeatures={
{Size={-6.5}, RawFeature={axis={wght=\elstob@RwghtOne,opsz=\elstob@RopszOne,SPAC=\elstob@spac}}},
{Size={6.5-7.5}, RawFeature={axis={wght=\elstob@RwghtTwo,opsz=\elstob@RopszTwo,SPAC=\elstob@spac}}},
{Size={7.5-8.5}, RawFeature={axis={wght=\elstob@RwghtThree,opsz=\elstob@RopszThree,SPAC=\elstob@spac}}},
{Size={8.5-9.5}, RawFeature={axis={wght=\elstob@RwghtFour,opsz=\elstob@RopszFour,SPAC=\elstob@spac}}},
{Size={9.5-10.5}, RawFeature={axis={wght=\elstob@RwghtFive,opsz=\elstob@RopszFive,SPAC=\elstob@spac}}},
{Size={10.5-11.5}, RawFeature={axis={wght=\elstob@RwghtSix,opsz=\elstob@RopszSix,SPAC=\elstob@spac}}},
{Size={11.5-12.5}, RawFeature={axis={wght=\elstob@RwghtSeven,opsz=\elstob@RopszSeven,SPAC=\elstob@spac}}},
{Size={12.5-13.5}, RawFeature={axis={wght=\elstob@RwghtEight,opsz=\elstob@RopszEight,SPAC=\elstob@spac}}},
{Size={13.5-14.5}, RawFeature={axis={wght=\elstob@RwghtNine,opsz=\elstob@RopszNine,SPAC=\elstob@spac}}},
{Size={14.5-15.5}, RawFeature={axis={wght=\elstob@RwghtTen,opsz=\elstob@RopszTen,SPAC=\elstob@spac}}},
{Size={15.5-16.5}, RawFeature={axis={wght=\elstob@RwghtEleven,opsz=\elstob@RopszEleven,SPAC=\elstob@spac}}},
{Size={16.5-17.5}, RawFeature={axis={wght=\elstob@RwghtTwelve,opsz=\elstob@RopszTwelve,SPAC=\elstob@spac}}},
{Size={17.5-}, RawFeature={axis={wght=\elstob@RwghtThirteen,opsz=\elstob@RopszThirteen,SPAC=\elstob@spac}}}
{Size={-6.5}, RawFeature={axis={wght=\elstob@RwghtOne, opsz=\elstob@RopszOne, SPAC=\elstob@spac}}},
{Size={6.5-7.5}, RawFeature={axis={wght=\elstob@RwghtTwo, opsz=\elstob@RopszTwo, SPAC=\elstob@spac}}},
{Size={7.5-8.5}, RawFeature={axis={wght=\elstob@RwghtThree, opsz=\elstob@RopszThree, SPAC=\elstob@spac}}},
{Size={8.5-9.5}, RawFeature={axis={wght=\elstob@RwghtFour, opsz=\elstob@RopszFour, SPAC=\elstob@spac}}},
{Size={9.5-10.5}, RawFeature={axis={wght=\elstob@RwghtFive, opsz=\elstob@RopszFive, SPAC=\elstob@spac}}},
{Size={10.5-11.5}, RawFeature={axis={wght=\elstob@RwghtSix, opsz=\elstob@RopszSix, SPAC=\elstob@spac}}},
{Size={11.5-12.5}, RawFeature={axis={wght=\elstob@RwghtSeven, opsz=\elstob@RopszSeven, SPAC=\elstob@spac}}},
{Size={12.5-13.5}, RawFeature={axis={wght=\elstob@RwghtEight, opsz=\elstob@RopszEight, SPAC=\elstob@spac}}},
{Size={13.5-14.5}, RawFeature={axis={wght=\elstob@RwghtNine, opsz=\elstob@RopszNine, SPAC=\elstob@spac}}},
{Size={14.5-15.5}, RawFeature={axis={wght=\elstob@RwghtTen, opsz=\elstob@RopszTen, SPAC=\elstob@spac}}},
{Size={15.5-16.5}, RawFeature={axis={wght=\elstob@RwghtEleven, opsz=\elstob@RopszEleven, SPAC=\elstob@spac}}},
{Size={16.5-17.5}, RawFeature={axis={wght=\elstob@RwghtTwelve, opsz=\elstob@RopszTwelve, SPAC=\elstob@spac}}},
{Size={17.5-}, RawFeature={axis={wght=\elstob@RwghtThirteen, opsz=\elstob@RopszThirteen, SPAC=\elstob@spac}}}
}
}
}{}
}{\typeout{Using predefined MainRegSizeDef}}

\@ifundefined{MainItalicSizeDef}{
\newcommand*{\MainItalicSizeDef}{
Expand Down

0 comments on commit d282d2c

Please sign in to comment.