Repository navigation
Conversation
Fixes storytold#2547 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Builds on storytold#2556. Ș ș Ț ț are U+0218..U+021B (Latin Extended-B), outside the Latin Extended-A block storytold#2556 routes to the Latin face, so Romanian text still went to the CJK CID font, which has no glyph for them: printed boxes followed by a full-em gap. They now take bytes 0x01..0x04 of each face's /Differences encoding as uni0218..uni021B and are measured like S and T. The uniXXXX names are found both by fonts that name the glyphs so (TeX Gyre Heros has no scommaaccent) and by viewers that map a name to its code point; the AGL name Tcommaaccent would map to the cedilla letter U+0162. The resource now also carries /Widths: a viewer takes a standard font's advances from its own metrics by glyph name, which have no uni0219, so ș advanced by nothing and overprinted the next letter (seen with poppler). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JadgGo4G2GHaAMNb3qyygk
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Character mappings crates/pdf/src/metrics.rs |
Character tables and lookups map supported Latin Extended-A and Romanian comma-below letters to glyph names and ASCII base characters. |
Text run classification and encoding crates/pdf/src/lib.rs |
Text is grouped into ANSI, Extended, or CID runs. Extended characters use per-face resource slots and widths. |
Font resource emission and rendering tests crates/pdf/src/lib.rs, crates/pdf/src/tests.rs |
Serialization emits Type1 Extended resources with face-specific widths and Differences encodings. Tests check character mappings, routing, and resources across eligible font faces. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant text_rotated
participant EncodingHelpers
participant PDFSerialization
text_rotated->>EncodingHelpers: classify and encode text runs
EncodingHelpers-->>text_rotated: return run encodings and font slots
text_rotated->>PDFSerialization: provide ANSI, Extended, and CID strings
Suggested reviewers: silvertree2010, fredapps
Merge Risk: 
Low · up to 8c755
-
Some viewers relying on standard font glyphs may display missing Romanian letters. The reported tested viewers rendered them correctly.
Architecture risk: 
Low · up to 4831a
-
The change affects 1 system.
Changed systems:
cratesArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — crates (service) was modified; 3 changed files map to changed impact.
Before / after behavior
- observed — Modified behavior in crates/pdf/src/lib.rs: The crate documentation now says Latin Extended-A characters missing from WinAnsiEncoding are rendered through a second resource in the same face, while other unsupported characters use the CID font.
- observed — Modified behavior in crates/pdf/src/lib.rs: Adds a font-slot range for one Latin Extended-A resource per standard face.
needs_cidnow excludes characters supported byext_code, so those characters are assigned to the extended resource rather than the CID font. - observed — Modified behavior in crates/pdf/src/lib.rs: Adds mappings between supported Latin Extended-A and Romanian comma-below characters and their extended encoding bytes, plus per-face widths for codes 1–255; unmapped codes receive width zero.
- observed — Modified behavior in crates/pdf/src/lib.rs: Adds ANSI, extended, and CID run classification and a hex-string encoder for extended runs. Extended strings encode each character using
ext_code, falling back to?if no code is available.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
I checked the comma-below encoding and per-glyph widths in the changed code, then rendered an original mixed ANSI/extended-run Romanian sample with MuPDF. Ș/ș/Ț/ț render with visible commas below and advance without colliding with adjacent text; both MuPDF and Poppler |
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the first hunk: the PDF writer's documentation now says Latin Extended-A letters that WinAnsiEncoding lacks (ő, ű, ł, č and so on) are set in the same standard face through a second resource with a /Differences encoding of standard glyph names; the title adds Romanian ș, ț, Ș and Ț (comma below) and says it is built on #2556. A /Differences array with standard glyph names (scommaaccent, tcommaaccent) is the right way to reach glyphs in the 14 standard fonts, but not every viewer's substitute font has those glyphs, so they may show as blanks: say which viewers were tried. The distinction between the cedilla letters (ş, ţ) and the comma-below letters (ș, ț) must be kept, since Romanian text uses the second. Text extraction should still give the right letters (a ToUnicode map is not present for standard fonts, so extraction may give the glyph names' mapped values). I did not read the code. Add tests for each of the four letters, a mix with other Latin Extended-A letters, and the width table for the new glyphs. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
Each of Ș ș Ț ț gets its own code (0x01..0x04), its uniXXXX glyph name and its base letter's width, apart from the cedilla letters Ş ş Ţ ţ; a run that mixes them with other Latin Extended-A letters stays in one resource. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JadgGo4G2GHaAMNb3qyygk
|
Thanks. A few points from the code, which the review didn't read:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JadgGo4G2GHaAMNb3qyygk
Stacked on #2556 (its commit is the first one here; only the top commit, PDF: set Romanian ș ț Ș Ț (comma below) in the Latin font too, is new). Part of #446.
Why
#2556 sets the Latin Extended-A letters (U+0100..U+017F) in the standard face, which covers Romanian ă/Ă. But Romanian ș ț Ș Ț are U+0218..U+021B, Latin Extended-B, so with #2556 they still go to the non-embedded STSong-Light CID font. Adobe-GB1 has no glyph for them: on Windows they print as boxes followed by a full-em gap (
Comand□ manuale,□tiin□e). Every Romanian document has them.What this changes
ext_codegives Ș ș Ț ț bytes 0x01..0x04 of the same per-face resource, and the/Differencesarray names themuni0218 uni0219 uni021A uni021B. TheuniXXXXform is found both by fonts that name these glyphs so (TeX Gyre Heros, poppler's Helvetica substitute, has noscommaaccent) and by viewers that map a glyph name to its code point. The AGL names would not do for Ț/ț: the AGL mapsTcommaaccentto the cedilla letter U+0162./FirstChar 1 /LastChar 255 /Widths. A viewer takes a standard font's advances from its own metrics by glyph name; those have nouni0219, so without widths ș advanced by nothing and overprinted the next letter (seen with poppler). Unused codes are 0.foldmeasures them like S and T, so wrapping and alignment use the right widths.How it was verified
cargo test -p gridcraft-pdf --lib: 19 passed.romanian_letters_use_the_latin_fontfails on Set ő, ű and other Latin Extended-A letters in the Latin PDF font #2556 without this commit (reverted and re-run).cargo clippy -p gridcraft-pdf --all-targets -- -D warnings,cargo fmt --check.pdftotextextracts them.Provenance
My own change, from the PDF spec (font
/Differences,/Widths) and the AGL specification; no other implementation consulted. AI-assisted (Claude Code) for @vioreltus, a native Romanian speaker who tested the print on Windows.🤖 Generated with Claude Code
https://claude.ai/code/session_01JadgGo4G2GHaAMNb3qyygk
Summary by CodeRabbit