genesis-editor

Font size

A size dropdown in the selection toolbar. The menu is 6–20 px; paste and import can keep larger steps through 72.

Sizes#

The dropdown offers 6, 8, 10, 12, 14, 16, 18, 20 px. Paste and import can keep a larger step from 6, 8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 72; the label shows it even when the menu doesn't list it. 16 is the editor's body size: it's labelled Default and stores nothing. When the selection has more than one size, the dropdown shows —.

  • ⌘⇧. / Ctrl+Shift+. steps the selection up a size, and ⌘⇧, / Ctrl+Shift+, steps it down.
  • Headings keep a pasted or imported size so a title stays larger than later headings. Code blocks don't take a size, and the dropdown hides there.
<BlockEditor tools={{ fontSize: true, bold: true, colors: true }} />

// Toolbar order: "fontSize" is a toolbar item id too.
<BlockEditor toolbar={["blockType", "bold", "italic", "fontSize", "colors", "link"]} />

Sizes are a style, like bold:

{ "type": "text", "text": "Small print", "styles": { "fontSize": "12px" } }

Pasted sizes#

Pasted text keeps its size relative to the rest of what you pasted, not its absolute size:

  1. Every size is converted to px: pt × 4/3; em and % of the parent; rem of 16; keywords such as small (13) and x-large (24).
  2. The size of most of the text, by length, becomes 16. A Google Doc in 11 pt pastes as Default, not as 14 px, and its 9 pt text as 14 px.
  3. The result is limited to 6–72 px and rounded to the nearest step (ties go up). Sizes outside the range count as fontSizes.clamped in the import report.

With the fontSize tool off, pasted sizes are dropped and reported under unsupportedStyles.

HTML#

<span style="font-size:12px" data-font-size="12px">Small print</span>

data-font-size marks a size the editor set itself: parseHTML reads it back exactly instead of comparing it with the rest of the document, so a document that's mostly 14 px stays that way.