Skip to content

Type: vertical type takes upright glyphs' cells from the font's vertical metrics - #343

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
imachus:pr/ja-vmetrics
Oct 7, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
imachus:pr/ja-vmetrics

Conversation

@imachus

@imachus imachus commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

What and why

Upright glyphs in vertical type advanced one em (or their horizontal
advance, if wider) and turned about a fixed point 0.38 em above the
baseline. Fonts that carry vertical metrics now place them as they ask:

  • FontFace::vertical_glyph: a glyph's advance down the column (vmtx)
    and the height of its vertical origin (VORG, else the glyph's top
    plus its top side bearing, as in TrueType fonts); None without
    vhea/vmtx or with values outside a few ems.
    FontFace::ideographic_centre: the em box centre from an ideograph's
    cell, else 0.38.
  • The layout advances an upright glyph by its vertical advance and hangs
    it from its vertical origin; tate-chu-yoko blocks and point type's
    anchor use the font's em box centre. Fonts without vertical metrics
    are laid out exactly as before.
  • Hiragino's tables give the values the layout assumed (one em, origin
    0.88 em), so Japanese vertical type in it renders pixel for pixel the
    same; this is the base for proportional vertical metrics (vpal) and
    for fonts whose em box sits elsewhere.
  • test_fonts::vertical_font: Source Sans 3 with vhea/vmtx (and
    optionally VORG) built in code, one glyph 1.4 em tall hanging from
    1.1 em; tested with and without VORG.

First of a few small steps toward Japanese composition (the ROADMAP's "CJK composition for vertical type"), following the W3C Requirements for Japanese Text Layout and the OpenType spec (vhea, vmtx, VORG).

How it was tested

  • cargo test for text, engine, render, pdf, svg and tools passes (2,135), with the new test in tests_vertical.rs (the test font is built in code; nothing is committed).
  • Rendered vertical point and area type in Hiragino Mincho and Hiragino Sans before and after: identical images. Hiragino's vertical_glyph reads (1000, 880) for 国、、, ー and ゃ.
  • cargo fmt --check, cargo clippy --all-targets -D warnings, cargo xtask brands, layers pass; the web build compiles.

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm).
  • No panics in shipped code; table values outside a few ems are ignored.
  • Clean-room: behaviour from the OpenType spec and JLREQ.
  • No new assets.

🤖 Generated with Claude Code

…cal metrics

Upright glyphs in vertical type advanced one em (or their horizontal
advance, if wider) and turned about a fixed point 0.38 em above the
baseline. Fonts that carry vertical metrics now place them as they ask:

- `FontFace::vertical_glyph`: a glyph's advance down the column (`vmtx`)
  and the height of its vertical origin (`VORG`, else the glyph's top
  plus its top side bearing, as in TrueType fonts); `None` without
  `vhea`/`vmtx` or with values outside a few ems.
  `FontFace::ideographic_centre`: the em box centre from an ideograph's
  cell, else 0.38.
- The layout advances an upright glyph by its vertical advance and hangs
  it from its vertical origin; tate-chu-yoko blocks and point type's
  anchor use the font's em box centre. Fonts without vertical metrics
  are laid out exactly as before.
- Hiragino's tables give the values the layout assumed (one em, origin
  0.88 em), so Japanese vertical type in it renders pixel for pixel the
  same; this is the base for proportional vertical metrics (`vpal`) and
  for fonts whose em box sits elsewhere.
- `test_fonts::vertical_font`: Source Sans 3 with `vhea`/`vmtx` (and
  optionally `VORG`) built in code, one glyph 1.4 em tall hanging from
  1.1 em; tested with and without `VORG`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit a3109c9 into storytold:main Oct 7, 2026
h-a-n-a-s-h-i pushed a commit that referenced this pull request Oct 7, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bflatastic added a commit that referenced this pull request Oct 7, 2026
…343)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bflatastic added a commit that referenced this pull request Oct 7, 2026
@bflatastic

Copy link
Copy Markdown
Member

Thank you @imachus! This is merged. Upright glyphs in vertical type now take their cell from the font's vhea/vmtx/VORG. Building the test font in code from Source Sans 3 is a neat way to pin it. While reviewing it I fixed one doc comment in #383: vertical_glyph returns two values, not three.

Checked live: MS Gothic vertical columns render correctly, with the vert forms ﹁﹂ and 。 placed at the top right of their cells.

bflatastic pushed a commit to imachus/vectorcraft that referenced this pull request Oct 7, 2026
… top

Japanese layout measures leading from the top of one line's ideographic
em box to the next (the right side, in vertical type), not from baseline
to baseline. The Paragraph panel menu now offers both:

- `ParaStyle.leading_model`: RomanBaseline (as before, the default) or
  EmBoxTop. With EmBoxTop a line's leading is the space below it — the
  next line's em box top is this line's plus its leading, and the next
  baseline hangs from there by that line's tallest em box — and area
  type's first line touches the top of the frame (its em box top on the
  frame's top, at least Area Type Options' minimum). With baseline
  leading a line's leading stays the space above it.
- Lines of one size are exactly as far apart either way; the models
  differ for mixed sizes and for the first line of area type (fonts
  whose ascent isn't the em box top: Hiragino's nearly is).
- The em box top comes from the font's vertical metrics (storytold#343), else
  0.88 em. Written only when EmBoxTop.
- `text.setFormat {leadingModel: "romanBaseline"|"emBoxTop"}`; menu items
  Top-to-Top Leading / Bottom-to-Bottom Leading (checked as set); catalog
  rows in ja and zh-hant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants