diegomura/react-pdf

Issue with Displaying Turkish names

amanjain-aj opened this issue · 5 comments

The input from the API is

MEYTEKS TEKSTİL SANAYİ VE TİCARET ANONİM ŞİRKETİ

But on the PDF what we see is

MEYTEKS TEKST0L SANAY0 VE T0CARET ANON0M ^0RKET0

@amanjain-aj you should use a font that supports Turkish characters, like Roboto.

I'm using Robot and tried @amanjain-aj 's string and got the same error. I was coming to file a very similar bug.

I'm trying to display CO₂ and the subscript 2 is transformed to a , (space followed by a comma). This is happening due to the UTF-16 manipulation in

// Detect if this is a unicode string

I'm not sure exactly what's wrong yet, but I see that the manipulation of the char code turns (U+2082 in UTF-16BE) becomes 0x20 0x82 which is interpreted directly in latin ASCII which gives ,.

I believe the same thing is happening.

@pcorpet I have only tested using Roboto inside the react-pdf repl: https://react-pdf.org/repl

I have changed the font registration to use Roboto:

Font.register({
  family: 'Roboto',
  src: 'https://fonts.gstatic.com/s/roboto/v48/KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWub2bWmTggvWl0Qn.ttf'
});

and changing the subtitle styles to:

subtitle: {
    fontSize: 18,
    margin: 12,
    fontFamily: 'Roboto'
  },

Then tried using CO₂ inside the subtitle component and it rendered correctly. So I'm not sure what’s causing it in your case.

Image

OK, thanks this is because I was pulling only Roboto latin, whereas the other char is in the math charset. Thanks a lot!

And I realize, there's no good way to register a different .ttf file for different unicode character ranges.