Slides, inches and points
How PowerPoint measures a slide: inches for positions, points for fonts. Write the unit helpers every later file uses, and check whether a box fits on the slide.
Before drawing anything we need to agree on units. PowerPoint uses two, and mixing them up is the most common bug in slide code: text boxes 72 times too big, or too small to see.
height: 5.625 in = 405 pt
1 inch
72 pt
Body text
18 pt ≈ ¼ in
Big title
40 pt ≈ ½ in
Two units
- Inches for positions and sizes. pptxgenjs, the library that writes our files, takes
x,y,wandhin inches. - Points for font sizes. A is 1/72 of an inch, so 18pt text is a quarter of an inch tall.
Why the engine uses points
Text is sized in points, and text is the hard part of layout. If boxes are in points too, "does 24pt text fit in this box?" needs no conversion at all. Points are also whole numbers for common sizes (a slide is 720 wide, not 10.0), which makes layout output easy to read.
72 points = 1 inch
pointsToInches(720) → 10 // slide width
inchesToPoints(0.75) → 54 // a 0.75in marginDoes a box fit?
You'll also write fitsOnSlide(box). A box { x, y, w, h } is fully on the slide when it doesn't start left of or above the slide, and its right edge (x + w) and bottom edge (y + h) don't pass the slide's width and height. Edges exactly on the border count as inside.
Key takeaways
- A 16:9 slide is 10 × 5.625 inches, which is 720 × 405 points.
- Our engine works in points everywhere and converts to inches only when writing the file.
- A box fits on the slide when its left, top, right and bottom edges are all inside it.
Sign in to run the exercise
Reading is free. Writing code here needs an account so we have somewhere to keep your Gemini key and the +20 XP you are about to earn.