glyph_imager 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
 - data/.gitignore +21 -0
 - data/LICENSE +20 -0
 - data/README.rdoc +17 -0
 - data/Rakefile +53 -0
 - data/VERSION +1 -0
 - data/glyph_imager.gemspec +90 -0
 - data/lib/glyph_imager.rb +102 -0
 - data/test/fonts/DejaVuSerif.ttf +0 -0
 - data/test/helper.rb +10 -0
 - data/test/test_glyph_imager.rb +62 -0
 - data/vendor/graphics_utf +157 -0
 - data/vendor/ttf-ruby-0.1/AUTHORS +1 -0
 - data/vendor/ttf-ruby-0.1/COPYING +340 -0
 - data/vendor/ttf-ruby-0.1/README +49 -0
 - data/vendor/ttf-ruby-0.1/TODO +23 -0
 - data/vendor/ttf-ruby-0.1/VERSION +1 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/datatypes.rb +189 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/encodings.rb +140 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/exceptions.rb +28 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/font_loader.rb +290 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/fontchunk.rb +77 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/cmap.rb +408 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/cvt.rb +49 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/fpgm.rb +48 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/gasp.rb +88 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/glyf.rb +452 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/head.rb +86 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/hhea.rb +96 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/hmtx.rb +98 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/kern.rb +186 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/loca.rb +75 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/maxp.rb +81 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/name.rb +222 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/os2.rb +172 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/post.rb +120 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/prep.rb +27 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/vhea.rb +45 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf/table/vmtx.rb +36 -0
 - data/vendor/ttf-ruby-0.1/lib/ttf.rb +20 -0
 - data/vendor/ttf-ruby-0.1/setup.rb +1558 -0
 - data/vendor/ttf-ruby-0.1/tools/README +44 -0
 - data/vendor/ttf-ruby-0.1/tools/ttfcairoglyphviewer +229 -0
 - data/vendor/ttf-ruby-0.1/tools/ttfdump +396 -0
 - data/vendor/ttf-ruby-0.1/tools/ttfglyph2svg +144 -0
 - data/vendor/ttf-ruby-0.1/tools/ttfsubset +273 -0
 - metadata +120 -0
 
| 
         @@ -0,0 +1,75 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # TTF/Ruby, a library to read and write TrueType fonts in Ruby.
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Copyright (C) 2006  Mathieu Blondel
         
     | 
| 
      
 3 
     | 
    
         
            +
            # 
         
     | 
| 
      
 4 
     | 
    
         
            +
            # This program is free software; you can redistribute it and/or modify
         
     | 
| 
      
 5 
     | 
    
         
            +
            # it under the terms of the GNU General Public License as published by
         
     | 
| 
      
 6 
     | 
    
         
            +
            # the Free Software Foundation; either version 2 of the License, or
         
     | 
| 
      
 7 
     | 
    
         
            +
            # (at your option) any later version.
         
     | 
| 
      
 8 
     | 
    
         
            +
            # 
         
     | 
| 
      
 9 
     | 
    
         
            +
            # This program is distributed in the hope that it will be useful,
         
     | 
| 
      
 10 
     | 
    
         
            +
            # but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
      
 11 
     | 
    
         
            +
            # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
      
 12 
     | 
    
         
            +
            # GNU General Public License for more details.
         
     | 
| 
      
 13 
     | 
    
         
            +
            # 
         
     | 
| 
      
 14 
     | 
    
         
            +
            # You should have received a copy of the GNU General Public License
         
     | 
| 
      
 15 
     | 
    
         
            +
            # along with this program; if not, write to the Free Software
         
     | 
| 
      
 16 
     | 
    
         
            +
            # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            module Font
         
     | 
| 
      
 19 
     | 
    
         
            +
            module TTF
         
     | 
| 
      
 20 
     | 
    
         
            +
            module Table
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            # Loca is the Location table class. It provides the offsets of glyphs in
         
     | 
| 
      
 23 
     | 
    
         
            +
            # the glyf table.
         
     | 
| 
      
 24 
     | 
    
         
            +
            class Loca < Font::TTF::FontChunk
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                # An array of glyphs offsets with number of glyphs + 1 elements.
         
     | 
| 
      
 27 
     | 
    
         
            +
                # The value associated with a given index of that array
         
     | 
| 
      
 28 
     | 
    
         
            +
                # is the offset associated with glyph with index index.
         
     | 
| 
      
 29 
     | 
    
         
            +
                # This offset may be used with Font::TTF::Table::Glyf#get_glyph_at_offset
         
     | 
| 
      
 30 
     | 
    
         
            +
                # to get the glyph object associated with offset.
         
     | 
| 
      
 31 
     | 
    
         
            +
                #
         
     | 
| 
      
 32 
     | 
    
         
            +
                # The additional offset is added so that the length of the
         
     | 
| 
      
 33 
     | 
    
         
            +
                # last glyph can be calculated: 
         
     | 
| 
      
 34 
     | 
    
         
            +
                # len of last glyph = additional offs - last glyph offs
         
     | 
| 
      
 35 
     | 
    
         
            +
                attr_accessor :glyph_offsets
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                # It is not recommended to create Loca objects by hand.
         
     | 
| 
      
 38 
     | 
    
         
            +
                # Use Font::TTF::File#get_table or Font::TTF::File#get_new_table
         
     | 
| 
      
 39 
     | 
    
         
            +
                # with :loca as parameter instead.
         
     | 
| 
      
 40 
     | 
    
         
            +
                def initialize(*args)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    super(*args)
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                    if exists_in_file?
         
     | 
| 
      
 44 
     | 
    
         
            +
                        @font.at_offset(@offset) do
         
     | 
| 
      
 45 
     | 
    
         
            +
                            n = @font.get_table(:maxp).num_glyphs + 1
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                            case @font.get_table(:head).index_to_loc_format
         
     | 
| 
      
 48 
     | 
    
         
            +
                                when Font::TTF::Table::Head::SHORT_FORMAT
         
     | 
