# Pre-registration — 2026-11-27-phayan-thai-font-mark-stacking

```
run_id:        2026-11-27-phayan-thai-font-mark-stacking
product:       phayan
tier:          standard
written_at:    2026-11-27T01:45:00Z (sections 1 to 6); section 7 and the Gate B block after the adversary
workdir (W):   /Users/jakubzavada/Repositories/.in-progress/phayan-study/work
```

Data, tools and renders live in W, not in this run directory: `third-party-ops-guard` refuses copying files
into the skills folder (proposal P-01 of the vault run). This directory keeps the method, briefs, logs,
ledger and record.

## 1. Question

Of the 34 font families that Google Fonts lists with the Thai subset (metadata of 27 Nov 2026), taken as
the Thai-subset file the CSS2 API serves to desktop Chrome at weight 400 and 700, and of Apple's six
system Thai faces on macOS 27.0.1, in how many does a vowel or tone mark (a) collide with another glyph's
ink, and (b) get cut off by its own line box at CSS line heights normal, 1, 1.15, 1.2, 1.5 and 1.6 inside
an `overflow: hidden` element, per kind of letter-and-mark combination, and does the answer change
between the two text engines browsers use (HarfBuzz in Chrome, Firefox and Android; Apple CoreText in
Safari and on the iPhone)?

## 2. Method

### Inputs

- **Fonts (frame, a census, not a sample).** Every family in `https://fonts.google.com/metadata/fonts`
  whose `subsets` lists `thai`: 34 families, saved as `W/data/gf-metadata-2026-11-27.json`. For each,
  weight 400 (or the offered weight nearest 400) and 700 where offered, requested from
  `https://fonts.googleapis.com/css2?family=<family>:wght@<w>` with a desktop Chrome User-Agent; the
  `/* thai */` `@font-face` block's WOFF2 is downloaded, its SHA-256 recorded, decompressed to TTF with
  fontTools; a variable file would be instanced at the requested weight (none was: the API served static
  files). 64 files. Apple: Thonburi Regular and Bold, Sukhumvit Set Text and Bold, Ayuthaya, Krungthep,
  Silom, Sathu from `/System/Library/Fonts/Supplemental/`: 8 faces, each with the SHA-256 of the system
  file. 72 font files in total. `W/tools/fetch_fonts.py` → `W/data/fonts.json` (id, source, family,
  weight, URLs, hashes, `name` id 5 version, hhea/OS2 metrics, whether GSUB/GPOS carry a `thai` script).
  Phayan's own site font is Noto Sans Thai 400 to 700 through `next/font` at line heights 1.6 (reading
  text) and 1.15 (tight text); it is in the frame and is reported by name whatever it shows.
- **Test clusters (fixed before measuring).** `W/data/cases.json`, 67 strings in 13 groups, written by
  `W/tools/make_cases.py` from the cases Microsoft's "Developing OpenType Fonts for Thai Script" and the
  W3C "Thai Layout Requirements" draft name as the hard ones:
  G00 no marks (control) · G01 normal consonant + upper vowel · G02 normal consonant + tone mark ·
  G03 normal consonant + upper vowel + tone mark (incl. ที่, นี้) · G04 tall consonant (ป ฝ ฟ ฬ) + upper
  vowel · G05 tall + tone · G06 tall + upper vowel + tone · G07 ญ/ฐ + lower vowel or phinthu ·
  G08 ฎ/ฏ + lower vowel or phinthu · G09 lower vowel + tone · G10 sara am + tone (น้ำ) · G11 thanthakhat,
  alone and stacked (ธิ์, ดิ์) · G12 wrong typing order (ก่ิ, นำ้, ป่ี, a doubled tone ก่่).
- **Running Thai (context only).** 300 random Thai Wikipedia articles (plain-text extracts, title, page
  id and revision id kept), `W/tools/freq.py 300 W/data/freq`: occurrences of each group's shape per
  10 000 Thai code points and the number of articles containing it.

### Measurements

