<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>data/fonts/Action Man.dfont</filename>
    </added>
    <added>
      <filename>examples/text/dfont.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -64,15 +64,26 @@ module Prawn
       set_font(original_font, original_size) if original_font
     end
 
-    # Looks up the given font name. Once a font has been found by that name,
-    # it will be cached to subsequent lookups for that font will return the
-    # same object.
+    # Looks up the given font using the given criteria. Once a font has been
+    # found by that matches the criteria, it will be cached to subsequent lookups
+    # for that font will return the same object.
+    #--
+    # Challenges involved: the name alone is not sufficient to uniquely identify
+    # a font (think dfont suitcases that can hold multiple different fonts in a
+    # single file). Thus, the :select key is included in the cache key.
+    #
+    # It is further complicated, however, since fonts in some formats (like the
+    # dfont suitcases) can be identified either by numeric index, OR by their
+    # name within the suitcase, and both should hash to the same font object
+    # (to avoid the font being embedded multiple times). This is not yet implemented,
+    # which means if someone selects a font both by name, and by index, the
+    # font will be embedded twice. Since we do font subsetting, this double
+    # embedding won't be catastrophic, just annoying.
+    # ++
     #
     def find_font(name, options={}) #:nodoc:
-      style = options[:style] || :normal
-
       if font_families.key?(name)
-        family, name = name, font_families[name][style]
+        family, name = name, font_families[name][options[:style] || :normal]
 
         if name.is_a?(Hash)
           options = options.merge(name)
@@ -80,7 +91,7 @@ module Prawn
         end
       end
 
-      key = &quot;#{name}:#{style}&quot;
+      key = &quot;#{name}:#{options[:select] || 0}&quot;
       font_registry[key] ||= Font.load(self, name, options.merge(:family =&gt; family))
     end
 </diff>
      <filename>lib/prawn/font.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,20 @@ require 'prawn/font/ttf'
 module Prawn
   class Font
     class DFont &lt; TTF
+      def self.each_named_font(file)
+        TTFunk::ResourceFile.open(file) do |file|
+          file.resources_for(&quot;sfnt&quot;).each do |name|
+            yield name
+          end
+        end
+      end
+
+      def self.font_count(file)
+        TTFunk::ResourceFile.open(file) do |file|
+          return file.map[&quot;sfnt&quot;][:list].length
+        end
+      end
+
       private 
 
       def read_ttf_file</diff>
      <filename>lib/prawn/font/dfont.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d1f9c1c40d4a3927383ca71b4dac10b34c87d84c</id>
    </parent>
  </parents>
  <author>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </author>
  <url>http://github.com/yob/prawn/commit/35a9b38f1734fd32314670baeb6578a152141efc</url>
  <id>35a9b38f1734fd32314670baeb6578a152141efc</id>
  <committed-date>2009-01-11T21:47:58-08:00</committed-date>
  <authored-date>2009-01-11T21:47:58-08:00</authored-date>
  <message>Make font's cache based on :name and :select

Also, add a sample dfont and an example to demonstrate usage.
Also added an API on Prawn::Font::DFont for querying the available
fonts in a dfont file.</message>
  <tree>ea9e70ea981d0d918c60b23c93b195571fc7d947</tree>
  <committer>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </committer>
</commit>
