Skip to content

Commit

Permalink
Merge 77d274f into fbfe5d4
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia committed Mar 29, 2023
2 parents fbfe5d4 + 77d274f commit 454454d
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 10 deletions.
4 changes: 4 additions & 0 deletions core/settings.lua
Expand Up @@ -111,6 +111,10 @@ function settings:declare (spec)
if spec.name then
SU.deprecated("'name' argument of SILE.settings:declare", "'parameter' argument of SILE.settings:declare", "0.10.10", "0.11.0")
end
if self.declarations[spec.parameter] then
SU.debug("settings", "Attempt to re-declare setting: " .. spec.parameter)
return
end
self.declarations[spec.parameter] = spec
self:set(spec.parameter, spec.default, true)
end
Expand Down
2 changes: 2 additions & 0 deletions tests/bidi.sil
Expand Up @@ -37,4 +37,6 @@ One two אבג three four
My hovercraft is full of eels.

הרחפת שלי מלאה בצלופחים

\set[parameter=typesetter.breakwidth]% restore default before folio is output (see #1708)
\end{document}
66 changes: 66 additions & 0 deletions tests/bug-1708.expected
@@ -0,0 +1,66 @@
Set paper size 209.7637818 297.6377985
Begin page
Mx 17.4104
My 41.1471
Set font Gentium Plus;10;400;;normal;;;LTR
T 47 w=4.7607 (L)
Mx 27.1711
T 82 w=5.0293 (o)
Mx 37.2004
T 85 w=3.9600 (r)
Mx 46.1604
T 72 w=4.6191 (e)
Mx 55.7795
T 80 w=8.0322 (m)
Mx 66.4616
T 76 w=2.7100 (i)
Mx 74.1715
T 83 w=5.2979 (p)
Mx 84.4694
T 86 w=3.8623 (s)
Mx 93.3317
T 88 w=5.2979 (u)
Mx 103.6295
T 80 w=8.0322 (m)
Mx 111.6618
My 37.9684
Set font Gentium Plus;6.81152;400;;normal;;;LTR
T 20 w=3.1962 (1)
Mx 17.4104
My 53.1471
Set font Gentium Plus;10;400;;normal;;;LTR
T 47 w=4.7607 (L)
Mx 27.1711
T 82 w=5.0293 (o)
Mx 37.2004
T 85 w=3.9600 (r)
Mx 46.1604
T 72 w=4.6191 (e)
Mx 55.7795
T 80 w=8.0322 (m)
Mx 66.4619
T 76 w=2.7100 (i)
Mx 74.1719
T 83 w=5.2979 (p)
Mx 84.4697
T 86 w=3.8623 (s)
Mx 93.3320
T 88 w=5.2979 (u)
Mx 103.6299
T 80 w=8.0322 (m)
Mx 17.4104
My 247.7565
Set font Gentium Plus;9;400;;normal;;;LTR
T 20 w=4.2231 (1)
Mx 21.6335
T 17 w=2.0610 (.)
Mx 41.6946
T 87 w=3.0981 (t)
Mx 49.7927
T 72 w=4.1572 (e)
Mx 58.9499
T 86 w=3.4761 (s)
Mx 67.4260
T 87 w=3.0981 (t)
End page
Finish
12 changes: 12 additions & 0 deletions tests/bug-1708.sil
@@ -0,0 +1,12 @@
\begin[papersize=a7,class=book]{document}
\neverindent
\nofolios
\set[parameter=document.letterspaceglue, value=5pt]
% Bug 1708: New typesetter instance (as e.g. done via a footnote)
% shouldn't reset settings from the global scope.

Lorem ipsum\footnote{test}

Lorem ipsum% Should still have letterspacing at 5pt

\end{document}
39 changes: 29 additions & 10 deletions typesetters/base.lua
@@ -1,3 +1,11 @@
--- SILE typesetter (default/base) class.
--
-- @copyright License: MIT
-- @module typesetters.base
--

-- Typesetter base class

local typesetter = pl.class()
typesetter.type = "typesetter"
typesetter._name = "base"
Expand Down Expand Up @@ -39,6 +47,27 @@ function typesetter:init (frame)
end

function typesetter:_init (frame)
self:declareSettings()
self.hooks = {}
self.breadcrumbs = SU.breadcrumbs()

self.frame = nil
self.stateQueue = {}
self:initFrame(frame)
self:initState()
-- In case people use stdlib prototype syntax off of the instantiated typesetter...
getmetatable(self).__call = self.init
return self
end

function typesetter:declareSettings()

-- Settings common to any typesetter instance.
-- These shouldn't be re-declared and overwritten/reset in the typesetter
-- constructor (see issue https://github.com/sile-typesetter/sile/issues/1708).
-- On the other hand, it's fairly acceptable to have them made global:
-- Any derived typesetter, whatever its implementation, should likely provide
-- some logic for them (= widows, orphans, spacing, etc.)

SILE.settings:declare({
parameter = "typesetter.widowpenalty",
Expand Down Expand Up @@ -103,16 +132,6 @@ function typesetter:_init (frame)
help = "Width to break lines at"
})

self.hooks = {}
self.breadcrumbs = SU.breadcrumbs()

self.frame = nil
self.stateQueue = {}
self:initFrame(frame)
self:initState()
-- In case people use stdlib prototype syntax off of the instantiated typesetter...
getmetatable(self).__call = self.init
return self
end

function typesetter:initState ()
Expand Down

0 comments on commit 454454d

Please sign in to comment.