- **M1 lab collisions.** `W/tools/measure_lab.py W/data/lab.jsonl`. Per font, `hb-shape` (HarfBuzz 14.3.0,
  `--cluster-level=2`, JSON) shapes every case; `W/tools/raster` (Swift, CoreText on macOS 27.0.1) shapes
  the same case with CoreText and rasterises every glyph of both shapings separately with the same
  CoreGraphics path fill at 256 px per em. Per pair of glyphs: overlapping ink pixels (coverage ≥ 128 of
  255 in both), and the gap in pixels when they do not touch. One row per font × case × engine
  (72 × 67 × 2 = 9 648 rows).
  - A glyph is a **mark** when its advance is below 0.05 em.
  - A row **collides** when some pair with at least one mark overlaps by at least 9 pixels and by at least
    1 % of the smaller glyph's ink. Sensitivity reported at (3 px, 0.25 %) and (9 px, 5 %). Overlap of two
    spacing glyphs (letters touching letters) is reported separately and is not a collision.
  - A font **collides in a group** when any case of the group collides at that weight.
  - Rows where HarfBuzz returns glyph 0 or CoreText uses a font other than the measured one are
    `missing` or `fallback`, excluded from collision counts and counted on their own.
  - **Wrong order (G12):** a row is `normalised` when its glyph list and positions equal those of the same
    letters in canonical order (G03-01, G10-02, G06-01, G02-01), otherwise `as typed`; collisions counted
    as above.
  - Stack height: highest ink above the baseline and lowest ink below it, in em. From these, per font and
    engine, the **line height at which two lines of text cannot touch** = highest canonical-case ink
    minus lowest canonical-case ink, in em.
- **M2 browser clipping.** `W/tools/node/browser_render.mjs <engine> <font>` with Playwright 1.59.0,
  Chromium 147.0.7727.15 (HarfBuzz) and WebKit 26.4 (CoreText); Firefox does not launch on this Mac
  (`browserType.launch: Timeout 30000ms exceeded`, twice, recorded) and is not substituted. Each case at
  each of six line heights in its own absolutely positioned block (`width: max-content`, 64 px, black on
  white), the Google file loaded from the downloaded WOFF2 through `@font-face`, the Apple face through
  `local('<PostScript name>')`; `document.fonts.check` recorded. A full-page screenshot with
  `overflow: visible` and one with `overflow: hidden`. `W/tools/browser_analyse.py` counts ink
  (luminance < 128) inside the block's box and above, below and beside it. A cell is **clipped** when ink
  above plus below the box is at least 1 % of the cell's ink (sensitivity 0.25 % and 5 %); side overhang is
  reported, not counted. Rows: 72 × 67 × 6 × 2 = 57 888.
- **M3 engine agreement.** (a) Per font × canonical case, whether HarfBuzz and CoreText agree on
  `collides`, and the largest difference in any glyph's position (px at 256/em). (b) Chromium against
  WebKit renders of the same cell at line height normal: best intersection over union of the ink masks
  within ±3 px; the cells where the lab says the two engines place glyphs differently (> 2 px) are compared
  with the cells where it says they agree.
- **M4 iPhone check.** One iOS 27.0 simulator of our own (`PHAYAN-STUDY iPhone 17 Pro`), Mobile Safari, a
  page served from this Mac on port 3511 before the site's dev server takes it. Ten fonts (Noto Sans Thai
  400 and 700, Sarabun, Kanit, Prompt, IBM Plex Sans Thai, Mitr, Anuphan at 400; Thonburi; Sukhumvit
  Set Text) × the 12 cases of G03 and G06 × line heights normal and 1.5, visible and hidden, at 32 CSS px.
  `xcrun simctl io screenshot`; the same clipping rule; agreement with WebKit-on-Mac per cell. A check,
  not a measurement per device: one capture per page, a simulator, not a phone.
- **M5 visual check (the orchestrator, by eye, not DeepSeek).** For each group with at least one collision,
  up to 6 colliding and 6 non-colliding HarfBuzz composites drawn at random (Python `random.Random(20261127)`),
  each glyph in its own colour with overlapping ink in black; and 20 clipped and 20 unclipped browser
  cells from the hidden pass. Each judged "visible defect / no visible defect" and recorded with the
  automatic verdict; agreement reported as counts.

### Repetitions

The renderers are deterministic: one run per cell by the measuring session, a full re-execution by a second
session from fresh downloads (hashes must match; any differing row is reported), and an independent
derivation on 12 fonts by a session given only the question and the definitions.

### Discard rule

Nothing measured is discarded. A font whose browser face fails `document.fonts.check` is reported as not
loaded and left out of M2 counts for that engine. Rows flagged `missing` or `fallback` are counted on their
own.

### Falsified before this file was frozen (W/falsify/)

- F1 collision detector: Sarabun กี่ with the tone mark moved a quarter em down — overlap 833 px on the
  mark pair; the true positions — 0 on all pairs.