| 
      
 49 
     | 
    
         
            +
                                    @glyph_offsets = @font.read_ushorts(n)
         
     | 
| 
      
 50 
     | 
    
         
            +
                                    @glyph_offsets.collect! { |o| o * 2 }
         
     | 
| 
      
 51 
     | 
    
         
            +
                                when Font::TTF::Table::Head::LONG_FORMAT
         
     | 
| 
      
 52 
     | 
    
         
            +
                                    @glyph_offsets = @font.read_ulongs(n)
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                            end
         
     | 
| 
      
 55 
     | 
    
         
            +
                        end
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                # Dumps the loca table in binary raw format as may be found in a font
         
     | 
| 
      
 60 
     | 
    
         
            +
                # file.
         
     | 
| 
      
 61 
     | 
    
         
            +
                def dump
         
     | 
| 
      
 62 
     | 
    
         
            +
                    case @font.get_table(:head).index_to_loc_format
         
     | 
| 
      
 63 
     | 
    
         
            +
                        when Font::TTF::Table::Head::SHORT_FORMAT
         
     | 
| 
      
 64 
     | 
    
         
            +
                            @glyph_offsets.collect { |o| o / 2 }.to_ushorts
         
     | 
| 
      
 65 
     | 
    
         
            +
                        when Font::TTF::Table::Head::LONG_FORMAT
         
     | 
| 
      
 66 
     | 
    
         
            +
                            @glyph_offsets.to_ulongs
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                    end
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
                
         
     | 
| 
      
 71 
     | 
    
         
            +
            end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            end
         
     | 
| 
      
 74 
     | 
    
         
            +
            end
         
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # TTF/Ruby, a library to read and write TrueType fonts in Ruby.
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Copyright (C) 2006  Mathieu Blondel
         
     | 
| 
      
 3 
     | 
    
         
            +
            # 
         
     | 
| 
      
 4 
     | 
    
         
            +
            # This program is free software; you can redistribute it and/or modify
         
     | 
| 
      
 5 
     | 
    
         
            +
            # it under the terms of the GNU General Public License as published by
         
     | 
| 
      
 6 
     | 
    
         
            +
            # the Free Software Foundation; either version 2 of the License, or
         
     | 
| 
      
 7 
     | 
    
         
            +
            # (at your option) any later version.
         
     | 
| 
      
 8 
     | 
    
         
            +
            # 
         
     | 
| 
      
 9 
     | 
    
         
            +
            # This program is distributed in the hope that it will be useful,
         
     | 
| 
      
 10 
     | 
    
         
            +
            # but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
      
 11 
     | 
    
         
            +
            # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
      
 12 
     | 
    
         
            +
            # GNU General Public License for more details.
         
     | 
| 
      
 13 
     | 
    
         
            +
            # 
         
     | 
| 
      
 14 
     | 
    
         
            +
            # You should have received a copy of the GNU General Public License
         
     | 
| 
      
 15 
     | 
    
         
            +
            # along with this program; if not, write to the Free Software
         
     | 
| 
      
 16 
     | 
    
         
            +
            # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            module Font
         
     | 
| 
      
 19 
     | 
    
         
            +
            module TTF
         
     | 
| 
      
 20 
     | 
    
         
            +
            module Table
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            # Maxp is the Maximum profile tables, which establishes memory requirements
         
     | 
| 
      
 23 
     | 
    
         
            +
            # for the associated font.
         
     | 
| 
      
 24 
     | 
    
         
            +
            class Maxp < Font::TTF::FontChunk
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                attr_accessor :version, :num_glyphs, :max_points, :max_contours, 
         
     | 
| 
      
 27 
     | 
    
         
            +
                              :max_composite_points, :max_composite_contours, 
         
     | 
| 
      
 28 
     | 
    
         
            +
                              :max_zones, :max_twilight_points, :max_storage, 
         
     | 
| 
      
 29 
     | 
    
         
            +
                              :max_function_defs, :max_instruction_defs, 
         
     | 
| 
      
 30 
     | 
    
         
            +
                              :max_stack_elements, :max_sizeof_instructions, 
         
     | 
| 
      
 31 
     | 
    
         
            +
                              :max_component_elements, :max_component_depth
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def initialize(*args)
         
     | 
| 
      
 34 
     | 
    
         
            +
                    super(*args)
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    if exists_in_file?
         
     | 
| 
      
 37 
     | 
    
         
            +
                        @font.at_offset(@offset) do
         
     | 
| 
      
 38 
     | 
    
         
            +
                            @version = @font.read_fixed
         
     | 
| 
      
 39 
     | 
    
         
            +
                            @num_glyphs = @font.read_ushort
         
     | 
| 
      
 40 
     | 
    
         
            +
                            @max_points = @font.read_ushort
         
     | 
| 
      
 41 
     | 
    
         
            +
                            @max_contours = @font.read_ushort
         
     | 
| 
      
 42 
     | 
    
         
            +
                            @max_composite_points = @font.read_ushort
         
     | 
| 
      
 43 
     | 
    
         
            +
                            @max_composite_contours = @font.read_ushort
         
     | 
| 
      
 44 
     | 
    
         
            +
                            @max_zones = @font.read_ushort
         
     | 
| 
      
 45 
     | 
    
         
            +
                            @max_twilight_points = @font.read_ushort
         
     | 
| 
      
 46 
     | 
    
         
            +
                            @max_storage = @font.read_ushort
         
     | 
| 
      
 47 
     | 
    
         
            +
                            @max_function_defs = @font.read_ushort
         
     | 
| 
      
 48 
     | 
    
         
            +
                            @max_instruction_defs = @font.read_ushort
         
     | 
| 
      
 49 
     | 
    
         
            +
                            @max_stack_elements = @font.read_ushort
         
     | 
| 
      
 50 
     | 
    
         
            +
                            @max_sizeof_instructions = @font.read_ushort
         
     | 
| 
      
 51 
     | 
    
         
            +
                            @max_component_elements = @font.read_ushort
         
     | 
| 
      
 52 
     | 
    
         
            +
                            @max_component_depth = @font.read_ushort
         
     | 
