<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>tileinfo.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -11,18 +11,11 @@ end
 $title = ARGV[0]
 $number_of_pages = Integer(ARGV[1])
 
-unless FileTest.exists?( 'Blocks.txt' )
-  unless system( &quot;curl&quot;, &quot;-s&quot;, &quot;ftp://ftp.unicode.org/Public/5.1.0/ucd/Blocks.txt&quot;, &quot;-o&quot;, &quot;Blocks.txt&quot; )
-    STDERR.puts &quot;Couldn't download Blocks.txt.&quot;
-    exit(-1)
-  end
-end
-
-require 'individual-characters/tileinfo.rb'
+require 'tileinfo.rb'
 
 $pages_hash = Hash.new
 
-files = Dir['individual-characters/non-blank/U*-*-*-top.png']
+files = Dir['individual-characters/U*-*-*-top.png']
 
 files.each do |png_file|
 
@@ -107,11 +100,11 @@ $pages.each do |p|
   puts &quot;#{p} (#{name_of_page(p)})&quot;
 end
 
-$info_hash = YAML.load( open( &quot;individual-characters/non-blank/top-sizes.yaml&quot;, &quot;r&quot; ){ |f| f.read } )
+$info_hash = YAML.load( open( &quot;top-sizes.yaml&quot;, &quot;r&quot; ){ |f| f.read } )
 
 $info_hash.each_key do |png_file|
   # puts &quot;key from $info_hash was: #{png_file}&quot;
-  from_page = png_file.gsub(/\-\d{3}\-\d{8}-top\..*/,'')
+  from_page = png_file.gsub(/^.*(U[0-9A-Fa-f]+)\-\d{3}\-\d{8}-top\.png$/,'\1')
   $pages_hash[from_page].push(png_file)
 end
 
@@ -215,7 +208,7 @@ class ImageToDraw
   end
   
   def draw_to( im, color, leave_header_space )
-    im_tile = GD::Image.new_from_png( &quot;individual-characters/non-blank/#{@image_file}&quot; )
+    im_tile = GD::Image.new_from_png( @image_file )
     y = 0
     im_tile.copy( im, x, y, 0, 0, im_tile.width, im_tile.height)
     im_tile.destroy</diff>
      <filename>compose-inline-breaks</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,7 @@ data.each do |e|
   unless system( &quot;convert&quot;,
                  &quot;-scale&quot;,
                  &quot;50%&quot;,
-                 &quot;individual-characters/non-blank/&quot; + name.gsub(&quot;.png&quot;,&quot;-top.png&quot;),
+                 &quot;individual-characters/&quot; + name.gsub(&quot;.png&quot;,&quot;-top.png&quot;),
                  destination_directory + &quot;reduced-&quot; + new_name )
     puts &quot;Failed to convert and copy: #{name}&quot;
     exit(-1)</diff>
      <filename>copy-characters-to-webspace</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1 @@
-Blocks.txt
 *.png.empty</diff>
      <filename>individual-characters/.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 #!/usr/bin/ruby -w
 
-charts_index_page = &quot;http://www.unicode.org/charts/PDF/&quot;
+require 'tileinfo.rb'
 
 # The directory with the helper files:
 helpers = &quot;png-find-grid-revised&quot;
@@ -10,6 +10,8 @@ unless system(&quot;cd #{helpers} &amp;&amp; make&quot;)
   exit(-1)
 end
 
+charts_index_page = &quot;http://www.unicode.org/charts/PDF/&quot;
+
 index_html = `curl -s #{charts_index_page}`
 unless $?.success?
   puts &quot;Couldn't fetch the charts index page from: #{charts_index_page}&quot;
@@ -82,7 +84,6 @@ end
 puts &quot;Globbing directory...&quot;
 
 png_files = Dir['U*-*.png']
-# png_files = [ &quot;U0000-002.png&quot;, &quot;UFB50-004.png&quot; ]
 
 some_done_done_from = Hash.new
 already_output_files = Dir['individual-characters/U*-*-*.png']
@@ -225,12 +226,140 @@ png_files.each do |png_file|
 
 end
 
-unless system &quot;cd individual-characters &amp;&amp; ./link-non-blanks&quot;
-  puts &quot;The link-non-blanks script failed&quot;
-  exit(-1)
+def compare_tile_filenames( a, b )
+  Integer( a.gsub( /^.*U([0-9A-F]+)\-([0-9A-F]+)\-([0-9A-F]+).*\.png$/, '0x\1\2\3' ) ) &lt;=&gt;
+    Integer( b.gsub( /^.*U([0-9A-F]+)\-([0-9A-F]+)\-([0-9A-F]+).*\.png$/, '0x\1\2\3' ) )
 end
 
-unless system &quot;cd individual-characters/non-blank &amp;&amp; ./extract-numbers&quot;
-  puts &quot;The extract-numbers script failed&quot;
-  exit(-1)
+files = Dir['individual-characters/U*-*-*.png']
+
+# If this is a repeat run then we may have some leftover -top and
+# -bottom files here:
+
+files.delete_if { |x| x =~ /top/ }
+files.delete_if { |x| x =~ /bottom/ }
+
+files.sort! { |a,b| compare_tile_filenames( a, b ) }
+
+# ------------------------------------------------------------------------
+
+last_block = -1
+
+open( &quot;top-sizes.yaml&quot;, &quot;w&quot; ) do |o_top_sizes|
+
+  o_top_sizes.puts &quot;---&quot;
+
+  open( &quot;codepoints.yaml&quot;, &quot;w&quot; ) do |o_codepoints|
+
+    files.each do |fname|
+
+      fname =~ /U([0-9A-F]+)-([0-9A-F]+)/
+
+      block = Integer(&quot;0x&quot;+$1)
+
+      if block != last_block
+        puts &quot;Extracting numbers from block: &quot; + sprintf(&quot;0x%06X&quot;,block)
+        last_block = block
+      end
+
+      block_name = name_of_page(fname.gsub(/^.*(U[0-9A-F]+).*$/,'\1'))
+      next unless block_name
+
+      info = `#{helpers}/png-size #{fname}`
+      unless $?.success?
+        puts &quot;png-size #{fname} failed.&quot;
+        next
+      end
+
+      width = nil
+      height = nil
+
+      info.chomp!
+      if info =~ /(\d+)x(\d+)/
+
+        width = Integer($1)
+        height = Integer($2)
+
+        top_part_fname = fname.sub( /.png/, '-top.png' )
+        bottom_part_fname = fname.sub( /.png/, '-bottom.png' )
+
+        guessed_text_size = 75
+
+        text_starts_at = height - guessed_text_size
+
+        p = IO.popen( &quot;#{helpers}/crop-images #{fname}&quot;, &quot;w&quot; )
+
+        p.puts( &quot;#{top_part_fname} 0 0 #{width} #{text_starts_at}&quot; )
+        p.puts( &quot;#{bottom_part_fname} 0 #{text_starts_at} #{width} #{guessed_text_size}&quot; )
+
+        p.close
+        unless $?.success?
+          puts &quot;#{helpers}/crop-images #{fname} failed.&quot;
+          exit(-1)
+        end
+
+        top_width = nil
+        top_height = nil
+
+        output = safe_backticks(&quot;#{helpers}/empty-image&quot;,top_part_fname)
+        if $?.success?
+          puts &quot;Empty, skipping: #{fname}&quot;
+          system(&quot;rm&quot;,top_part_fname)
+          system(&quot;rm&quot;,bottom_part_fname)
+          next
+        else
+          output.chomp!
+          if output =~ /^(\d+) (\d+)/
+            top_width = Integer($1)
+            top_height = Integer($2)
+          end
+        end
+
+        # Check that the bottom part isn't hashed out, and delete
+        # it if so:
+
+        output = safe_backticks(&quot;#{helpers}/bottom-line-proportion&quot;,bottom_part_fname)
+        proportion = Float(output)
+        if proportion &gt; 0.01
+          puts &quot;Probably cross-hatched, skipping: #{fname}&quot;
+          system(&quot;rm&quot;,top_part_fname)
+          system(&quot;rm&quot;,bottom_part_fname)
+          next
+        end
+
+        if top_width and top_height
+            o_top_sizes.puts(&quot;#{fname}: !ruby/object:TileInfo&quot;)
+            o_top_sizes.puts(&quot;  filename: #{fname}&quot;)
+            o_top_sizes.puts(&quot;  h: #{top_height}&quot;)
+            o_top_sizes.puts(&quot;  w: #{top_width}&quot;)
+            o_top_sizes.puts(&quot;  block: #{block_name}&quot;)
+        end
+
+        # Now use OCR to try to parse the codepoint out of the bottom
+        # part:
+
+        result = `pngtopnm #{bottom_part_fname} | ocrad -`
+        unless $?.success?
+          puts &quot;png-topnm #{bottom_part_fname} | ocrad - failed.&quot;
+          exit(-1)
+        end
+
+        result.chomp!
+        result.gsub!( /\s/, '' )
+        result.gsub!( /[oO]/, '0' )
+        result.gsub!( /a/, '8' )
+        result.gsub!( /g/, '9' )
+
+        result.upcase!
+
+        o_codepoints.puts &quot;-&quot;
+        o_codepoints.puts '  - &quot;' + fname + '&quot;'
+        o_codepoints.puts &quot;  - &quot; + &quot;0x&quot; + result
+
+      end
+
+    end
+
+  end
+
 end</diff>
      <filename>make-unicode-poster</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>individual-characters/link-non-blanks</filename>
    </removed>
    <removed>
      <filename>individual-characters/non-blank/.gitignore</filename>
    </removed>
    <removed>
      <filename>individual-characters/non-blank/extract-numbers</filename>
    </removed>
    <removed>
      <filename>individual-characters/tileinfo.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>bbb639dbb999107136ed9a96e88c32485ee7d990</id>
    </parent>
  </parents>
  <author>
    <name>Mark Longair</name>
    <email>mark@claret.study</email>
  </author>
  <url>http://github.com/mhl/unicode-poster/commit/780d59492769f116eb69c48c3bfafa401f929144</url>
  <id>780d59492769f116eb69c48c3bfafa401f929144</id>
  <committed-date>2008-07-18T03:34:40-07:00</committed-date>
  <authored-date>2008-07-18T03:34:40-07:00</authored-date>
  <message>Remove link-non-blanks and non-blank/, tidy scripts and move into top-level directory</message>
  <tree>59c41f4c0dd172bf81f54d994b2fad5ccecfc9f7</tree>
  <committer>
    <name>Mark Longair</name>
    <email>mark@claret.study</email>
  </committer>
</commit>