- F2 clipping detector: line height 3 → 0 of 67 cells clipped; line height 0.4 → 67 of 67.
- F3 dotted-circle detector: **failed its positive control** (58 of the 72 files have no U+25CC glyph, and
  neither engine inserted one for a lone mark, a doubled tone or a wrong order). The dotted-circle measure
  is dropped and replaced by `normalised / as typed` for G12.
- F4 missing glyph: Latin A in the Thai subset — HarfBuzz gid 0 flagged; CoreText falls back to Helvetica,
  flagged as fallback.

## 3. Expectation

- E1. In HarfBuzz, at weight 400, at least 24 of the 34 Google families show no collision in any canonical
  case.
- E2. The group with the most colliding Google families (400, HarfBuzz) is a tall-consonant group (G04,
  G05 or G06).
- E3. HarfBuzz and CoreText agree on `collides` in at least 95 % of canonical font × case cells of the
  Google files.
- E4. All six Apple faces show no collision in any canonical case under CoreText.
- E5. With `overflow: hidden` in Chromium, at least 9 of the 34 Google families (400) clip at least one G03
  or G06 case at line height 1.5; at least 17 clip at line height normal; fewer clip at 1.6 than at 1.5.
- E6. For G12 wrong order, at least one sequence is rendered `as typed` (not normalised) in at least half
  of the fonts in each engine.
- E7. Noto Sans Thai 400 does not clip any case at line height 1.6 in either engine.

## 4. Falsifier

- E1 refuted if fewer than 24 Google families are collision-free.
- E2 refuted if the largest count belongs to any group outside G04 to G06.
- E3 refuted if agreement is below 95 %.
- E4 refuted if any Apple face collides in any canonical case under CoreText.
- E5 refuted part by part: fewer than 9 at 1.5; fewer than 17 at normal; 1.6 not lower than 1.5.
- E6 refuted if fewer than half of the fonts render any G12 sequence `as typed` in an engine.
- E7 refuted if any Noto Sans Thai 400 cell is clipped at 1.6 in either engine.

## 5. Abandonment condition

- `METHOD_BROKEN` if M3(b) shows the browsers do not follow the lab: in cells where the lab finds the two
  engines' positions identical, Chromium-versus-WebKit IoU median below 0.80.
- `NOT_MEASURABLE` for M2 if more than 20 % of font files fail to load in a browser; the lab arm then
  stands alone and the article says so.
- `NULL` (still published) if no font collides and none clips at 1.5: the answer is then that the fonts
  are not the problem.

## 6. Estimate

- **What the run needs from Jakub:** nothing. Every input is a public download or a font already on this
  Mac; no account, no production data.
- Machine time: lab about 15 min, browsers about 40 min, Wikipedia 5 min, iPhone check 30 min; with
  re-execution, derivation and three critics about 6 hours of wall clock.
- Money: 0 USD in external interfaces; child sessions on DeepSeek.
- Claims expected in the ledger: type M (collisions, clipping, engine agreement, line-height minimums,
  frequency), type S (what the Google CSS2 API serves, the OpenType Thai spec's named cases, CSS
  line-height definition), no type D, no type U.

## 7. Adversary dispositions

Adversary A1b (`ADVERSARY.md`, 32 objections; A1 on the judgement tier died on HTTP 429, see RECORD D-1).
Changed 29, accepted as a stated limitation 3, rejected 0 (two partial rejections inside changed items).

- A-1 changed: rows whose text has a combining mark but whose shaping has no mark glyph are
  `not_measurable_composed` and counted on their own; Thonburi and Thonburi Bold are expected there.
- A-2 changed: group G13, a mark followed by another letter (กัป, กัฟ, ที่ป, กุฎ, ปั้ป).
- A-3 changed: group G14, leading-vowel words (เก่า, ไม่, โต๊ะ, ใช่, ให้). 77 cases in all.
- A-4 changed: the clipping verdict is ink above plus below the box; side overhang is its own count
  (`clipped_side`) with the same thresholds.
- A-5 changed: Apple faces load in the browser from the same TTF the lab measures (`url()`), not `local()`.
- A-6 changed: NOT_MEASURABLE for the Apple browser arm if any Apple file fails to load in an engine; any
  `font_loaded: false` is reported by name.
- A-7 changed: `measure_lab.py` asserts 64 Google files from 34 families, the eight Apple PostScript names and
  77 cases before the first row.
