Sha256: f135b69223f994cbb8d9b4924863eeceecb03b9822c2131fa44b5fe04a09cb12

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8
#
# Prawn enables the declaration of fallback fonts for those glyphs that may not
# be present in the desired font. Use the <code>:fallback_fonts</code> option
# with any of the text or text box methods, or set fallback_fonts document-wide.
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
  file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
  font_families["Kai"] = {
    :normal => { :file => file, :font => "Kai" }
  }
  
  file = "#{Prawn::DATADIR}/fonts/Action Man.dfont"
  font_families["Action Man"] = {
    :normal => { :file => file, :font => "ActionMan" },
  }
  
  font("Action Man") do
    text("When fallback fonts are included, each glyph will be rendered " +
         "using the first font that includes the glyph, starting with the " +
         "current font and then moving through the fallback fonts from left " +
         "to right." +
         "\n\n" +
         "hello ƒ 你好\n再见 ƒ goodbye",
         :fallback_fonts => ["Times-Roman", "Kai"])
  end
  move_down 20

  formatted_text([ { :text => "Fallback fonts can even override" },
                   { :text => "fragment fonts (你好)", :font => "Times-Roman" },
                 ],
                 :fallback_fonts => ["Times-Roman", "Kai"])
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
prawn-0.15.0 manual/text/fallback_fonts.rb
prawn-0.14.0 manual/text/fallback_fonts.rb
prawn-0.13.2 manual/text/fallback_fonts.rb
prawn-0.13.1 manual/text/fallback_fonts.rb
prawn-0.13.0 manual/text/fallback_fonts.rb
prawn-1.0.0.rc2 manual/text/fallback_fonts.rb
nurettin-prawn-1.0.0.rc1 manual/text/fallback_fonts.rb