| 
      
 53 
     | 
    
         
            +
                        end
         
     | 
| 
      
 54 
     | 
    
         
            +
                    end
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                # Dumps the maxp table in binary raw format as may be found in a font
         
     | 
| 
      
 58 
     | 
    
         
            +
                # file.
         
     | 
| 
      
 59 
     | 
    
         
            +
                def dump
         
     | 
| 
      
 60 
     | 
    
         
            +
                    raw = (@version || 0).to_fixed
         
     | 
| 
      
 61 
     | 
    
         
            +
                    raw += (@num_glyphs || 0).to_ushort
         
     | 
| 
      
 62 
     | 
    
         
            +
                    raw += (@max_points || 0).to_ushort
         
     | 
| 
      
 63 
     | 
    
         
            +
                    raw += (@max_contours || 0).to_ushort
         
     | 
| 
      
 64 
     | 
    
         
            +
                    raw += (@max_composite_points || 0).to_ushort
         
     | 
| 
      
 65 
     | 
    
         
            +
                    raw += (@max_composite_contours || 0).to_ushort
         
     | 
| 
      
 66 
     | 
    
         
            +
                    raw += (@max_zones || 0).to_ushort
         
     | 
| 
      
 67 
     | 
    
         
            +
                    raw += (@max_twilight_points || 0).to_ushort
         
     | 
| 
      
 68 
     | 
    
         
            +
                    raw += (@max_storage || 0).to_ushort
         
     | 
| 
      
 69 
     | 
    
         
            +
                    raw += (@max_function_defs || 0).to_ushort
         
     | 
| 
      
 70 
     | 
    
         
            +
                    raw += (@max_instruction_defs || 0).to_ushort
         
     | 
| 
      
 71 
     | 
    
         
            +
                    raw += (@max_stack_elements || 0).to_ushort
         
     | 
| 
      
 72 
     | 
    
         
            +
                    raw += (@max_sizeof_instructions || 0).to_ushort
         
     | 
| 
      
 73 
     | 
    
         
            +
                    raw += (@max_component_elements || 0).to_ushort
         
     | 
| 
      
 74 
     | 
    
         
            +
                    raw += (@max_component_depth || 0).to_ushort
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
                
         
     | 
| 
      
 77 
     | 
    
         
            +
            end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
| 
      
 80 
     | 
    
         
            +
            end
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,222 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # TTF/Ruby, a library to read and write TrueType fonts in Ruby.
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Copyright (C) 2006  Mathieu Blondel
         
     | 
| 
      
 3 
     | 
    
         
            +
            # 
         
     | 
| 
      
 4 
     | 
    
         
            +
            # This program is free software; you can redistribute it and/or modify
         
     | 
| 
      
 5 
     | 
    
         
            +
            # it under the terms of the GNU General Public License as published by
         
     | 
| 
      
 6 
     | 
    
         
            +
            # the Free Software Foundation; either version 2 of the License, or
         
     | 
| 
      
 7 
     | 
    
         
            +
            # (at your option) any later version.
         
     | 
| 
      
 8 
     | 
    
         
            +
            # 
         
     | 
| 
      
 9 
     | 
    
         
            +
            # This program is distributed in the hope that it will be useful,
         
     | 
| 
      
 10 
     | 
    
         
            +
            # but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
      
 11 
     | 
    
         
            +
            # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
      
 12 
     | 
    
         
            +
            # GNU General Public License for more details.
         
     | 
| 
      
 13 
     | 
    
         
            +
            # 
         
     | 
| 
      
 14 
     | 
    
         
            +
            # You should have received a copy of the GNU General Public License
         
     | 
| 
      
 15 
     | 
    
         
            +
            # along with this program; if not, write to the Free Software
         
     | 
| 
      
 16 
     | 
    
         
            +
            # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            require 'iconv'
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            module Font
         
     | 
| 
      
 21 
     | 
    
         
            +
            module TTF
         
     | 
| 
      
 22 
     | 
    
         
            +
            module Table
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            # Name is the the Naming table which allows multilingual strings to be
         
     | 
| 
      
 25 
     | 
    
         
            +
            # associated with the TrueType font file.
         
     | 
| 
      
 26 
     | 
    
         
            +
            class Name < Font::TTF::FontChunk
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                # A NameRecord holds a string for a given Platform and Encoding.
         
     | 
| 
      
 29 
     | 
    
         
            +
                class NameRecord < Font::TTF::FontChunk
         
     | 
| 
      
 30 
     | 
    
         
            +
                    include Font::TTF::Encodings
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    COPYRIGHT_NOTICE = 0
         
     | 
| 
      
 33 
     | 
    
         
            +
                    FONT_FAMILY_NAME = 1
         
     | 
| 
      
 34 
     | 
    
         
            +
                    FONT_SUBFAMILY_NAME = 2
         
     | 
| 
      
 35 
     | 
    
         
            +
                    UNIQUE_FONT_IDENTIFIER = 3
         
     | 
| 
      
 36 
     | 
    
         
            +
                    FULL_FONT_NAME = 4
         
     | 
| 
      
 37 
     | 
    
         
            +
                    VERSION_STRING = 5
         
     | 
| 
      
 38 
     | 
    
         
            +
                    POSTSCRIPT_NAME = 6
         
     | 
| 
      
 39 
     | 
    
         
            +
                    TRADEMARK = 7
         
     | 
| 
      
 40 
     | 
    
         
            +
                    MANUFACTURER_NAME = 8
         
     | 
| 
      
 41 
     | 
    
         
            +
                    DESIGNER_NAME = 9
         
     | 
| 
      
 42 
     | 
    
         
            +
                    DESCRIPTION = 10
         
     | 
| 
      
 43 
     | 
    
         
            +
                    VENDOR_URL = 11
         
     | 
| 
      
 44 
     | 
    
         
            +
                    DESIGNER_URL = 12
         
     | 
| 
      
 45 
     | 
    
         
            +
                    LICENSE_DESCRIPTION = 13
         
     | 
