Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into esperanto
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jun 22, 2022
2 parents 8b772f9 + 2888d6c commit dda7c40
Show file tree
Hide file tree
Showing 33 changed files with 1,599 additions and 246 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
with:
fetch-depth: 0
- name: Run ‘commitlint’ linter
uses: wagoid/commitlint-github-action@v4
uses: wagoid/commitlint-github-action@v5
with:
configFile: '.commitlintrc.yml'
4 changes: 3 additions & 1 deletion classes/diglot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ function diglot:_init (options)
if self._legacy and not self._deprecated then return self:_deprecator(diglot) end
plain._init(self, options)
self:loadPackage("counters")
SILE.scratch.counters.folio = { value = 1, display = "arabic" }
self:registerPostinit(function ()
SILE.scratch.counters.folio = { value = 1, display = "arabic" }
end)
self:declareFrame("a", { left = "8.3%pw", right = "48%pw", top = "11.6%ph", bottom = "80%ph" })
self:declareFrame("b", { left = "52%pw", right = "100%pw-left(a)", top = "top(a)", bottom = "bottom(a)" })
self:declareFrame("folio",{ left = "left(a)", right = "right(b)", top = "bottom(a)+3%ph", bottom = "bottom(a)+8%ph" })
Expand Down
2 changes: 1 addition & 1 deletion classes/pecha.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pecha.defaultFrameset = {
}

function pecha:_init(options)
self._init(self, options)
plain._init(self, options)
self:loadPackage("rotate")
self:registerPostinit(function ()
SILE.call("language", { main = "bo" })
Expand Down
4 changes: 3 additions & 1 deletion classes/triglot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ function triglot:_init (options)
if self._legacy and not self._deprecated then return self:_deprecator(triglot) end
book._init(self, options)
self:loadPackage("counters")
SILE.scratch.counters.folio = { value = 1, display = "arabic" }
self:registerPostinit(function ()
SILE.scratch.counters.folio = { value = 1, display = "arabic" }
end)
self:declareFrame("a", {left = "5%pw", right = "28%pw", top = "11.6%ph", bottom = "80%ph" })
self:declareFrame("b", {left = "33%pw", right = "60%pw", top = "top(a)", bottom = "bottom(a)" })
self:declareFrame("c", {left = "66%pw", right = "95%pw", top = "top(a)", bottom = "bottom(a)" })
Expand Down
7 changes: 7 additions & 0 deletions core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ function settings:_init()
help = "Skip to be added to left side of line"
})

self:declare({
parameter = "document.zenkakuchar",
default = "",
type = "string",
help = "The character measured to determine the length of a zenkaku width (全角幅)"
})

SILE.registerCommand("set", function(options, content)
local parameter = SU.required(options, "parameter", "\\set command")
local makedefault = SU.boolean(options.makedefault, false)
Expand Down
19 changes: 19 additions & 0 deletions core/units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,23 @@ units["en"] = {
definition = "0.5em"
}

-- jlreq measures distances in units of 1em, but also assumes that an em is the
-- width of a full-width character. In SILE terms it isn't: measuring an "m" in
-- a 10pt Japanese font gets you 5 points. So we measure a full-width character
-- and use that as a unit. We call it zw following ptex (zenkaku width)
units["zw"] = {
relative = true,
definition = function (v)
local zenkakuchar = SILE.settings:get("document.zenkakuchar")
local measureable, zenkaku = pcall(SILE.shaper.measureChar, SILE.shaper, zenkakuchar)
if not measureable then
SU.warn(string.format([[Zenkaku width (全角幅) unit zw is falling back to 1em == 1zw as we
cannot measure %s. Either change this char to one suitable for your
language, or load a font that has it.]], zenkakuchar))
end
local width = measureable and zenkaku.width or 1
return v * width
end
}

return units
67 changes: 31 additions & 36 deletions documentation/c04-useful.sil
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ obscure corners as the documentation progresses.
The most basic command for altering the look of the text is the \code{\\font}
command; it takes two forms:

\noindent{}• \code{\\font[\em{parameters…}]\{\em{argument}\}}

\noindent{}• \code{\\font[\em{parameters…}]}
\begin{itemize}
\item{\code{\\font[\em{parameters…}]\{\em{argument}\}}}
\item{\code{\\font[\em{parameters…}]}}
\end{itemize}

The first form sets the given argument text in the specified font; the
second form changes the font used to typeset text from this point on.
Expand Down Expand Up @@ -64,42 +65,36 @@ current page width or height, the current frame width or height, and the line wi
You can specify lengths in terms of the current paragraph skip (\code{ps}) and
baseline skip (\code{bs}), which will make sense later on. Additional units are
available relative to the largest or smallest value of either axis (\code{\%pmax},
\code{\%pmin}, \code{\%fmax, \code{\%fmin}}).
\code{\%pmin}, \code{\%fmax}, \code{\%fmin}).

