public
Description: Scripts for generating posters that contain glyphs of every printable character in Unicode 5.1.0
Homepage: http://mythic-beasts.com/~mark/random/unicode-poster/
Clone URL: git://github.com/mhl/unicode-poster.git
unicode-poster / dice-posters
100755 50 lines (42 sloc) 1.209 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/ruby -w
 
subdirectory = "diced-#{Time.now.to_i}"
# subdirectory = "diced-hello"
 
pamdice = "/home/mark/netpbm-10.34/package/bin/pamdice"
pnmtops = "/home/mark/netpbm-10.34/package/bin/pnmtops"
 
system("mkdir",subdirectory)
 
originals = Dir["poster-complete-*-A0-600dpi.pam"]
 
originals.each do |o|
  # Find the size:
  width = height = nil
  open(o) do |f|
    f.gets
    unless f.gets =~ /^(\d+) (\d+)/
      STDERR.puts "This doesn't look like a pnm file to me."
      exit(-1)
    end
    width = Integer($1)
    height = Integer($2)
  end
  split_width = (width / 4.0).ceil
  split_height = (height / 4.0).ceil
  # Get the page number:
  unless o =~ /poster-complete-(\d{2})/
    puts "Couldn't find page number from filename: #{o}"
    exit(-1)
  end
  page = $1
  system(pamdice,
         "-outstem=#{subdirectory}/diced-#{page}",
         "-width=#{split_width}",
         "-height=#{split_height}",
         o)
 
end
 
# Convert each to EPS:
pgm_files = Dir[subdirectory+"/*.pgm"]
pgm_files.each do |p|
  epsfile = p.gsub(/\.pgm/,'.eps')
  # full A4 would be 11.75 (ish)
  command = "#{pnmtops} -height 11 -imageheight 11 -psfilter -rle #{p} > #{epsfile}"
  puts command
  system command
end