| 
      
 46 
     | 
    
         
            +
                    LICENSE_URL = 14
         
     | 
| 
      
 47 
     | 
    
         
            +
                    RESERVED = 15
         
     | 
| 
      
 48 
     | 
    
         
            +
                    PREFERRED_FAMILY = 16
         
     | 
| 
      
 49 
     | 
    
         
            +
                    PREFERRED_SUBFAMILY = 17
         
     | 
| 
      
 50 
     | 
    
         
            +
                    COMPATIBLE_FULL = 18
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    ID2NAME = {
         
     | 
| 
      
 53 
     | 
    
         
            +
                        COPYRIGHT_NOTICE => "Copyright Notice",
         
     | 
| 
      
 54 
     | 
    
         
            +
                        FONT_FAMILY_NAME => "Font Family Name",
         
     | 
| 
      
 55 
     | 
    
         
            +
                        FONT_SUBFAMILY_NAME => "Font Subfamily Name",
         
     | 
| 
      
 56 
     | 
    
         
            +
                        UNIQUE_FONT_IDENTIFIER => "Unique Font Identifier",
         
     | 
| 
      
 57 
     | 
    
         
            +
                        FULL_FONT_NAME => "Full Font Name",
         
     | 
| 
      
 58 
     | 
    
         
            +
                        VERSION_STRING => "Version String",
         
     | 
| 
      
 59 
     | 
    
         
            +
                        POSTSCRIPT_NAME => "Postscript Name",
         
     | 
| 
      
 60 
     | 
    
         
            +
                        TRADEMARK => "Trademark",
         
     | 
| 
      
 61 
     | 
    
         
            +
                        MANUFACTURER_NAME => "Manufacturer Name",
         
     | 
| 
      
 62 
     | 
    
         
            +
                        DESIGNER_NAME => "Designer Name",
         
     | 
| 
      
 63 
     | 
    
         
            +
                        DESCRIPTION => "Description",
         
     | 
| 
      
 64 
     | 
    
         
            +
                        VENDOR_URL => "Vendor URL",
         
     | 
| 
      
 65 
     | 
    
         
            +
                        DESIGNER_URL => "Designer URL",
         
     | 
| 
      
 66 
     | 
    
         
            +
                        LICENSE_DESCRIPTION => "License Description",
         
     | 
| 
      
 67 
     | 
    
         
            +
                        LICENSE_URL => "License URL",
         
     | 
| 
      
 68 
     | 
    
         
            +
                        RESERVED => "Reserved",
         
     | 
| 
      
 69 
     | 
    
         
            +
                        PREFERRED_FAMILY => "Preferred Family",
         
     | 
| 
      
 70 
     | 
    
         
            +
                        PREFERRED_SUBFAMILY => "Preferred Subfamily",
         
     | 
| 
      
 71 
     | 
    
         
            +
                        COMPATIBLE_FULL => "Compatible full"
         
     | 
| 
      
 72 
     | 
    
         
            +
                    }
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                  
         
     | 
| 
      
 75 
     | 
    
         
            +
                    SIZEOF_NAME_RECORD = 6 * IO::SIZEOF_USHORT
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                    attr_accessor :platform_id, :encoding_id, :language_id, :name_id, 
         
     | 
| 
      
 78 
     | 
    
         
            +
                                  :str_offset, :str
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                    def initialize(table, n=nil)
         
     | 
| 
      
 81 
     | 
    
         
            +
                        @table = table
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                        if n.nil?
         
     | 
| 
      
 84 
     | 
    
         
            +
                            # New name record created by hand
         
     | 
| 
      
 85 
     | 
    
         
            +
                            super(@table.font)
         
     | 
| 
      
 86 
     | 
    
         
            +
                            @platform_id = @table.font.read_ushort
         
     | 
| 
      
 87 
     | 
    
         
            +
                            @encoding_id = @table.font.read_ushort
         
     | 
| 
      
 88 
     | 
    
         
            +
                            @language_id = 0
         
     | 
| 
      
 89 
     | 
    
         
            +
                        else
         
     | 
| 
      
 90 
     | 
    
         
            +
                            offset = @table.offset + 3 * IO::SIZEOF_USHORT + \
         
     | 
| 
      
 91 
     | 
    
         
            +
                                    n * SIZEOF_NAME_RECORD
         
     | 
| 
      
 92 
     | 
    
         
            +
                
         
     | 
| 
      
 93 
     | 
    
         
            +
                            super(@table.font, offset, SIZEOF_NAME_RECORD)
         
     | 
| 
      
 94 
     | 
    
         
            +
                
         
     | 
| 
      
 95 
     | 
    
         
            +
                            @table.font.at_offset(@offset) do
         
     | 
| 
      
 96 
     | 
    
         
            +
                                @platform_id = @table.font.read_ushort
         
     | 
| 
      
 97 
     | 
    
         
            +
                                @encoding_id = @table.font.read_ushort
         
     | 
| 
      
 98 
     | 
    
         
            +
                                @language_id = @table.font.read_ushort
         
     | 
| 
      
 99 
     | 
    
         
            +
                                @name_id = @table.font.read_ushort
         
     | 
| 
      
 100 
     | 
    
         
            +
                                @str_len = @table.font.read_ushort
         
     | 
| 
      
 101 
     | 
    
         
            +
                                @str_offset = @table.font.read_ushort
         
     | 
| 
      
 102 
     | 
    
         
            +
                            end
         
     | 
| 
      
 103 
     | 
    
         
            +
                
         
     | 
| 
      
 104 
     | 
    
         
            +
                            offs = @table.offset + @table.string_storage_offset + \
         
     | 
| 
      
 105 
     | 
    
         
            +
                                   @str_offset
         
     | 
| 
      
 106 
     | 
    
         
            +
                            @table.font.at_offset(offs) do
         
     | 
| 
      
 107 
     | 
    
         
            +
                                @str = @table.font.read(@str_len)
         
     | 
| 
      
 108 
     | 
    
         
            +
                            end
         
     | 
| 
      
 109 
     | 
    
         
            +
                        end
         
     | 