The full list of attributes to the \code{\\font} command are:

\medskip

\noindent{}• \em{size}: as above.

\noindent{}• \em{family}: the name of the font to be selected. SILE should know
about all the fonts installed on your system, so that fonts can be specified by
their name.

\noindent{}• \em{filename}: if a filename is supplied, SILE will use the font file provided rather than looking at your system’s font library.

\noindent{}• \em{style}: can be \code{normal} or \code{italic}.

\noindent{}• \em{weight}: a CSS-style numeric weight ranging from \font[weight=100]{100},
through \font[weight=200]{200},
\font[weight=300]{300},
\font[weight=400]{400},
\font[weight=500]{500},
\font[weight=600]{600},
\font[weight=700]{700},
\font[weight=800]{800} to
\font[weight=900]{900}. Not all fonts will support all weights (many just have
two), but SILE will choose the closest.

\noindent{}• \em{variant}: a font variant (\code{normal}, \code{smallcaps})

\noindent{}• \em{language}: The two letter (ISO639-1) language code for the
text. This will affect both font shaping and hyphenation.

\noindent{}• \em{direction}: The expected text direction. (\code{LTR-TTB} for left to right, top to bottom; \code{RTL-BTT} would set text right to left, bottom to top!)

\noindent{}• \em{script}: The script family in use. (See chapter 7, “Language”, for more on these past three settings.)
\medskip
\begin{itemize}
\item{\autodoc:parameter{size}: as above.}
\item{\autodoc:parameter{family}: the name of the font to be selected. SILE should know
about all the fonts installed on your system, so that fonts can be specified by
their name.}
\item{\autodoc:parameter{filename}: if a filename is supplied, SILE will use the font
file provided rather than looking at your system’s font library.}
\item{\autodoc:parameter{style}: can be \code{normal} or \code{italic}.}
\item{\autodoc:parameter{weight}: a CSS-style numeric weight ranging from \font[weight=100]{100},
through \font[weight=200]{200},
\font[weight=300]{300},
\font[weight=400]{400},
\font[weight=500]{500},
\font[weight=600]{600},
\font[weight=700]{700},
\font[weight=800]{800} to
\font[weight=900]{900}. Not all fonts will support all weights (many just have
two), but SILE will choose the closest.}
\item{\autodoc:parameter{variant}: a font variant (\code{normal}, \code{smallcaps})}
\item{\autodoc:parameter{language}: The two letter (ISO639-1) language code for the
text. This will affect both font shaping and hyphenation.}
\item{\autodoc:parameter{direction}: The expected text direction. (\code{LTR-TTB} for
left to right, top to bottom; \code{RTL-BTT} would set text right to left, bottom to top!)}
\item{\autodoc:parameter{script}: The script family in use. (See chapter 7, “Language”, for more
on these past three settings.)}
\end{itemize}

It’s quite fiddly to be always changing font specifications manually; later
we’ll see some ways to automate the process. SILE provides the \code{\\em\{…\}}
Expand Down
5 changes: 5 additions & 0 deletions documentation/c05-packages.sil
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ basic functionality to other packages and classes. Classes such as the
\subsection{indexer}
\package-documentation[src=packages/indexer]

