WinAnsi encoding when I want UTF-8

167 views
Skip to first unread message

Toby A

unread,
Jun 28, 2017, 3:32:01 AM6/28/17
to Prawn
I'm using Rails 4.2 with Prawn to generate a PDF document that contains non-roman characters. The characters are coming through as tofu, even though I've specified a unicode font that supports them like this:

font_families.update("Charis" => {
 
:normal => "#{Rails.root}/app/assets/fonts/CharisSILR.ttf",
 
:bold => "#{Rails.root}/app/assets/fonts/CharisSILB.ttf"
})
font
('Charis')

I used a tool to inspect the font in the PDF file and it is Charis as I specified, but it looks like the encoding used is "WinAnsi" which I think only supports the Latin character set. This is the output of my font inspecting tool:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
AAAAAG
+CharisSIL-Bold                TrueType          WinAnsi          yes yes yes      6  0
AAAAAH
+CharisSIL                     TrueType          WinAnsi          yes yes yes      7  0
AAAAAI
+CharisSIL                     TrueType          WinAnsi          yes yes yes      8  0

so how do I specify that I want the encoding to be UTF-8?

Toby

Toby A

unread,
Jun 28, 2017, 5:33:49 AM6/28/17
to Prawn
My aim is to get rid of the tofu in my document (see attached image)
prawn tofu.png

Toby A

unread,
Jun 28, 2017, 5:46:58 AM6/28/17
to Prawn
My mistake. The font I'm using doesn't have glyphs for the characters I'm outputting.
Reply all
Reply to author
Forward
0 new messages