| 
      
 110 
     | 
    
         
            +
                    end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                    # Returns string "as is".
         
     | 
| 
      
 113 
     | 
    
         
            +
                    def to_s
         
     | 
| 
      
 114 
     | 
    
         
            +
                        @str
         
     | 
| 
      
 115 
     | 
    
         
            +
                    end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                    # Returns whether the string is Macintosh Roman or not.
         
     | 
| 
      
 118 
     | 
    
         
            +
                    def roman?
         
     | 
| 
      
 119 
     | 
    
         
            +
                        @platform_id == Platform::MACINTOSH and \
         
     | 
| 
      
 120 
     | 
    
         
            +
                        @encoding_id == MacintoshEncoding::ROMAN
         
     | 
| 
      
 121 
     | 
    
         
            +
                    end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                    # Returns whether the string is unicode or not.
         
     | 
| 
      
 124 
     | 
    
         
            +
                    def unicode?
         
     | 
| 
      
 125 
     | 
    
         
            +
                        @platform_id == Platform::UNICODE or \
         
     | 
| 
      
 126 
     | 
    
         
            +
                        (@platform_id == Platform::MICROSOFT and \
         
     | 
| 
      
 127 
     | 
    
         
            +
                        @encoding_id == MicrosoftEncoding::UNICODE)
         
     | 
| 
      
 128 
     | 
    
         
            +
                    end
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                    # Returns the string in UTF-8 if possible.
         
     | 
| 
      
 131 
     | 
    
         
            +
                    def utf8_str
         
     | 
| 
      
 132 
     | 
    
         
            +
                        if unicode?
         
     | 
| 
      
 133 
     | 
    
         
            +
                            # from utf-16 big endian to utf-8
         
     | 
| 
      
 134 
     | 
    
         
            +
                            Iconv.new("utf-8", "utf-16be").iconv(@str)
         
     | 
| 
      
 135 
     | 
    
         
            +
                        else
         
     | 
| 
      
 136 
     | 
    
         
            +
                            @str
         
     | 
| 
      
 137 
     | 
    
         
            +
                        end
         
     | 
| 
      
 138 
     | 
    
         
            +
                    end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                    # Sets the NameRecord string with new_string being UTF-8.
         
     | 
| 
      
 141 
     | 
    
         
            +
                    def utf8_str=(new_string)
         
     | 
| 
      
 142 
     | 
    
         
            +
                        if unicode?
         
     | 
| 
      
 143 
     | 
    
         
            +
                            # from utf-8 to utf-16 big endian
         
     | 
| 
      
 144 
     | 
    
         
            +
                            @str = Iconv.new("utf-16be", "utf-8").iconv(new_string)
         
     | 
| 
      
 145 
     | 
    
         
            +
                        else
         
     | 
| 
      
 146 
     | 
    
         
            +
                            @str = new_string
         
     | 
| 
      
 147 
     | 
    
         
            +
                        end
         
     | 
| 
      
 148 
     | 
    
         
            +
                    end
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                    def dump
         
     | 
| 
      
 151 
     | 
    
         
            +
                        # Dump everything except str_offset, which can't be calculated
         
     | 
| 
      
 152 
     | 
    
         
            +
                        # here and the string itself which must be put in the storage
         
     | 
| 
      
 153 
     | 
    
         
            +
                        # area
         
     | 
| 
      
 154 
     | 
    
         
            +
                        raw = (@platform_id || Platform::MACINTOSH).to_ushort
         
     | 
| 
      
 155 
     | 
    
         
            +
                        raw += (@encoding_id || MacintoshEncoding::ROMAN).to_ushort
         
     | 
| 
      
 156 
     | 
    
         
            +
                        raw += (@language_id || 0).to_ushort
         
     | 
| 
      
 157 
     | 
    
         
            +
                        raw += (@name_id || 0).to_ushort
         
     | 
| 
      
 158 
     | 
    
         
            +
                        raw += (@str.length || 0).to_ushort
         
     | 
| 
      
 159 
     | 
    
         
            +
                    end
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                end
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                attr_accessor :format_selector
         
     | 
| 
      
 164 
     | 
    
         
            +
                # An Array of NameRecord objects.
         
     | 
| 
      
 165 
     | 
    
         
            +
                attr_accessor :name_records
         
     | 
| 
      
 166 
     | 
    
         
            +
                attr_reader :string_storage_offset
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                def initialize(*args)
         
     | 
| 
      
 169 
     | 
    
         
            +
                    super(*args)
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
                    if exists_in_file?
         
     | 
| 
      
 172 
     | 
    
         
            +
                        @font.at_offset(@offset) do
         
     | 
| 
      
 173 
     | 
    
         
            +
                            @format_selector = @font.read_ushort
         
     | 
| 
      
 174 
     | 
    
         
            +
                            @name_record_num = @font.read_ushort
         
     | 
| 
      
 175 
     | 
    
         
            +
                            @string_storage_offset = @font.read_ushort
         
     | 
| 
      
 176 
     | 
    
         
            +
                        end
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
                        @name_records = []
         
     | 
| 
      
 179 
     | 
    
         
            +
                        @name_record_num.times do |i|
         
     | 
| 
      
 180 
     | 
    
         
            +
                            @name_records << NameRecord.new(self, i)
         
     | 
| 
      
 181 
     | 
    
         
            +
                        end
         
     | 
| 
      
 182 
     | 
    
         
            +
                    end
         
     | 
| 
      
 183 
     | 
    
         
            +
                end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                # Gets a new empty NameRecord which may then be added to the 
         
     | 
| 
      
 186 
     | 
    
         
            +
                # name_records array.
         
     | 
| 
      
 187 
     | 
    
         
            +
                def get_new_name_record
         
     | 
| 
      
 188 
     | 
    
         
            +
                    NameRecord.new(self)
         
     | 
| 
      
 189 
     | 
    
         
            +
                end
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
                # Dumps the name table in binary raw format as may be found in a font
         
     | 
| 
      
 192 
     | 
    
         
            +
                # file.
         
     | 