\subsection{lists}
\script[src=packages/font-fallback]
\font:add-fallback[family=Symbola]% HACK Gentium Plus (SILE default font) lacks the circle bullet :(
\package-documentation[src=packages/lists]

\subsection{math}
\package-documentation[src=packages/math]

Expand Down
99 changes: 55 additions & 44 deletions documentation/c07-settings.sil
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ As we mentioned in the section on grid typesetting, the rules for spacing betwee
\em{lines} within a paragraph is determined by two
rules. Let’s reiterate those rules now in terms of settings:

\noindent• SILE tries to insert space between two successive lines to make their
baselines exactly \autodoc:setting{document.baselineskip} apart.

\noindent• If this first rule would mean that the bottom and the top of the lines are less
than \autodoc:setting{document.lineskip} apart, then they are forced to be
\autodoc:setting{document.lineskip} apart.
\begin{itemize}
\item{SILE tries to insert space between two successive lines to make their
baselines exactly \autodoc:setting{document.baselineskip} apart.}
\item{If this first rule would mean that the bottom and the top of the lines are
less than \autodoc:setting{document.lineskip} apart, then they are forced
to be \autodoc:setting{document.lineskip} apart.}
\end{itemize}

\note{This linebreaking method is fiddly, and book designers may prefer to
work with the tools provided by the \code{linespacing} package.}
Expand Down Expand Up @@ -288,32 +289,41 @@ been adapted as appropriate. Here is a quick run-down of the settings
applicable to the line-breaking algorithm. You are expected to know what you
are doing with these.

\noindent• \autodoc:setting{linebreak.tolerance}: How bad a breakpoint is before it is rejected
by the algorithm. (Default: 500)

\noindent• \autodoc:setting{linebreak.parShape}: Whether to utilize a callback to \code{SILE.linebreak:parShape()} to get a customized shape for each line in a paragraph. (Default: false)

\noindent• \autodoc:setting{linebreak.pretolerance}: If there are no breakpoints better than
this, the paragraph is considered for hyphenation. (Default: 100)

\noindent• \autodoc:setting{linebreak.hangIndent}: How far to indent initial line(s) of a paragraph. (Default: 0)

\noindent• \autodoc:setting{linebreak.hangAfter}: An integer count of how many lines should have \autodoc:setting{linebreak.hangIndent} applied. (Default: nil)

\noindent• \autodoc:setting{linebreak.adjdemerits}: Additional demerits which are accumulated in the course of paragraph building when two consecutive lines are visually incompatible. In these cases, one line is built with much space for justification, and the other one with little space. (Default: 10000)

\noindent• \autodoc:setting{linebreak.looseness}: How many lines the current paragraph should
be made longer than normal. (Default: 0)

\noindent• \autodoc:setting{linebreak.prevGraf}: The number of lines in the paragraph last added to the vertical list.

\noindent• \autodoc:setting{linebreak.emergencyStretch}: Assumed extra stretchability in lines of a paragraph. (Default: 0)

\noindent• \autodoc:setting{linebreak.linePenalty}: Penalty value associated with each line break. (Default: 10)

\noindent• \autodoc:setting{linebreak.hyphenPenalty}: Penalty associated with break at a hyphen. (Default: 50)

\noindent• \autodoc:setting{linebreak.doubleHyphenDemerits}: Penalty for consecutive lines ending with a hyphen. (Default: 10000)
\begin{itemize}
\item{\autodoc:setting{linebreak.tolerance}: How bad a breakpoint is before it is
rejected by the algorithm.
(Default: 500)}
\item{\autodoc:setting{linebreak.parShape}: Whether to utilize a callback to
\code{SILE.linebreak:parShape()} to get a customized shape for each line in a paragraph.
(Default: false)}
\item{\autodoc:setting{linebreak.pretolerance}: If there are no breakpoints better than
this, the paragraph is considered for hyphenation.
(Default: 100)}
\item{\autodoc:setting{linebreak.hangIndent}: How far to indent initial line(s) of a paragraph.
(Default: 0)}
\item{\autodoc:setting{linebreak.hangAfter}: An integer count of how many lines should have
\autodoc:setting{linebreak.hangIndent} applied.
(Default: nil)}
\item{\autodoc:setting{linebreak.adjdemerits}: Additional demerits which are accumulated in the
course of paragraph building when two consecutive lines are visually incompatible. In these
cases, one line is built with much space for justification, and the other one with little space.
(Default: 10000)}
\item{\autodoc:setting{linebreak.looseness}: How many lines the current paragraph should
be made longer than normal.
(Default: 0)}
\item{\autodoc:setting{linebreak.prevGraf}: The number of lines in the paragraph last added to
the vertical list.}
\item{\autodoc:setting{linebreak.emergencyStretch}: Assumed extra stretchability in lines of a
paragraph.
(Default: 0)}
\item{\autodoc:setting{linebreak.linePenalty}: Penalty value associated with each line break.
(Default: 10)}
\item{\autodoc:setting{linebreak.hyphenPenalty}: Penalty associated with break at a hyphen.
(Default: 50)}
\item{\autodoc:setting{linebreak.doubleHyphenDemerits}: Penalty for consecutive lines ending
with a hyphen.
(Default: 10000)}
\end{itemize}

\section{Shaper settings}

Expand Down Expand Up @@ -356,22 +366,23 @@ Most of the time you will not be fiddling with these settings at the SILE layer,
because complex layout commands are expected to be implemented in Lua. The
following SILE functions access the settings system from inside Lua:

\noindent• \code{SILE.settings:set(\em{<parameter>}, \em{value})}: sets a setting.
\begin{itemize}
\item{\code{SILE.settings:set(\em{<parameter>}, \em{value})}: sets a setting.

\note{
You should note that, while in the SILE layer, the \code{\\set} command does its
best to turn the textual description of a type into the appropriate Lua type
for the value. \code{SILE.settings:set} does not do that; it expects the value
to be of the appropriate type: lengths need to be a \code{SILE.length} object,
glue must be \code{SILE.nodefactory.glue} and so on.}

\noindent• \code{SILE.settings:get(\em{<parameter>})}: retrieves the current
setting of the parameter.

\noindent• \code{SILE.settings:temporarily(\em{function})}: Saves all settings,
runs the function and then restores all settings afterwards.

\noindent• \code{SILE.settings:declare(\em{<specification>})}: Declares a new
setting. See the base settings in \code{settings.lua} for examples of how to
call this. A class or package should namespace its settings with \code{<package>.<setting>}.
glue must be \code{SILE.nodefactory.glue} and so on.}}

