2 # << Haru Free PDF Library 2.0.0 >> -- font_example.rb
4 # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
6 # Permission to use, copy, modify, distribute and sell this software
7 # and its documentation for any purpose is hereby granted without fee,
8 # provided that the above copyright notice appear in all copies and
9 # that both that copyright notice and this permission notice appear
10 # in supporting documentation.
11 # It is provided "as is" without express or implied warranty.
16 font_list = ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats", nil]
21 height = page.get_height
22 width = page.get_width
24 page.set_line_width(1.0)
25 page.rectangle(50.0, 50.0, width - 100.0, height - 110.0)
28 font1 = pdf.get_font("Helvetica", nil)
30 title = "Font Example"
31 page.set_font_and_size(font1, 24.0)
32 tw = page.text_width(title)
34 page.text_out((width - tw) / 2, height - 50.0, title)
35 page.set_font_and_size(font1, 16.0)
36 page.text_out(60.0, height - 80.0, "<Standerd Type1 fonts samples>")
39 samp_text = "abcdefgABCDEFG12345!#$\%&+-@?"
42 page.move_text_pos(60.0, height - 105.0)
46 font2 = pdf.get_font(font_list[i], nil)
48 page.set_font_and_size(font1, 9.0)
49 page.show_text(font_list[i])
50 page.move_text_pos(0.0, -18.0)
52 page.set_font_and_size(font2, 20.0)
53 page.show_text(samp_text)
54 page.move_text_pos(0.0, -20.0)
60 pdf.save_to_file($0 + ".pdf")