Any font for creating PDF that will handle Chinese, Cyrillic ...?

I am creating a pdf document generator in Ruby on Rails with a Shrimp gem and I came up with a problem when I have Chinese, Japanese and Cyrillic characters. not displayed correctly. I searched for this because "when I create a font, I need to specify which font the pdf text should have."

Now this is not a problem, but the fact that my documents will contain all kinds of possible characters that gTLD supports .

Question 1:

Do you know any font for creating pdf documents that will include as many characters as possible (Asian, Europe, Symbols, ...)? Ideally, all characters supported by gTLD.

I know that Shrimp by default includes gkai00mp.ttf, but it focuses on Chinese characters, and I'm looking for permissibility to include them all (like PokeMon, catch them, I know that I ask too much, but still ...)

Another problem is when the client opens this document:

Question 2

Is the PDF created by Prawn including my font in a pdf file, so when other computers open it, will the font be present? Is it a standard by default? Or do I need to provide / force this functionality?

+5
source share
2 answers

OK, I will answer myself. On SuperUser, I asked a similar question (focusing on the answers more theoretically), and the main conclusion was:

, Unicode.

, , pdf , prawn.

:

1/

  kai = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
  action_man_path = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
  dejavu = "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"

  font_families.update("dejavu" => {
    :normal      => dejavu,
    :italic      => dejavu,
    :bold        => dejavu,
    :bold_italic => dejavu
  })

  #Times is defined in prawn
  font_families.update("times" => {
    :normal => "Times-Roman",
    :italic      => "Times-Italic",
    :bold        => "Times-Bold",
    :bold_italic => "Times-BoldItalic"
  })

  font_families.update("action_man" => {
    :normal      => { :file => action_man_path, :font => "ActionMan" },
    :italic      => { :file => action_man_path, :font => "ActionMan-Italic" },
    :bold        => { :file => action_man_path, :font => "ActionMan-Bold" },
    :bold_italic => { :file => action_man_path, :font => "ActionMan-BoldItalic" }
  })

  font_families.update(
      "kai" => {
        :normal => { :file => kai, :font => "Kai" },
        :bold   => kai,
        :italic => kai,
        :bold_italic => kai
       }
    )

def fallback_fonts
  ["dejavu", "times", 'kai', 'action_man']
end

2/

 font("Helvetica", size: 14) do  #keyword "Helvetica" is specified in Prawn by default
   text "址 foo", :fallback_fonts => fallback_fonts 
 end

, ,

, Rails

"", , , , bold_italic . . , gkai00mp, . , / char , ( , ).

/ (exaple "Kai" )..

  font_families.update(
      "kai" => {
        :normal => { :file => kai, :font => "Kai" }
        }
    )

.. char, kai...

 text "<b>址 foo</b>", :fallback_fonts => fallback_fonts, :inline_format=>true 

...

Prawn::Errors::UnknownFont in Foo

  is not a known font. 

2:, -ascii ruby ,

# coding: utf-8

class Foo
...
end

, , ruby ​​1.9. Ruby 1.8.x ASCII ( ruby ​​1.9 P.C. Rails I18n ()

3

, git github ./manuals

+8

2014 Google Noto (https://www.google.com/get/noto/) . ttf, otf ttc . , NotoSansCJK .

+2

All Articles