\item{\code{SILE.settings:get(\em{<parameter>})}: retrieves the current
setting of the parameter.}
\item{\code{SILE.settings:temporarily(\em{function})}: Saves all settings,
runs the function and then restores all settings afterwards.}
\item{\code{SILE.settings:declare(\em{<specification>})}: Declares a new
setting. See the base settings in \code{settings.lua} for examples of how
to call this. A class or package should namespace its settings with
\code{<package>.<setting>}.}
\end{itemize}
\end{document}
45 changes: 23 additions & 22 deletions documentation/c09-concepts.sil
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,22 @@ going to stipulate that the gutter width will be 3\% of the page width:
Declarations of frame dimensions are like ordinary SILE \code{<dimension>}s,
except with three additional features:

\noindent• You can refer to properties of other frames using the \code{top()},
\code{bottom()}, \code{left()}, \code{right()}, \code{height()} and \code{width()}
functions. These functions take a frame ID. SILE magically pre-defines the frame
\code{page} to allow you to access the dimensions of the whole page.

\noindent• You can use arithmetic functions: plus, minus, divide, multiply, and
parenthesis have their ordinary arithmetic meaning. To declare that frame \code{b}
should be half the height of frame \code{a} plus 5 millimeters, you can say
\code{height=5mm + (height(b) / 2)}. However, as we will see later, it is usually
better to structure your declarations to let SILE make those kind of computations for
you.

\noindent• Since book design is often specified in terms of proportion of a page,
you can use the shortcut \code{width=5\%pw} instead of \code{width=0.05 * width(page)}
and \code{height=50\%ph} instead of \code{height=0.5 * height(page)}.
\begin{itemize}
\item{You can refer to properties of other frames using the \code{top()},
\code{bottom()}, \code{left()}, \code{right()}, \code{height()} and
\code{width()} functions. These functions take a frame ID. SILE magically
pre-defines the frame \code{page} to allow you to access the dimensions
of the whole page.}
\item{You can use arithmetic functions: plus, minus, divide, multiply, and
parenthesis have their ordinary arithmetic meaning. To declare that frame
\code{b} should be half the height of frame \code{a} plus 5 millimeters,
you can say \code{height=5mm + (height(b) / 2)}. However, as we will see
later, it is usually better to structure your declarations to let SILE
make those kind of computations for you.}
\item{Since book design is often specified in terms of proportion of a page,
you can use the shortcut \code{width=5\%pw} instead of \code{width=0.05 * width(page)}
and \code{height=50\%ph} instead of \code{height=0.5 * height(page)}.}
\end{itemize}

\end{note}

Expand All @@ -280,13 +281,13 @@ margin of the left column is the left margin of the typeblock; the right margin
the right column is the right margin of the typeblock. But we also want
a few other parameters to ensure that:

\noindent• the gutter is placed between our two columns

\noindent• the two columns have the same width (We don’t know what that width is, but SILE
will work it out for us.)

\noindent• after the left column is full, typesetting should move to the right
column.
\begin{itemize}
\item{the gutter is placed between our two columns}
\item{the two columns have the same width (We don’t know what that width is,
but SILE will work it out for us.)}
\item{after the left column is full, typesetting should move to the right
column.}
\end{itemize}

\begin{verbatim}
\line
Expand Down
11 changes: 8 additions & 3 deletions documentation/c10-classdesign.sil
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,14 @@ displaying page numbers, and so on.

The key methods for defining the \em{output routine} are:

\noindent{}• \code{newPar} and \code{endPar} are called at the start and end of each paragraph.

\noindent{}• \code{newPage} and \code{endPage} are called at the start and each of each page.
\begin{itemize}
\item{\code{newPar} and \code{endPar} are called at the start and end of
each paragraph.}
\item{\code{newPage} and \code{endPage} are called at the start
and each of each page.}
\item{\code{init} and \code{finish} are called at the start and
end of the document.}
\end{itemize}

\noindent{}• \code{init} and \code{finish} are called at the start and end of the document.

Expand Down
Loading

0 comments on commit dda7c40

Please sign in to comment.