Skip to content

brandon-julio-t/react-pdf-textkit-codepoints-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React PDF Textkit Empty Glyph Codepoints Reproduction

This is a minimal reproduction for a @react-pdf/textkit@6.3.0 text mapping bug.

What It Shows

textkit trusts glyph.codePoints returned by the font layout engine. If a glyph object has codePoints: [], textkit loses the source-character mapping for that glyph.

This repro uses real fontkit@2.0.4 and a real Roboto font from @fontsource/roboto. It first calls font.getGlyph(gid) by glyph id, then calls font.layout("AB"). The first glyph returned by font.layout() has empty codePoints.

No PDF renderer is involved. The failure is isolated to @react-pdf/textkit handling a fontkit glyph run with an empty codePoints entry.

Run

bun install
bun run repro

With unpatched @react-pdf/textkit@6.3.0, this fails because the first glyph still has empty codePoints.

Expected behavior: textkit should repair missing/empty glyph codePoints from the input run string when the glyph sequence remains unambiguous.

Observed Output

fontkit glyph.codePoints after getGlyph(gid): [ [], [ 66 ] ]
Text: AB
Expected codePoints: [ 65, 66 ]
Actual textkit glyph.codePoints: [ [ 66 ] ]
Actual textkit stringIndices: [ 0 ]
Actual textkit glyphIndices: [ 0 ]
AssertionError [ERR_ASSERTION]: textkit should preserve source character mapping when fontkit returns a glyph with empty codePoints

The first character (A, code point 65) is lost from the final glyph mapping.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors