pdftract/notes/bf-3ayf6.md
jedarden a014a697c9 docs(bf-3n62c): document CLI execution attempt on degraded fixture
Documented attempt to execute pdftract CLI with OCR on degraded-200dpi.pdf.
Found that OCR feature requires leptonica system dependencies not currently
available in NixOS environment. CLI invocation and fixture file are valid,
but compilation fails due to missing lept.pc.

Acceptance criteria:
- Command executes: PARTIAL (valid syntax, build fails due to dependencies)
- Process starts: FAIL (blocked by missing leptonica headers)
- OCR process begins: FAIL (build prevents execution)

This is an environmental limitation, not a code defect.

References: bf-3n62c
2026-07-06 18:11:39 -04:00

3.3 KiB

Normal Glyphs Presence Assertion — bf-3ayf6

Overview

Extended the CMAP test to verify that normal glyphs (A, B, space, C) ARE PRESENT in the CMAP output. This complements the unmapped glyph absence assertions added in bead bf-5d2id.

Changes Made

Modified File: crates/pdftract-core/tests/cmap_unmapped_glyphs.rs

Test: test_cmap_unmapped_glyph_skip (lines 18-106)

Changes:

  1. Extended CMAP data (line 30):

    • Changed from single mapping beginbfchar 1 <00> <0041> endbfchar
    • To multiple mappings beginbfchar 4 <00> <0041> <01> <0042> <02> <0020> <03> <0043> endbfchar
    • Now includes A, B, space, and C glyphs
  2. Added normal glyphs presence assertions (lines 41-75):

    • Assert glyph 'A' is present: map.lookup(&[0x00]) returns Some(&['A'][..])
    • Assert glyph 'B' is present: map.lookup(&[0x01]) returns Some(&['B'][..])
    • Assert glyph 'space' is present: map.lookup(&[0x02]) returns Some(&[' '[..])
    • Assert glyph 'C' is present: map.lookup(&[0x03]) returns Some(&['C'][..])
  3. Updated count verification (lines 77-85):

    • Changed from map.len() == 1 to map.len() == 4
    • Updated message to reflect all 4 normal glyph mappings
  4. Fixed unmapped glyphs validity check (lines 95-103):

    • Removed conflicting assertion that expected 1 mapping
    • Updated logic to check all entries have valid Unicode destinations
    • Changed condition to properly detect invalid entries

Acceptance Criteria Status

  • Test asserts normal glyphs are present in CMAP - All 4 glyph types (A, B, space, C) verified present with explicit assertions
  • Multiple glyph types are verified - Includes Latin letters (A, B, C) and whitespace (space)
  • Assertions provide clear failure messages - Each assertion includes specific message identifying which glyph failed and why
  • Test compiles and runs without panics - Test runs successfully with cargo test --test cmap_unmapped_glyphs test_cmap_unmapped_glyph_skip

Verification

Test Run

$ cargo test --test cmap_unmapped_glyphs test_cmap_unmapped_glyph_skip
   Running tests/cmap_unmapped_glyphs.rs (target/debug/deps/cmap_unmapped_glyphs-3a20d3c83b7275bc)

running 1 test
test test_cmap_unmapped_glyph_skip ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out

Inspected Output

The test now prints CMAP structure inspection showing all 4 normal glyphs:

=== CMAP Output Structure Inspection ===
  Source bytes: [00]
  Target chars: "A" (Unicode: [41])
  Source bytes: [01]
  Target chars: "B" (Unicode: [42])
  Source bytes: [02]
  Target chars: " " (Unicode: [20])
  Source bytes: [03]
  Target chars: "C" (Unicode: [43])
  Total mappings: 4
=== End CMAP Inspection ===

Notes

  • This is the positive case test complementing bf-5d2id's negative case test
  • Both tests now work together: unmapped glyphs are absent, normal glyphs are present
  • The test covers multiple glyph categories: letters (A, B, C) and whitespace (space)
  • All assertions have specific, actionable failure messages
  • Depends on: bf-5d2id (unmapped glyph absence assertion)
  • References: bf-3tzsn (fixture exploration)

Status

PASS - All acceptance criteria met. Normal glyphs presence assertions added successfully.

Date

2026-07-06