Repository navigation
Course Presentation: measure slide text as it is drawn, and set it larger where a slide has room - #154
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):h2at 20 px andh3at 16 px, in lines of 1.5em, with .5em after;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 afont-sizeanywhere 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 allowsfont.size, and a style may sit onp,h2,h3andli. The style is written as the content check writes one it keeps (trimmed, in its order,text-alignfirst, ending in;), so an untrusted play changes nothing. A first version wrotefont-size: 3.33emand 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:
mainThe 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-verifypasses each, trusted and untrusted, and the untrusted plays report no warning.layout.test.ts, three new tests, all failing onmain:Suites: h5p-author 145 tests.
apps/skills73: 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 -gafter the release.