This page is generated from HOOKS.md in the Typography Stylist source. Edit it there — edits made here are kept, but they stop this page from being updated until the conflict is resolved.
Plain Typography Switch
Since 2.3.5. Use this switch when your theme lets a reader choose plain text, for example a “Simplify typography” toggle in a reader panel. Turn it on for an element, and all plugin content in that element changes:
- No First Letter Hang moves a letter or a line into the margin. This applies to Typography Stylist blocks and to core Paragraph and Heading blocks with a paragraph style.
- Fit-to-width lines that had a hang get smaller, so they still fill the block and do not go past its end edge. This also applies to content saved before 2.3.5.
- The OpenType features of the plugin are reset to
font-feature-settings: normal(class only, see below). The reset applies to every.typost-styledelement and its descendants, so it also removes features that your theme sets on those elements (for exampleonumon headings). The font keeps its default features, such as standard ligatures and kerning. The Case setting (All Caps, Small Caps and others) does not change. Small caps from thesmcpandc2scfeature toggles are features, so they are reset. - The feature reset does not apply to block editor content, also when a page shows the editor on the frontend.
Add the typost-plain class to the element, or to an ancestor, such as <body>:
// Reader panel toggle
toggle.addEventListener('change', () => {
document.body.classList.toggle('typost-plain', toggle.checked);
});
You can also set the custom property --typost-plain: 1 in your own CSS. The property removes the hangs only, because a custom property cannot change font-feature-settings:
/* Hangs off, features kept */
.my-reader-mode {
--typost-plain: 1;
}
Details:
- The change applies at once, with no page reload. The frontend loads no script for it.
- With the switch off, content looks the same as before 2.3.5, and saved blocks stay valid.
- The switch works on the frontend only. The editor shows the hang that the author set.
- Fit-to-width lines are not measured again. When the feature reset changes the width of letters (for example a swash capital in place of a plain capital), a line can be a little wider or narrower than the block. A theme rule such as
* { font-feature-settings: normal !important }has the same result. - Do not use
--typost-hang-on. It is internal, and the plugin sets it for centered and end-aligned text.