- A-8 changed: the unit is the family (34 Google, 6 Apple); file counts (64, 8) are reported beside it; for a
  family, 400 is the headline weight and 700 is reported inside it.
- A-9 changed: the headline counts canonical cases only (G00 to G11, G13, G14); G12 is reported separately.
- A-10 changed: `W/tools/verdict.py` holds the verdict rule as code and every lab row carries its verdict at
  three thresholds; controlled by F5.
- A-11 changed: a glyph is a mark by the Unicode category of the character it maps to (Mn), plus the
  nikhahit half of sara am (U+0E33 with zero advance); the advance rule remains only for unmapped glyphs.
- B-1 changed in part: AAT-shaped Apple rows are labelled as such; stripping `morx` is rejected, because a
  font with its shaping table removed is not a font anyone renders.
- B-2 changed: agreement is reported with Cohen's kappa, the disagreement rate restricted to cells where
  either engine collides, and the direction of each disagreement.
- B-3 changed: the Chromium-versus-WebKit search window is ±16 px and the best shift is recorded; the
  abandonment rule in section 5 is replaced (amendment AM-2).
- B-4 changed: a collision also needs overlap that survives a one-pixel erosion (at least three pixels
  thick); F5 controls: tone pushed 0.5 px into the vowel is not a collision at the main threshold, 2 px is.
- B-5 changed: per cell the browser arm records the smallest line height that holds all the ink
  (`min_lh_em`, from the fixed centre of the line box); per font the largest over canonical cases is reported
  as the answer to (b), with the counts at fixed line heights as the secondary view.
- B-6 changed: the mechanism variable is whether HarfBuzz moved any glyph (`dx_dy_nonzero`), not the presence
  of a `thai` GPOS record.
- B-7 changed: `W/tools/engine_follow.py` compares each browser's render with both lab shapings drawn at the
  same 64 px; Chromium is expected nearer HarfBuzz and WebKit nearer CoreText where the two differ.
- B-8 accepted as a limitation: Skia and CoreGraphics rasterise differently; the lab arm states that its two
  shapings share one rasteriser.
- B-9 changed: a cell is also clipped when the cut ink is at least 20 px at 64 px font size, whatever its
  share of the cell.
- B-10 changed in part: the visual check is blind (plain black renders, shuffled, verdicts in a key file read
  after judging); the judge is still the orchestrator, stated as a limitation.
- C-1 changed: the conditions (separate mark glyphs, vertical cut, isolated block at 64 px) are stated beside
  the headline; G13 and G14 add multi-letter strings.
- C-2 changed: the primary result is the matrix group × weight × engine; the font count is a summary with the
  distribution of how many groups each family collides in.
- C-3 changed: side overhang reported as `clipped_side` (what a fixed-width `overflow: hidden` element cuts).
- C-4 accepted as a limitation: line breaking inside paragraphs is not measured.
- C-5 changed: Noto Sans Thai (the site font) and Thonburi (its fallback on Apple devices) are reported first,
  and rendered again at 18 px at line heights 1.15 and 1.6 in both engines.
- C-6 changed: E4 is restated over the Apple faces whose marks are separate glyphs.
- C-7 changed: direction of disagreements reported; Sukhumvit Set Text is already in M4.
- C-8 changed: families tagged text (Google category Sans Serif or Serif) or display (Display, Handwriting);
  the headline counts text families, display families on a second line.
- C-9 changed in part: the re-execution first re-requests CSS and WOFF2 and compares hashes; on a mismatch both
  sets are recorded and the headline stays on the first set. The full re-render is kept, because it also tests
  that the written method can be run by another session.
- C-10 changed: each collision carries `mark-base` or `mark-mark`, reported separately.
- C-11 accepted as a limitation: Android's own installed Noto Sans Thai is not measured.

## 8. Amendments

- **AM-1** 2026-11-27T02:20Z, post_hoc: false. All section-7 changes above. Disclosure: before freezing, the
  instruments were tried on three files (Sarabun 400, Charm 400, Thonburi) as sizing probes; those numbers are
  not evidence and no probe row enters the dataset. The probe showed Sarabun collisions in G06 and Sarabun
  cells cut at line height 1.5; E5 is left exactly as first written.
- **AM-2** 2026-11-27T02:20Z, post_hoc: false. Section 5's METHOD_BROKEN rule is replaced: METHOD_BROKEN if, in
  the cells where the lab's two shapings place some glyph more than 2 px apart (at 256 px per em), Chromium is
  not nearer the HarfBuzz drawing or WebKit not nearer the CoreText drawing in more than a third of those cells.
  The absolute Chromium-versus-WebKit IoU is reported, not used as a gate: the probe showed about 0.85 between two
  renders of identical positions, the rasterisers' own difference (B-8).
