Skip to content

Course Presentation: measure slide text as it is drawn, and set it larger where a slide has room - #154

Merged
alekswebnet merged 1 commit into
mainfrom
fix/cp-text-size
Nov 7, 2026
Merged

alekswebnet merged 1 commit into
mainfrom
fix/cp-text-size

Conversation

@alekswebnet

Copy link
Copy Markdown
Contributor

Closes #145.

h5p-author's slide layout measured text at the slide's 16 px in lines of 1.5. Course Presentation draws a paragraph at 10.8 px per 640 px of slide, in lines of 1.25em. So a text box came out about twice as tall as its text, and a slide of text alone showed small text in its top part.

What changes (packages/author/lib/types.mjs)

  • Measure: text is measured at the sizes Course Presentation 1.27's stylesheet and Advanced Text's give each block (SLIDE_TEXT, slideTextHeight):

    • a paragraph at 10.8 px per 640, in lines of 1.25em, with 1em after it;
    • h2 at 20 px and h3 at 16 px, in lines of 1.5em, with .5em after;
    • a list item at 12 px, with 1em between items and around the list.

    A text box is now about as tall as its text. Interactive Video keeps its own measure.

  • Grow: on a slide with room and no question, the text is set larger, in steps of 2, 1.75, 1.5 and 1.25 times, choosing the largest that fits with every picture at its full size (growText). Text whose source sets a font-size anywhere keeps its own size. A slide with a question gives the room to the question, as before, since how much a question needs depends on its answers.

  • Where the size goes: on the block itself, <p style="font-size:1.8em;">, not on a span inside as the issue proposed. Course Presentation gives a paragraph's line height in em, and a span inherits it as a fixed length, so its wrapped lines would overlap. The content check keeps the style: Advanced Text allows font.size, and a style may sit on p, h2, h3 and li. The style is written as the content check writes one it keeps (trimmed, in its order, text-align first, ending in ;), so an untrusted play changes nothing. A first version wrote font-size: 3.33em and the untrusted play reported "text rewritten" for it.

  • Docs: design/author.md, the type file's notes on stacking and on what fits on a slide, and a clause in h5p-author's README.

Checked

  • The water-cycle brief from the issue, rebuilt as the skill writes it (one text box per topic slide, then two questions). Slide 2 at a 1100 px viewport, a 1024 px slide:

    Paragraph Heading Text box Text in it
    main 17.3 px 32 px 213 px 146 px
    this branch 34.6 px 64 px 343 px 335 px

    The text now fills its box, with no scrollbar. Headings stay in Course Presentation's own ratio to paragraphs, 1.85. On a 568 px slide, a phone's width, paragraphs are 19 px where they were 9.6. The question slides look as they did. I checked the screenshots of every slide by eye.

  • One-slide presentations (a title slide, a text slide, a list slide, text with a question): h5p-verify passes each, trusted and untrusted, and the untrusted plays report no warning.

  • layout.test.ts, three new tests, all failing on main:

    • a text box measured as Course Presentation draws it;
    • text set larger on a slide with room, at a smaller step for more text, and not at all when even the smallest step does not fit;
    • a size the source set is kept, and a block's own style stays beside the new one, in the content check's order.
  • Suites: h5p-author 145 tests. apps/skills 73: every type file's example builds, checks unchanged as saved content, and plays trusted and untrusted with no warning.

Not done

Release: an h5p-author minor, since packages built from the same source now carry larger text. The type file's prose changed, so a global skill copy needs npx skills update -g after the release.

…set it larger where there is room

The slide layout measured text at the slide's 16 px in lines of 1.5, but
Course Presentation draws a paragraph at 10.8 px per 640 in lines of
1.25em, so a text box came out about twice as tall as its text and a
slide of text alone showed small text in its top part. Text is now
measured at the sizes Course Presentation 1.27's stylesheet gives each
block, and on a slide with room and no question it is set larger, in
steps up to twice, as large as fits with its pictures whole. The size
goes on each block, written as the content check writes a style, so the
lines grow with it and an untrusted play changes nothing. Text whose
source sets a size keeps it.

Closes #145.
@alekswebnet
alekswebnet merged commit 8acf821 into main Nov 7, 2026
8 checks passed
@alekswebnet
alekswebnet deleted the fix/cp-text-size branch November 8, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Course Presentation slides from h5p-author are small text on an empty slide: the layout measures text at 16 px, CP draws it at 10.8

1 participant