question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chevin font corrupts text copy pasted from PDF

See original GitHub issue

Describe the bug Chevin font corrupts text copy pasted from PDF.

To Reproduce

const Test = () => (
  <Document>
    <Page>
      <View>
        <Text style={styles.roboto}>
          The Portable Document Format (PDF) (redundantly: PDF format) is a file format developed by Adobe in the 1990s to present documents, 
          including text formatting and images, in a manner independent of application software, hardware, and operating systems.[2][3] 
          Based on the PostScript language, each PDF file encapsulates a complete description of a fixed-layout flat document, including the 
          text, fonts, vector graphics, raster images and other information needed to display it. PDF was standardized as an open format, 
          ISO 32000, in 2008, and no longer requires any royalties for its implementation.
        </Text>
        <Text style={styles.chevin}>
          The Portable Document Format (PDF) (redundantly: PDF format) is a file format developed by Adobe in the 1990s to present documents, 
          including text formatting and images, in a manner independent of application software, hardware, and operating systems.[2][3] 
          Based on the PostScript language, each PDF file encapsulates a complete description of a fixed-layout flat document, including the 
          text, fonts, vector graphics, raster images and other information needed to display it. PDF was standardized as an open format, 
          ISO 32000, in 2008, and no longer requires any royalties for its implementation.
        </Text>
      </View>
    </Page>
  </Document>
);

Font.register(
  {src: 'https://pdf-font-test.s3.eu-central-1.amazonaws.com/Chevin-Light.ttf',
  family: 'Chevin' },
);

Font.register(
  {src: 'https://pdf-font-test.s3.eu-central-1.amazonaws.com/Roboto-Light.ttf',
  family: 'Roboto' },
);

const styles = StyleSheet.create({
  roboto: {
    fontFamily: 'Roboto'
  },
  
  chevin: {
    fontFamily: 'Chevin'
  }
});

ReactPDF.render(<Test />);

REPL link

Expected behavior Text copy pasted from PDF from Chevin font paragraph should equal the Roboto version:

The Portable Document Format (PDF) (redundantly: PDF format) is a file
format developed by Adobe in the 1990s to present documents, including
text formatting and images, in a manner independent of application software,
hardware, and operating systems.[2][3] Based on the PostScript language,
each PDF file encapsulates a complete description of a fixed-layout flat doc-
ument, including the text, fonts, vector graphics, raster images and other in-
formation needed to display it. PDF was standardized as an open format, ISO
32000, in 2008, and no longer requires any royalties for its implementation.

Actual behavior Copy pasted text from PDF from Chevin paragraph is corrupted:

The Portable Document Format (PDF) (redundantly: PDF format) is a vle format depeloAed 
by 1dobe in the 900,s to Aresent documentsg includinx tewt formattinx and imaxesg in a 
manner indeAendent of aAAlication soft.areg hard.areg and oAeratinx systems[2]32B3 Sased 
on the Post-criAt lanxuaxeg each PDF vle encaAz sulates a comAlete descriAtion of a 
vwedzlayout Iat documentg includinx the tewtg fontsg pector xraAhicsg raster imaxes and 
other information needed to disAlay it[ PDF .as standardiOed as an oAen formatg 8-q B],,,g in 
],,􏰃g and no lonxer re􏰄uires any royalties for its imAlementation[

Edit: rendering is also corrupted for Chevin paragraph: chevin-rendering-bug

Desktop: * OS: MacOS * Browser: Firefox 67 * React-pdf version: REPL at 2019-06-06 v1.6.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
diegomuracommented, Jul 24, 2019

Not sure why some fonts are not loaded correctly by fontkit. Something that worked for me is opening the font with a font editor (such as birdfont) and export it again without changes

4reactions
anttikekkicommented, Aug 6, 2019

Exporting font with Birdfont fixed the problem on Chevin. I had tried to do the same fix with FontForge font editor but with no luck this time.

I had the same problem with react-pdf 1.4.3 but then exporting the font again with FontForge fixed it. Strange that different re-export tricks are needed for different versions of this library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Copying and pasting text turns to gibberish
Hi quintonv,. As mentioned, you are getting gibberish text when copying and pasting text from pdf, it seems the issue seems to be...
Read more >
PDF has garbled text when copy pasting - adobe reader
In Acrobat, click File -> Properties, then click the Fonts tab to see encoding, and the Security tab to see whether it's encrypted....
Read more >
Problem with Font .. Copy and paste into Word
I have a pdf file, including a font called "AdvP405B6" (from document properties). it caused problems when copying and pasting into Word ...
Read more >
Full font list
... Century Kurrent Start copy 1 18th Century Kurrent Text 18thCentury 19 000 ... Bold PDF AlphaBravo Light PDF AlphaBravo Medium PDF AlphaBravo...
Read more >
Untitled
Imposed sanctions syria, Andrew loomis creative illustration pdf, Bloons td 4 free. ... Crusade against corruption, Morckhovenlei antwerpen, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found