Typography Stylist works with all themes, with no configuration. This page is for themes that need more.
What does the plugin output?
On the frontend, the plugin does its styling with CSS:
--font-Ncustom properties for all fonts. The plugin prints them on pages that have styled content.@font-facerules only for the fonts that the page uses.- Inline
font-feature-settings,font-variation-settings,font-family, and sizes on styled spans. - A stylesheet of paragraph style classes. A single post or page prints only the styles that it uses. Archive pages, the blog page, and search results print all styles.
Which unit do font sizes use?
New content writes font sizes in rem, so the sizes follow the root font size. If your theme changes the root font size, for example html { font-size: 62.5% }, a size of 24px shows at 15px. To write new sizes in px, select Write new font sizes in px at Settings → Typography Stylist → Options. Content that you saved before keeps its unit.
How do I use a plugin font in my theme CSS?
Use the custom property:
.site-title {
font-family: var(--font-12, Georgia, serif);
}
Always give a fallback in the var(). On a page with no styled content, the property is not defined. On other pages, the font file loads only if the content uses the font.
My theme CSS uses a font but it never loads
This is the most common integration problem. It comes from how loading works. The plugin scans the content for font references. It cannot see a font that only a stylesheet uses.
To load the font on every page, select Load on all pages on its card at Settings → Typography Stylist → Custom Fonts. Or use this filter:
add_filter( 'typost_force_enqueue_font_ids', function ( $ids ) {
$ids[] = 12; // The numeric font ID from Settings > Custom Fonts.
return $ids;
} );
This prints the --font-12 property and its @font-face on every page.
If your theme puts a paragraph style class in a template, for example typost-ps-3, use the typost_force_enqueue_paragraph_style_ids filter. It prints the CSS of the styles that you name on every page, and it loads their fonts.
Can I style the site title with OpenType features?
Not with the inline format. core/site-title and core/site-tagline declare allowedFormats: []. This tells WordPress to allow no inline formatting. Core’s own Bold and Italic are not available there either. So the plugin has nothing to attach to.
You have two options. You can apply the features in your theme CSS:
.wp-block-site-title {
font-family: var(--font-12, serif);
font-feature-settings: "dlig" 1, "swsh" 1;
}
Or you can use a Typography Stylist block in the header template, in place of the core block. You then get the full interface, but you lose the dynamic site title.
Which classes should I be aware of?
| Class | Where |
|---|---|
.wp-block-typost | The wrapper of a Typography Stylist block |
.wp-block-typost > .typost-styled | The visible copy of the block, with aria-hidden="true" |
.typost-fit | Added to the visible copy when the block uses Fit to width |
.typost-styled | Every inline styled span, and the visible copy of each block |
.typost-line | One measured line in a fit-to-width block |
.typost-ps-{id} | A paragraph style |
The visible copy of each block has the typost-styled class too. A rule for .typost-styled therefore styles whole blocks as well as inline spans. Use span.typost-styled to target only inline spans.
Can a reader turn the typography off?
Yes, since 2.3.5. If your theme has a reader setting such as “Simplify typography”, add the typost-plain class to an element, for example <body>. In that element, no First Letter Hang moves a letter into the margin, fit-to-width lines that had a hang get smaller so they still fill the block, and the plugin’s OpenType features are reset. The Case setting does not change. The change applies at once, with no page reload and no script. See Theme CSS Switches.
Does my theme need the screen reader class?
Only for a custom class. Each block has a Screen Reader Class setting in its sidebar Accessibility panel. The plugin includes the CSS for visually-hidden, sr-only, and screen-reader-text. If you choose Custom, your theme must define the class. If it does not, the plain copy shows and the text appears two times.