| 
      
 193 
     | 
    
         
            +
                def dump
         
     | 
| 
      
 194 
     | 
    
         
            +
                    raw = (@format_selector || 0).to_ushort
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
                    nr_num = @name_records.length || 0
         
     | 
| 
      
 197 
     | 
    
         
            +
                    raw += nr_num.to_ushort
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                    string_storage_offset = 3 * IO::SIZEOF_USHORT + \
         
     | 
| 
      
 200 
     | 
    
         
            +
                                            nr_num * NameRecord::SIZEOF_NAME_RECORD
         
     | 
| 
      
 201 
     | 
    
         
            +
                    raw += string_storage_offset.to_ushort
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
                    str_offset = 0 # starting from string_storage_offset
         
     | 
| 
      
 204 
     | 
    
         
            +
                    strs = []
         
     | 
| 
      
 205 
     | 
    
         
            +
                    @name_records.each do |nr|
         
     | 
| 
      
 206 
     | 
    
         
            +
                        raw += nr.dump
         
     | 
| 
      
 207 
     | 
    
         
            +
                        raw += str_offset.to_ushort
         
     | 
| 
      
 208 
     | 
    
         
            +
                        str_offset += nr.str.length
         
     | 
| 
      
 209 
     | 
    
         
            +
                        strs << nr.str
         
     | 
| 
      
 210 
     | 
    
         
            +
                    end
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
                    strs.each do |str|
         
     | 
| 
      
 213 
     | 
    
         
            +
                        raw += str
         
     | 
| 
      
 214 
     | 
    
         
            +
                    end
         
     | 
| 
      
 215 
     | 
    
         
            +
                    raw
         
     | 
| 
      
 216 
     | 
    
         
            +
                end
         
     | 
| 
      
 217 
     | 
    
         
            +
               
         
     | 
| 
      
 218 
     | 
    
         
            +
            end
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
            end
         
     | 
| 
      
 221 
     | 
    
         
            +
            end
         
     | 
| 
      
 222 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,172 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # TTF/Ruby, a library to read and write TrueType fonts in Ruby.
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Copyright (C) 2006  Mathieu Blondel
         
     | 
| 
      
 3 
     | 
    
         
            +
            # 
         
     | 
| 
      
 4 
     | 
    
         
            +
            # This program is free software; you can redistribute it and/or modify
         
     | 
| 
      
 5 
     | 
    
         
            +
            # it under the terms of the GNU General Public License as published by
         
     | 
| 
      
 6 
     | 
    
         
            +
            # the Free Software Foundation; either version 2 of the License, or
         
     | 
| 
      
 7 
     | 
    
         
            +
            # (at your option) any later version.
         
     | 
| 
      
 8 
     | 
    
         
            +
            # 
         
     | 
| 
      
 9 
     | 
    
         
            +
            # This program is distributed in the hope that it will be useful,
         
     | 
| 
      
 10 
     | 
    
         
            +
            # but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
      
 11 
     | 
    
         
            +
            # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
      
 12 
     | 
    
         
            +
            # GNU General Public License for more details.
         
     | 
| 
      
 13 
     | 
    
         
            +
            # 
         
     | 
| 
      
 14 
     | 
    
         
            +
            # You should have received a copy of the GNU General Public License
         
     | 
| 
      
 15 
     | 
    
         
            +
            # along with this program; if not, write to the Free Software
         
     | 
| 
      
 16 
     | 
    
         
            +
            # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            module Font
         
     | 
| 
      
 19 
     | 
    
         
            +
            module TTF
         
     | 
| 
      
 20 
     | 
    
         
            +
            module Table
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            # OS2 is the OS/2 and Windows font metrics table.
         
     | 
| 
      
 23 
     | 
    
         
            +
            class OS2 < Font::TTF::FontChunk
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                INSTALLABLE_EMBEDDING = 0x0000
         
     | 
| 
      
 26 
     | 
    
         
            +
                RESTRICTED_LICENCE_EMBEDDING = 0x0002
         
     | 
| 
      
 27 
     | 
    
         
            +
                PREVIEW_AND_PRINT_EMBEDDING = 0x0004
         
     | 
| 
      
 28 
     | 
    
         
            +
                EDITABLE_EMBEDDING = 0x0008
         
     | 
| 
      
 29 
     | 
    
         
            +
                NO_SUBSET_EMBEDDING = 0x0100
         
     | 
| 
      
 30 
     | 
    
         
            +
                BITMAP_ONLY_EMBEDDING = 0x0200
         
     | 
| 
      
 31 
     | 
    
         
            +
                
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                attr_accessor :version, :x_avg_char_width, :us_weight_class,
         
     | 
| 
      
 34 
     | 
    
         
            +
                              :us_width_class, :fs_type, :y_subscriptXSize,
         
     | 
| 
      
 35 
     | 
    
         
            +
                              :y_subscript_y_size, :y_subscript_x_offset,
         
     | 
| 
      
 36 
     | 
    
         
            +
                              :y_subscript_y_offset, :y_superscript_x_size,
         
     | 
| 
      
 37 
     | 
    
         
            +
                              :y_superscript_y_size, :y_superscript_x_offset,
         
     | 
| 
      
 38 
     | 
    
         
            +
                              :y_superscript_y_offset, :y_strikeout_size,
         
     | 
| 
      
 39 
     | 
    
         
            +
                              :y_strikeout_position, :s_family_class,
         
     | 
| 
      
 40 
     | 
    
         
            +
                              :panose, :ul_unicode_range1, :ul_unicode_range2,
         
     | 
| 
      
 41 
     | 
    
         
            +
                              :ul_unicode_range3, :ul_unicode_range4, 
         
     | 
| 
      
 42 
     | 
    
         
            +
                              :ach_vend_id, :fs_selection, :us_first_char_index,
         
     | 
| 
      
 43 
     | 
    
         
            +
                              :us_last_char_index, :s_typo_ascender, :s_typo_descender,
         
     | 
| 
      
 44 
     | 
    
         
            +
                              :s_typo_line_gap, :us_win_ascent, :us_win_descent,
         
     | 
