Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread


By: Bernard Kenik
Ocra and Prawn [ reply ]  
2010-03-18 03:05
When I attempted to package my script which required Prawn, I ran into problems as others have experienced... prawn uses the Helvetica font file by default and also needs a win-ansi.txt file.

Took me a while to find how to resolve the problems.
By the way it turned out that 2 other files were needed. These files are part of Ruby ... enc/trans/ and enc/

I am using ruby 1.9.1p243 [i386-mingw32], ocra 1.1.3, and prawn 0.8.4 on Windows XP with SP3 installed.

1. Modified the Prawn gem as follows:

In prawn-core-0.8.4:
locate lib/prawn/font/afm.rb ... line 23
add "data/fonts/" to the @metrics_path array

locate lib/prawn/encoding.rb ... line 88
change @mapping_file = "../data/encodings/win_ansi.txt"
to @mapping_file = "data/encoding/win_ansi.txt"

In your project directory which contains the main app script:

copy the entire "data" directory structure from praw-core-0.8.4/data it contains the font and encodings folders and their files.

copy the entire "enc" directory structure from <your path to ruby>/lib/ruby/1.9.1/i386-mingw32/enc. it contains the trans folder as well as their files.

The reason you need to copy the entire directory structures is that Prawn's search path expects to find the directories in your executable directory.

Ensure that all other directories that contains files that you need are located in the executable directory.

Once your program has been debugged and passes all your tests, you can invoke Ocra has follow:

ocra yourapp.rb data/font/*.* data/encodings/*.* enc/trans/ enc/

note that I included all fonts ... I could just have used data/font/Helvetica.afm

there's only one file in data/encodings.

Hope this helps others that have had similiar problems with Ocra.