Tweego v2.1.1
SugarCube v2.36.1
How can I interactively change a font’s “line-height” for an entire Story?
I can change “line-height” for the current passage using a function and the selector “.passage” but other selectors, including “html” “#passages” and “#story”, don’t affect the visible “line-height”. Other font modifications do work for both “.passage” and “html”.
:: Start
!! Start
How can I interactively change a font's line-height for an entire story?
A function to change line-height works fine for the selector ".passage" but does nothing when selecting "html". Unfortunately, ".passage" applies only to the current passage. Other types of font modifications work for both ".passage" and "html". The selectors "#passages" and "#story" also are non-responsive.
This was tested using Tweego v2.1.1 and SugarCube 2.36.1 under Windows 10 22H2 with Firefox v108.0.1 and Edge v108.0.1462.54.
Go to [[Another Passage]]
Go to [[Start]]. (Erase current ".passage" font settings.)
----
Modifying ".passage" font settings:
family = <<link "Ariel">><<set fontFamily(".passage","Ariel")>> <</link>>
family = <<link "Courier">><<set fontFamily(".passage","Courier")>> <</link>>
<<link "Shrink">><<set fontSize(".passage",-2)>> <</link>> Font size <<link "Expand">> <<set fontSize(".passage",2)>><</link>>
<<link "Shrink">> <<set lineHeight(".passage",-4)>> <</link>> .passage line-height <<link "Expand">> <<set lineHeight(".passage",4)>> <</link>> (works fine)
----
Modifying "html" font settings:
family = <<link "Ariel">><<set fontFamily("html","Ariel")>> <</link>>
family = <<link "Courier">><<set fontFamily("html","Courier")>> <</link>>
<<link "Shrink">><<set fontSize("html",-2)>> <</link>> Font size <<link "Expand">> <<set fontSize("html",2)>><</link>>
<<link "Shrink">> <<set lineHeight("html",-4)>> <</link>> html line-height <<link "Expand">> <<set lineHeight("html",4)>> <</link>> (does not work)
----
----
Modifying "#passages" font settings:
<<link "Shrink">> <<set lineHeight("#passages",-4)>> <</link>>"#passages" line-height <<link "Expand">> <<set lineHeight("#passages",4)>> <</link>> (does not work)
----
Modifying "#story" font settings:
<<link "Shrink">> <<set lineHeight("#story",-4)>> <</link>> "#story" line-height <<link "Expand">> <<set lineHeight("#story",4)>> <</link>> (does not work)
----
Environment:
''Story Compiler:'' <<= $('tw-storydata').attr('creator') + " v" + $('tw-storydata').attr('creator-version')>>
''Story Format:'' <<= $('tw-storydata').attr('format') + " v" + $('tw-storydata').attr('format-version')>>
''Your Reader (Browser):'' <<= navigator.userAgent>>
----
:: StoryInit
:: StoryData
{
"ifid": "C31A5464-60FC-4937-A550-C7D75F7692AF"
}
:: StoryTitle
test font changes
:: Story Stylesheet [stylesheet]
/* use default font configuration */
:: Story JavaScript [script]
// change line-height for specified selector
window.lineHeight = function(sel,value) {
$(sel).css("line-height", (parseInt($(sel).css("line-height")) + value) + "px");
}
// change font-size for specified selector
window.fontSize = function(sel,value) {
$(sel).css("font-size", (parseInt($(sel).css("font-size")) + value) + "px");
}
// change font-family for specified selector
window.fontFamily = function(sel,fam) {
$(sel).css("font-family", fam);
}
:: Another Passage
!! This is Another Passage
go back to [[Start]]
line-height doesn't change for the text below
----
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx
----