| 
      
 45 
     | 
    
         
            +
                              :ul_code_page_range1, :ul_code_page_range2,
         
     | 
| 
      
 46 
     | 
    
         
            +
                              :sx_height, :s_cap_height, :us_default_char,
         
     | 
| 
      
 47 
     | 
    
         
            +
                              :us_break_char, :us_max_context
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                def initialize(*args)
         
     | 
| 
      
 50 
     | 
    
         
            +
                    super(*args)
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    if exists_in_file?
         
     | 
| 
      
 53 
     | 
    
         
            +
                        @font.at_offset(@offset) do
         
     | 
| 
      
 54 
     | 
    
         
            +
                            @version = @font.read_ushort
         
     | 
| 
      
 55 
     | 
    
         
            +
                            @x_avg_char_width = @font.read_short
         
     | 
| 
      
 56 
     | 
    
         
            +
                            @us_weight_class = @font.read_ushort
         
     | 
| 
      
 57 
     | 
    
         
            +
                            @us_width_class = @font.read_ushort
         
     | 
| 
      
 58 
     | 
    
         
            +
                            @fs_type = @font.read_short
         
     | 
| 
      
 59 
     | 
    
         
            +
                            @y_subscriptXSize = @font.read_short
         
     | 
| 
      
 60 
     | 
    
         
            +
                            @y_subscript_y_size = @font.read_short
         
     | 
| 
      
 61 
     | 
    
         
            +
                            @y_subscript_x_offset = @font.read_short
         
     | 
| 
      
 62 
     | 
    
         
            +
                            @y_subscript_y_offset = @font.read_short
         
     | 
| 
      
 63 
     | 
    
         
            +
                            @y_superscript_x_size = @font.read_short
         
     | 
| 
      
 64 
     | 
    
         
            +
                            @y_superscript_y_size = @font.read_short
         
     | 
| 
      
 65 
     | 
    
         
            +
                            @y_superscript_x_offset = @font.read_short
         
     | 
| 
      
 66 
     | 
    
         
            +
                            @y_superscript_y_offset = @font.read_short
         
     | 
| 
      
 67 
     | 
    
         
            +
                            @y_strikeout_size = @font.read_short
         
     | 
| 
      
 68 
     | 
    
         
            +
                            @y_strikeout_position = @font.read_short
         
     | 
| 
      
 69 
     | 
    
         
            +
                            @s_family_class = @font.read_short
         
     | 
| 
      
 70 
     | 
    
         
            +
                            @panose = @font.read_bytes(10)
         
     | 
| 
      
 71 
     | 
    
         
            +
                            @ul_unicode_range1 = @font.read_ulong
         
     | 
| 
      
 72 
     | 
    
         
            +
                            @ul_unicode_range2 = @font.read_ulong
         
     | 
| 
      
 73 
     | 
    
         
            +
                            @ul_unicode_range3 = @font.read_ulong
         
     | 
| 
      
 74 
     | 
    
         
            +
                            @ul_unicode_range4 = @font.read_ulong
         
     | 
| 
      
 75 
     | 
    
         
            +
                            @ach_vend_id = @font.read_chars(4)
         
     | 
| 
      
 76 
     | 
    
         
            +
                            @fs_selection = @font.read_ushort
         
     | 
| 
      
 77 
     | 
    
         
            +
                            @us_first_char_index = @font.read_ushort
         
     | 
| 
      
 78 
     | 
    
         
            +
                            @us_last_char_index = @font.read_ushort
         
     | 
| 
      
 79 
     | 
    
         
            +
                            @s_typo_ascender = @font.read_short
         
     | 
| 
      
 80 
     | 
    
         
            +
                            @s_typo_descender = @font.read_short
         
     | 
| 
      
 81 
     | 
    
         
            +
                            @s_typo_line_gap = @font.read_short
         
     | 
| 
      
 82 
     | 
    
         
            +
                            @us_win_ascent = @font.read_ushort
         
     | 
| 
      
 83 
     | 
    
         
            +
                            @us_win_descent = @font.read_ushort
         
     | 
| 
      
 84 
     | 
    
         
            +
                            @ul_code_page_range1 = @font.read_ulong
         
     | 
| 
      
 85 
     | 
    
         
            +
                            @ul_code_page_range2 = @font.read_ulong
         
     | 
| 
      
 86 
     | 
    
         
            +
                            # From opentype spec
         
     | 
| 
      
 87 
     | 
    
         
            +
                            @sx_height = @font.read_short
         
     | 
| 
      
 88 
     | 
    
         
            +
                            @s_cap_height = @font.read_short
         
     | 
| 
      
 89 
     | 
    
         
            +
                            @us_default_char = @font.read_ushort
         
     | 
| 
      
 90 
     | 
    
         
            +
                            @us_break_char = @font.read_ushort
         
     | 
| 
      
 91 
     | 
    
         
            +
                            @us_max_context = @font.read_ushort
         
     | 
| 
      
 92 
     | 
    
         
            +
                        end
         
     | 
| 
      
 93 
     | 
    
         
            +
                    end
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                def installable_embedding?
         
     | 
| 
      
 97 
     | 
    
         
            +
                    @fs_type == INSTALLABLE_EMBEDDING
         
     | 
| 
      
 98 
     | 
    
         
            +
                end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                def editable_embedding?
         
     | 
| 
      
 101 
     | 
    
         
            +
                    installable_embedding? or @fs_type & EDITABLE_EMBEDDING != 0
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                def preview_and_print_embedding?
         
     | 
| 
      
 105 
     | 
    
         
            +
                    editable_embedding? or @fs_type & PREVIEW_AND_PRINT_EMBEDDING != 0
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                def restricted_licence_embedding?
         
     | 
| 
      
 109 
     | 
    
         
            +
                    (not preview_and_print_embedding? and 
         
     | 
| 
      
 110 
     | 
    
         
            +
                        @fs_type & RESTRICTED_LICENCE_EMBEDDING != 0)
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                def no_subset_embedding?
         
     | 
