Permalink
Browse files

added an example of rendered Shift-JIS encoded text

  • Loading branch information...
1 parent 558ef4a commit 4b626ad4750c39a0b4899bb4a270d2705c583347 @yob yob committed Jul 2, 2008
Showing with 19 additions and 0 deletions.
  1. +1 −0 data/shift_jis_text.txt
  2. +18 −0 examples/sjis.rb
View
@@ -0,0 +1 @@
+���C���y�[�W
View
@@ -0,0 +1,18 @@
+# coding: utf-8
+
+# Tests passing non utf-8 data into Prawns text function. Should
+# be transparently converted to utf-8 and rendered as usual.
+#
+# NOTE: only works on ruby1.9 compatible VMs, and requires the current
+# font to include japanese glyphs
+
+$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
+require "prawn"
+
+datafile = File.join(File.dirname(__FILE__), "..", "data", "shift_jis_text.txt")
+sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets }
+
+Prawn::Document.generate("sjis.pdf") do
+ font "/usr/share/fonts/truetype/arphic/gkai00mp.ttf"
+ text sjis_str
+end

0 comments on commit 4b626ad

Please sign in to comment.