<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,6 +5,7 @@ v0.6.2 (xxx)
 - Added a few callbacks to improve the way we supply information on page resources 
 - Ignore whitespace in hex strings, as required by the spec (section 3.2.3)
 - Use our &quot;unknown character box&quot; when a single character in an Identity-H string fails to decode
+- Support ToUnicode CMaps that use the bfrange operator
 
 v0.6.1 (12th March 2008)
 - Tweaked behaviour when we encounter Identity-H encoded text that doesn't have a ToUnicode mapping. We</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,6 @@ v0.7
   - maybe a third option to Reader.parse?
     parse(io, receiver, {:pages =&gt; true, :fonts =&gt; false, :metadata =&gt; true, :bookmarks =&gt; false})
 - detect when a font's encoding is a CMap (generally used for pre-Unicode, multibyte asian encodings), and display a user friendly error
-- When parsing a CMap into a ruby object, recognise ranged mappings defined by begincodespacerange (see spec, section 5.9.2)
 - Provide a way to get raw access to a particular object. Good for testing purposes
 
 v0.8</diff>
      <filename>TODO</filename>
    </modified>
    <modified>
      <diff>@@ -28,12 +28,33 @@ class PDF::Reader
 
     def initialize(data)
       @map = {}
-      inmap = false
+      in_char_mode = false
+      in_range_mode = false
+
       data.each_line do |l|
-        inmap = true if l.include?(&quot;beginbfchar&quot;)
-        if inmap
+        if l.include?(&quot;beginbfchar&quot;)
+          in_char_mode = true 
+        elsif l.include?(&quot;endbfchar&quot;)
+          in_char_mode = false 
+        elsif l.include?(&quot;beginbfrange&quot;)
+          in_range_mode = true 
+        elsif l.include?(&quot;endbfrange&quot;)
+          in_range_mode = false 
+        end
+        if in_char_mode
           m, find, replace = *l.match(/&lt;([0-9a-fA-F]+)&gt; &lt;([0-9a-fA-F]+)&gt;/)
           @map[&quot;0x#{find}&quot;.hex] = &quot;0x#{replace}&quot;.hex if find &amp;&amp; replace
+        elsif in_range_mode
+          m, start_code, end_code, dst = *l.match(/&lt;([0-9a-fA-F]+)&gt; &lt;([0-9a-fA-F]+)&gt; &lt;([0-9a-fA-F]+)&gt;/)
+          if start_code &amp;&amp; end_code &amp;&amp; dst
+            start_code = &quot;0x#{start_code}&quot;.hex
+            end_code   = &quot;0x#{end_code}&quot;.hex
+            dst        = &quot;0x#{dst}&quot;.hex
+            (start_code..end_code).each do |val|
+              @map[val] = dst 
+              dst += 1
+            end
+          end
         end
       end
     end</diff>
      <filename>lib/pdf/reader/cmap.rb</filename>
    </modified>
    <modified>
      <diff>@@ -57,4 +57,13 @@ EOF
     map.decode(0x9).should eql(0x73)
   end
 
+  specify &quot;should correctly load a cmap that uses the beginbfrange operator&quot; do
+    filename = File.dirname(__FILE__) + &quot;/data/cmap_with_bfrange.txt&quot;
+    map = PDF::Reader::CMap.new(File.read(filename))
+    map.decode(0x16C9).should eql(0x4F38) # mapped with the bfchar operator
+    map.decode(0x0003).should eql(0x0020) # mapped with the bfrange operator
+    map.decode(0x0004).should eql(0x0020+1) # mapped with the bfrange operator
+    map.decode(0x0005).should eql(0x0020+2) # mapped with the bfrange operator
+  end
+
 end</diff>
      <filename>specs/cmap_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d04ce054e8e8602b375bfce111d4878cff979e9a</id>
    </parent>
  </parents>
  <author>
    <name>jhealy</name>
    <email>jhealy@3db89d08-1e44-db11-a2a8-0014220fd31b</email>
  </author>
  <url>http://github.com/yob/pdf-reader/commit/06c8dbbf2b202dce5fc5bbffec69413bb14d99f9</url>
  <id>06c8dbbf2b202dce5fc5bbffec69413bb14d99f9</id>
  <committed-date>2008-03-21T02:25:41-07:00</committed-date>
  <authored-date>2008-03-21T02:25:41-07:00</authored-date>
  <message>pdf-reader: added support for ToUnicode CMaps that use the bfrange operator (see section 5.9.2 of the spec)


git-svn-id: https://pmade.com/svn/oss/pdf-reader/trunk@1327 3db89d08-1e44-db11-a2a8-0014220fd31b</message>
  <tree>3936f1ff2b27c0e4bfc2aac883c7083a0478276a</tree>
  <committer>
    <name>jhealy</name>
    <email>jhealy@3db89d08-1e44-db11-a2a8-0014220fd31b</email>
  </committer>
</commit>