- **AM-3** 2026-11-27T02:20Z, post_hoc: false. Sources: the source session (S-1) found that Microsoft's Thai
  OpenType guide names two of the cases (decomposing sara am, removing the tail of ญ before a lower vowel) and
  the W3C Thai layout requirements name none; the case list is the run's own, built from the standard problem
  classes, and the article says so. The Google CSS2 documentation does not describe unicode-range subsets, so the
  served CSS of every request is saved (`W/data/css/`) as the evidence for what the API sends.
- **AM-4** 2026-11-27T02:20Z, post_hoc: false. Firefox is out (does not launch under Playwright 1.59.0 here).
- **AM-5** 2026-11-27T02:20Z, post_hoc: false. E4 restated (C-6): every Apple face whose marks are separate
  glyphs shows no collision in any canonical case under CoreText; the composed faces are reported as not
  measurable for (a). Refuted if any such face collides.


# Amendments after the freeze (append-only)

PREREGISTRATION.md is frozen at 889ae816b311; amendments after that point are kept here.

- **AM-6** 2026-11-27T02:45Z, post_hoc: false. At H RESEARCH's request (Thonburi is the default Thai face on
  iPhone and Mac and cannot stay "not measurable"), a pixel arm for (a): `W/tools/components.py` counts
  connected ink islands (8-connected, islands under 0.1 % of an em squared ignored) of the whole cluster drawn
  by CoreText against the sum of the islands of each character drawn alone from its nominal glyph; fewer islands
  in the cluster means a mark touches or overlaps something (`touch_by_components`). Apple's lone-mark glyphs
  carry a dotted ring, found as the ink shared by every mark glyph and removed before counting. Cases with ญ or ฐ
  are left out (their tail is removed by substitution, which also lowers the count). Calibration before use:
  on every font whose marks are separate glyphs, `touch_by_components` against the lab's `loose` verdict
  (CoreText rows), reported as a 2×2 table; the arm is used on Thonburi only if agreement is at least 90 % and
  false positives are under 5 % of cells; otherwise Thonburi is reported with clipping and the visual check only.
  Disclosure: the arm was tried on Sarabun 400, Noto Sans Thai 400, Thonburi and Sukhumvit Set Text while it was
  built (sizing probes, not evidence).

- **AM-7** 2026-11-27T09:10Z (Bangkok clock 09:10, UTC 02:10), post_hoc: true. The independent derivation (D-1)
  reported that Chrome does not apply Thonburi's AAT shaping when the file is loaded through `@font-face`, while
  the installed Thonburi renders like the lab's CoreText and HarfBuzz shapings. A-5 had moved the Apple faces in
  the browser arm from `local()` to the TTF file. Nobody loads an Apple system face as a web font, so the reader's
  case is the installed face named in CSS. Added: the eight Apple faces rendered again in both engines with
  `font-family: '<installed family>'` and no `@font-face` (`SYSFONT=1`), output `data/renders-sys`, analysed the
  same way. For Apple faces the article reports the installed path; the web-font path is reported as a
  secondary row. Seen before this amendment: the derivation's report, the lab arm's collision counts; not seen:
  any browser-arm result of M-A.

- **AM-8** 2026-11-27 (after M-A), post_hoc: true. The component arm's ring removal failed on Thonburi: the code
  point of every mark maps to a ".key" glyph (the mark inside a 12-dot ring, drawn for keyboards), the dots differ
  by a pixel between glyphs, so the intersection left them in, and every Thonburi cluster read as "touching" (64 of
  64). Change: a mark's part count is taken from the glyph of the same name without ".key" when the font has one
  (Thonburi and Thonburi Bold do). Output `data/components-v2.jsonl`; `data/components.jsonl` stays as the record
  of the failed version. The rerun was started by the orchestrator, not a measuring child (RECORD, deviation).

- **AM-9** 2026-11-27 (while writing), post_hoc: true. Added a check of which installed face Chromium and WebKit on
  the Mac use for Thai when a page names no font (`W/tools/node/fallback.mjs`, `W/fallback/`): the unstyled render
  and the `sans-serif` render were pixel-identical to Thonburi in both engines. Run by the orchestrator. The iPhone's
  fallback was not tested, so the article claims it for the Mac only.
