-
As in the title, is it possible to add something like in https://www.w3.org/Talks/Tools/Slidy2/#(2)
this function? So that I can immediately modify the font size when there is a problem with the text layout. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, As mentioned in https://revealjs.com/keyboard/ you can add/edit keyboard shortcut quite easily. Font sizes in reveal are controlled by a main css variable named then overriding this variable value on a DOM node will automatically change font-sizes in every children. If you do so on body element, you then control the whole font sizes. This snippet should do the trick : function updateFontSize( delta ) {
const fontSizeRegexp = /^(?<size>\d+)(?<unit>\D*)$/, // the beauty of named capturing groups 😍
fontSize = getComputedStyle( Reveal.getViewportElement() ).getPropertyValue( '--r-main-font-size' ),
{ size, unit } = fontSize.match(fontSizeRegexp).groups;
Reveal.getViewportElement().style.setProperty( '--r-main-font-size', ( parseInt( size ) + delta ) + unit );
}
function resetFontSize() {
Reveal.getViewportElement().style.removeProperty( '--r-main-font-size' );
}
Reveal.initialize({
// ...
keyboard: {
82 : () => updateFontSize( -2 ), // 'r'
84 : () => updateFontSize( +2 ), // 't'
69 : () => resetFontSize(), // 'e'
},
// ...
}); |
Beta Was this translation helpful? Give feedback.
Hi,
As mentioned in https://revealjs.com/keyboard/ you can add/edit keyboard shortcut quite easily.
Font sizes in reveal are controlled by a main css variable named
--r-main-font-size
:reveal.js/css/theme/template/exposer.scss
Line 6 in 92ee97f
then overriding this variable value on a DOM node will automatically change font-sizes in every children. If you do so on body element, you then control the whole font sizes. This snippet should do the trick :