| 
      
 114 
     | 
    
         
            +
                    @fs_type & NO_SUBSET_EMBEDDING != 0
         
     | 
| 
      
 115 
     | 
    
         
            +
                end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                def subset_embedding?
         
     | 
| 
      
 118 
     | 
    
         
            +
                    not no_subset_embedding?
         
     | 
| 
      
 119 
     | 
    
         
            +
                end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                def bitmap_only_embedding?
         
     | 
| 
      
 122 
     | 
    
         
            +
                    @fs_type & BITMAP_ONLY_EMBEDDING != 0
         
     | 
| 
      
 123 
     | 
    
         
            +
                end
         
     | 
| 
      
 124 
     | 
    
         
            +
                
         
     | 
| 
      
 125 
     | 
    
         
            +
                # Dumps the os2 table in binary raw format as may be found in a font
         
     | 
| 
      
 126 
     | 
    
         
            +
                # file.
         
     | 
| 
      
 127 
     | 
    
         
            +
                def dump
         
     | 
| 
      
 128 
     | 
    
         
            +
                    raw = (@version || 0).to_ushort
         
     | 
| 
      
 129 
     | 
    
         
            +
                    raw += (@x_avg_char_width || 0).to_short
         
     | 
| 
      
 130 
     | 
    
         
            +
                    raw += (@us_weight_class || 0).to_ushort
         
     | 
| 
      
 131 
     | 
    
         
            +
                    raw += (@us_width_class || 0).to_ushort
         
     | 
| 
      
 132 
     | 
    
         
            +
                    raw += (@fs_type || 0).to_ushort
         
     | 
| 
      
 133 
     | 
    
         
            +
                    raw += (@y_subscriptXSize || 0).to_short
         
     | 
| 
      
 134 
     | 
    
         
            +
                    raw += (@y_subscript_y_size || 0).to_short
         
     | 
| 
      
 135 
     | 
    
         
            +
                    raw += (@y_subscript_x_offset || 0).to_short
         
     | 
| 
      
 136 
     | 
    
         
            +
                    raw += (@y_subscript_y_offset || 0).to_short
         
     | 
| 
      
 137 
     | 
    
         
            +
                    raw += (@y_superscript_x_size || 0).to_short
         
     | 
| 
      
 138 
     | 
    
         
            +
                    raw += (@y_superscript_y_size || 0).to_short
         
     | 
| 
      
 139 
     | 
    
         
            +
                    raw += (@y_superscript_x_offset || 0).to_short
         
     | 
| 
      
 140 
     | 
    
         
            +
                    raw += (@y_superscript_y_offset || 0).to_short
         
     | 
| 
      
 141 
     | 
    
         
            +
                    raw += (@y_strikeout_size || 0).to_short
         
     | 
| 
      
 142 
     | 
    
         
            +
                    raw += (@y_strikeout_position || 0).to_short
         
     | 
| 
      
 143 
     | 
    
         
            +
                    raw += (@s_family_class || 0).to_short
         
     | 
| 
      
 144 
     | 
    
         
            +
                    raw += (@panose || [0] * 10).to_bytes
         
     | 
| 
      
 145 
     | 
    
         
            +
                    raw += (@ul_unicode_range1 || 0).to_ulong
         
     | 
| 
      
 146 
     | 
    
         
            +
                    raw += (@ul_unicode_range2 || 0).to_ulong
         
     | 
| 
      
 147 
     | 
    
         
            +
                    raw += (@ul_unicode_range3 || 0).to_ulong
         
     | 
| 
      
 148 
     | 
    
         
            +
                    raw += (@ul_unicode_range4 || 0).to_ulong
         
     | 
| 
      
 149 
     | 
    
         
            +
                    raw += (@ach_vend_id || " " * 4)
         
     | 
| 
      
 150 
     | 
    
         
            +
                    raw += (@fs_selection || 0).to_ushort
         
     | 
| 
      
 151 
     | 
    
         
            +
                    raw += (@us_first_char_index || 0).to_ushort
         
     | 
| 
      
 152 
     | 
    
         
            +
                    raw += (@us_last_char_index || 0).to_ushort
         
     | 
| 
      
 153 
     | 
    
         
            +
                    raw += (@s_typo_ascender || 0).to_short
         
     | 
| 
      
 154 
     | 
    
         
            +
                    raw += (@s_typo_descender || 0).to_short
         
     | 
| 
      
 155 
     | 
    
         
            +
                    raw += (@s_typo_line_gap || 0).to_short
         
     | 
| 
      
 156 
     | 
    
         
            +
                    raw += (@us_win_ascent || 0).to_ushort
         
     | 
| 
      
 157 
     | 
    
         
            +
                    raw += (@us_win_descent || 0).to_ushort
         
     | 
| 
      
 158 
     | 
    
         
            +
                    raw += (@ul_code_page_range1 || 0).to_ulong
         
     | 
| 
      
 159 
     | 
    
         
            +
                    raw += (@ul_code_page_range2 || 0).to_ulong
         
     | 
| 
      
 160 
     | 
    
         
            +
                    # From opentype spec
         
     | 
| 
      
 161 
     | 
    
         
            +
                    raw += (@sx_height || 0).to_short
         
     | 
| 
      
 162 
     | 
    
         
            +
                    raw += (@s_cap_height || 0).to_short
         
     | 
| 
      
 163 
     | 
    
         
            +
                    raw += (@us_default_char || 0).to_ushort
         
     | 
| 
      
 164 
     | 
    
         
            +
                    raw += (@us_break_char || 0).to_ushort
         
     | 
| 
      
 165 
     | 
    
         
            +
                    raw += (@us_max_context || 0).to_ushort
         
     | 
| 
      
 166 
     | 
    
         
            +
                end
         
     | 
| 
      
 167 
     | 
    
         
            +
                
         
     | 
| 
      
 168 
     | 
    
         
            +
            end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
            end
         
     | 
| 
      
 171 
     | 
    
         
            +
            end
         
     | 
| 
      
 172 
     | 
    
         
            +
            end
         
     |