Skip to content

Add per-font codepoint-coverage test for all 8 bundled fonts#212

Merged
kostub merged 1 commit into
masterfrom
feature/add-math-fonts-pr4
May 31, 2026
Merged

Add per-font codepoint-coverage test for all 8 bundled fonts#212
kostub merged 1 commit into
masterfrom
feature/add-math-fonts-pr4

Conversation

@kostub
Copy link
Copy Markdown
Owner

@kostub kostub commented May 30, 2026

Goal

Generalize the symbol-coverage test from Latin Modern to all 8 fonts — one XCTest method per font — with per-font allow-lists of known-missing commands, and document those gaps in the README.

Plan: docs/plans/2026-05-30-add-math-fonts.md (items 18–20)
LLD: docs/lld/2026-05-30-add-math-fonts.md

Stack

Commits

  • [item 18] Add per-font codepoint-coverage tests (allow-lists empty)
  • [item 19] Populate Fira Math / Noto Sans Math coverage allow-lists
  • [item 20] Document per-font symbol-coverage gaps in README

Coverage findings

All 8 fonts have full coverage of supportedLatexSymbolNames — no missing symbols found. The allow-lists for Fira Math and Noto Sans Math are empty (complete coverage confirmed). All 6 TeX-grade fonts (Latin Modern, XITS, Termes, New Computer Modern, Pagella, STIX Two) also pass with empty allow-lists.

The per-font test structure (assertAllSymbolsRenderInFont:name:allowList: + one method per font) is in place for easy future maintenance.

Testing

273 tests, 0 failures (swift test).

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request documents symbol coverage in the README and adds unit tests in MTTypesetterTest.m to verify that all LaTeX symbols render correctly across multiple fonts. The reviewer suggested adding an assertion in the new helper method assertAllSymbolsRenderInFont:name:allowList: to verify that the underlying CoreText font (font.ctFont) is not NULL, ensuring that font loading failures are caught explicitly.

Comment thread iosMathTests/MTTypesetterTest.m Outdated
Comment on lines +1566 to +1568
- (void) assertAllSymbolsRenderInFont:(MTFont *)font name:(NSString *)fontName allowList:(NSSet<NSString*> *)allowList
{
NSArray<NSString*>* allSymbols = [MTMathAtomFactory supportedLatexSymbolNames];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When testing if an MTFont has successfully loaded, we should verify that its internal CoreText font (font.ctFont) is not NULL, rather than assuming it loaded or asserting that the MTFont instance itself is non-nil (since fontWithName:size: always returns a non-nil instance). Adding this assertion at the start of the helper method ensures that any font loading failure is caught immediately with a clear message.

- (void) assertAllSymbolsRenderInFont:(MTFont *)font name:(NSString *)fontName allowList:(NSSet<NSString*> *)allowList
{
    XCTAssertTrue(font.ctFont != NULL, @"Font %@ failed to load its underlying CoreText font", fontName);
    NSArray<NSString*>* allSymbols = [MTMathAtomFactory supportedLatexSymbolNames];
References
  1. When testing if an MTFont has successfully loaded its underlying font files, do not assert that the MTFont instance itself is non-nil (as fontWithName:size: always returns a non-nil instance). Instead, verify that the internal CoreText font (font.ctFont) is not NULL.

@kostub kostub force-pushed the feature/add-math-fonts-pr3 branch from d2a99a6 to 090db84 Compare May 31, 2026 08:31
@kostub kostub force-pushed the feature/add-math-fonts-pr4 branch from 1dad97b to f3e93fd Compare May 31, 2026 17:13
@kostub kostub changed the base branch from feature/add-math-fonts-pr3 to master May 31, 2026 17:13
@kostub kostub force-pushed the feature/add-math-fonts-pr4 branch from f3e93fd to dce545f Compare May 31, 2026 17:20
Loops over every bundled math font and asserts that each command in
supportedLatexSymbolNames renders with positive metrics.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kostub kostub force-pushed the feature/add-math-fonts-pr4 branch from dce545f to 1a73653 Compare May 31, 2026 17:23
@kostub kostub changed the title All-font codepoint coverage test + documented gaps Add per-font codepoint-coverage test for all 8 bundled fonts May 31, 2026
@kostub kostub merged commit 10b9c03 into master May 31, 2026
1 check passed
@kostub kostub deleted the feature/add-math-fonts-pr4 branch May 31, 2026 17:44
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.

1 participant