Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ No “Must” row is unowned. The owner is the story that closes it: `US1 creato
| 20 | JavaScript execution, 3D, multimedia, geospatial, public-key encryption | PDFsharp: no or partial. PdfPig: no. | Non-goal: actions may be copied or refused with a warning; nothing is executed, and no new encryption surface is added. | 1.1 (excluded) | Product boundary (ADR-001) | None by design | Out-of-scope statement in `README.md` and ADR-001 | Out of scope |
| 21 | Drop-in source or binary compatibility with PDFsharp or PdfPig | N/A | Non-goal: capability parity only; no reference package is referenced by the suite. | 1.1 (excluded) | Product boundary (ADR-001) | None by design | ADR-001 and the dependency check in quickstart step 8 | Out of scope |

| 22 | Reading the fonts a document uses, and whether each program travels with it | PDFsharp: no dedicated API (font resolution is internal). PdfPig: fonts are reachable through a page's letters, not as a document-level answer. | Must: one entry per font keyed by the object its resource names, with its kind, program, encoding, `/ToUnicode` presence and the pages that select it; a resource that does not resolve and a font that states no descriptor are reported as warnings rather than dropped. | 1.6 (Unreleased) | US3 reading | `PdfFontInspectorTests.Reports_every_font_the_document_states`, `Reports_an_embedded_subset_with_its_program_and_pages`, `Reports_a_font_that_carries_no_program`, `Resolves_a_composite_font_to_its_descendant`, `Reads_a_font_a_form_paints_with`, `Reports_a_resource_that_names_no_object`, `Reports_the_fonts_of_a_real_world_document`, `Reads_the_fonts_of_a_document_it_encrypted_itself`, `Opens_an_encrypted_document_with_its_password`, `Reports_a_type3_font_as_carrying_its_own_glyphs`, `Reports_a_type3_font_that_states_no_glyphs`, `Reports_a_cid_type0_font_with_a_custom_encoding`, `Reports_where_each_program_is_stored`, `Reports_a_composite_font_that_names_no_descendant`, `Reports_a_multiple_master_font`, `Recognises_a_subset_tag_and_rejects_a_name_that_only_looks_like_one`, `Reads_the_resources_a_page_inherits_from_the_tree`, `Stops_the_walk_at_the_nesting_depth_it_is_given`, `Returns_no_font_for_a_document_that_stays_closed`, `Refuses_a_null_source` | Pending for the fixture that pins every other branch: it is built in memory by `PdfContentFixtures.Fonts()`, so a validator run needs it written to disk first. The real-world leg **was** run: `uv run --with pikepdf --with pypdf python docs/tools/validate-pdf.py tests/SharpCorePDF.Tests/Assets/parity/labelled/table.pdf` (`qpdf check: no problems`, 1.3, 1 page, 7 objects) and a pikepdf listing of the same file's `/Font` entries (`F1` Helvetica, `F2` Courier, `F3` Times-Roman, all `/Type1`, `/WinAnsiEncoding`, no `/FontDescriptor`) | Implemented (2026-11-06) — twenty tests are in the suite, the real-world leg agrees with pikepdf on the same file, and the mutation reading is recorded in `docs/mutation-testing.md`: 97.44% over `PdfFontDescriptorLookup.cs`, 94.44% over `FontAccumulator.cs`, 90.91% over `PdfFontInspector.cs`, with the single survivor in the last two explained as unobservable |
| 22 | Reading the fonts a document uses, and whether each program travels with it | PDFsharp: no dedicated API (font resolution is internal). PdfPig: fonts are reachable through a page's letters, not as a document-level answer. | Must: one entry per font keyed by the object its resource names, with its kind, program, encoding, `/ToUnicode` presence and the pages that select it; a resource that does not resolve and a font that states no descriptor are reported as warnings rather than dropped. | 1.6 (Unreleased) | US3 reading | `PdfFontInspectorTests.Reports_every_font_the_document_states`, `Reports_an_embedded_subset_with_its_program_and_pages`, `Reports_a_font_that_carries_no_program`, `Resolves_a_composite_font_to_its_descendant`, `Reads_a_font_a_form_paints_with`, `Reports_a_resource_that_names_no_object`, `Reports_the_fonts_of_a_real_world_document`, `Reads_the_fonts_of_a_document_it_encrypted_itself`, `Opens_an_encrypted_document_with_its_password`, `Reports_a_type3_font_as_carrying_its_own_glyphs`, `Reports_a_type3_font_that_states_no_glyphs`, `Reports_a_cid_type0_font_with_a_custom_encoding`, `Reports_where_each_program_is_stored`, `Reports_a_composite_font_that_names_no_descendant`, `Reports_a_multiple_master_font`, `Recognises_a_subset_tag_and_rejects_a_name_that_only_looks_like_one`, `Reads_the_resources_a_page_inherits_from_the_tree`, `Stops_the_walk_at_the_nesting_depth_it_is_given`, `Returns_no_font_for_a_document_that_stays_closed`, `Refuses_a_null_source` | Closed on 2026-11-14 for the in-memory fixture too: `PdfFontInspectorTests.Writes_the_font_fixture_the_external_validator_reads` writes `PdfContentFixtures.Fonts()` to `%TEMP%/scpdf-fonts-fixture.pdf`, and `uv run --with pikepdf --with pypdf python docs/tools/validate-pdf.py` read it (PDF 1.7, 4 pages, 41 objects, 5 streams decoded, 0 failed). `qpdf --check` reports one repairable problem — object 9's page tree child states no `/Resources` — which is deliberate: that page is the "states no resources at all" shape the fixture exists for. A pikepdf walk of the object graph listed **17 font objects / 15 unique `/BaseFont` names**, exactly the names the inspector returns: `ABCDEF+Arial`, `Helvetica`, `Courier`, `ZapfDingbats`, `XYZABC+SomeFont`, `ZapfType3`, `MinionMM`, `Loose`, `ABCDEFHelvetica`, `abcDEF+Weird`, `EmptyType3`, `ABCDEF+X`, `FontFileOne`, `CffOne`, `BaseEncoded`. The real-world leg remains: `uv run --with pikepdf --with pypdf python docs/tools/validate-pdf.py tests/SharpCorePDF.Tests/Assets/parity/labelled/table.pdf` (`qpdf check: no problems`, 1.3, 1 page, 7 objects) and a pikepdf listing of the same file's `/Font` entries (`F1` Helvetica, `F2` Courier, `F3` Times-Roman, all `/Type1`, `/WinAnsiEncoding`, no `/FontDescriptor`) | Implemented (2026-11-06) — twenty tests are in the suite, the real-world leg agrees with pikepdf on the same file, and the mutation reading is recorded in `docs/mutation-testing.md`: 97.44% over `PdfFontDescriptorLookup.cs`, 94.44% over `FontAccumulator.cs`, 90.91% over `PdfFontInspector.cs`, with the single survivor in the last two explained as unobservable |

## 1.1 scope decision (D3, 2026-10-22)

Expand Down
36 changes: 36 additions & 0 deletions tests/SharpCorePDF.Tests/PdfFontInspectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,42 @@ public async Task Reports_every_font_the_document_states()
Assert.Equal(expected, result.Items.Select(font => font.BaseFont));
}

/// <summary>
/// Writes the in-memory font fixture to disk, so the external <c>pikepdf</c>/<c>pypdf</c> run recorded
/// in <c>docs/parity.md</c> row 22 reads the same bytes, and pins the font tuples that run lists.
/// </summary>
[Fact]
public async Task Writes_the_font_fixture_the_external_validator_reads()
{
var path = Path.Combine(Path.GetTempPath(), "scpdf-fonts-fixture.pdf");

await File.WriteAllBytesAsync(path, PdfContentFixtures.Fonts(), Token);

var result = await FontsAsync(await File.ReadAllBytesAsync(path, Token));

string[] expected =
[
"ABCDEF+Arial",
"Helvetica",
"Courier",
"ZapfDingbats",
"XYZABC+SomeFont",
"ZapfType3",
"MinionMM",
"Loose",
"ABCDEFHelvetica",
"abcDEF+Weird",
"EmptyType3",
"ABCDEF+X",
"FontFileOne",
"CffOne",
"BaseEncoded",
];

Assert.Equal(expected, result.Items.Select(font => font.BaseFont));
Assert.True(new FileInfo(path).Length > 0);
}

/// <summary>A subset that carries its program is reported with the program, the encoding and its pages.</summary>
[Fact]
public async Task Reports_an_embedded_subset_with_its_program_and_pages()
Expand Down
Loading