glyph_imager 0.0.14 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/VERSION +1 -1
  2. data/glyph_imager.gemspec +45 -36
  3. data/lib/glyph_imager.rb +19 -27
  4. data/test/fonts/Musica.ttf +0 -0
  5. data/test/test_glyph_imager.rb +9 -3
  6. data/vendor/ttfunk/.gitignore +1 -0
  7. data/vendor/ttfunk/data/fonts/DejaVuSans.ttf +0 -0
  8. data/vendor/ttfunk/data/fonts/comicsans.ttf +0 -0
  9. data/vendor/ttfunk/example.rb +45 -0
  10. data/vendor/ttfunk/lib/ttfunk.rb +102 -0
  11. data/vendor/ttfunk/lib/ttfunk/directory.rb +17 -0
  12. data/vendor/ttfunk/lib/ttfunk/encoding/mac_roman.rb +88 -0
  13. data/vendor/ttfunk/lib/ttfunk/encoding/windows_1252.rb +69 -0
  14. data/vendor/ttfunk/lib/ttfunk/reader.rb +44 -0
  15. data/vendor/ttfunk/lib/ttfunk/resource_file.rb +78 -0
  16. data/vendor/ttfunk/lib/ttfunk/subset.rb +18 -0
  17. data/vendor/ttfunk/lib/ttfunk/subset/base.rb +141 -0
  18. data/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb +50 -0
  19. data/vendor/ttfunk/lib/ttfunk/subset/unicode.rb +48 -0
  20. data/vendor/ttfunk/lib/ttfunk/subset/unicode_8bit.rb +63 -0
  21. data/vendor/ttfunk/lib/ttfunk/subset/windows_1252.rb +55 -0
  22. data/vendor/ttfunk/lib/ttfunk/subset_collection.rb +72 -0
  23. data/vendor/ttfunk/lib/ttfunk/table.rb +46 -0
  24. data/vendor/ttfunk/lib/ttfunk/table/cmap.rb +34 -0
  25. data/vendor/ttfunk/lib/ttfunk/table/cmap/format00.rb +54 -0
  26. data/vendor/ttfunk/lib/ttfunk/table/cmap/format04.rb +126 -0
  27. data/vendor/ttfunk/lib/ttfunk/table/cmap/format12.rb +37 -0
  28. data/vendor/ttfunk/lib/ttfunk/table/cmap/subtable.rb +82 -0
  29. data/vendor/ttfunk/lib/ttfunk/table/glyf.rb +64 -0
  30. data/vendor/ttfunk/lib/ttfunk/table/glyf/compound.rb +81 -0
  31. data/vendor/ttfunk/lib/ttfunk/table/glyf/simple.rb +37 -0
  32. data/vendor/ttfunk/lib/ttfunk/table/head.rb +44 -0
  33. data/vendor/ttfunk/lib/ttfunk/table/hhea.rb +41 -0
  34. data/vendor/ttfunk/lib/ttfunk/table/hmtx.rb +47 -0
  35. data/vendor/ttfunk/lib/ttfunk/table/kern.rb +79 -0
  36. data/vendor/ttfunk/lib/ttfunk/table/kern/format0.rb +62 -0
  37. data/vendor/ttfunk/lib/ttfunk/table/loca.rb +43 -0
  38. data/vendor/ttfunk/lib/ttfunk/table/maxp.rb +40 -0
  39. data/vendor/ttfunk/lib/ttfunk/table/name.rb +125 -0
  40. data/vendor/ttfunk/lib/ttfunk/table/os2.rb +78 -0
  41. data/vendor/ttfunk/lib/ttfunk/table/post.rb +91 -0
  42. data/vendor/ttfunk/lib/ttfunk/table/post/format10.rb +43 -0
  43. data/vendor/ttfunk/lib/ttfunk/table/post/format20.rb +35 -0
  44. data/vendor/ttfunk/lib/ttfunk/table/post/format25.rb +23 -0
  45. data/vendor/ttfunk/lib/ttfunk/table/post/format30.rb +17 -0
  46. data/vendor/ttfunk/lib/ttfunk/table/post/format40.rb +17 -0
  47. data/vendor/ttfunk/lib/ttfunk/table/simple.rb +14 -0
  48. metadata +46 -37
  49. data/vendor/ttf-ruby-0.1/AUTHORS +0 -1
  50. data/vendor/ttf-ruby-0.1/COPYING +0 -340
  51. data/vendor/ttf-ruby-0.1/README +0 -49
  52. data/vendor/ttf-ruby-0.1/TODO +0 -23
  53. data/vendor/ttf-ruby-0.1/VERSION +0 -1
  54. data/vendor/ttf-ruby-0.1/lib/ttf.rb +0 -20
  55. data/vendor/ttf-ruby-0.1/lib/ttf/datatypes.rb +0 -181
  56. data/vendor/ttf-ruby-0.1/lib/ttf/encodings.rb +0 -140
  57. data/vendor/ttf-ruby-0.1/lib/ttf/exceptions.rb +0 -28
  58. data/vendor/ttf-ruby-0.1/lib/ttf/font_loader.rb +0 -290
  59. data/vendor/ttf-ruby-0.1/lib/ttf/fontchunk.rb +0 -77
  60. data/vendor/ttf-ruby-0.1/lib/ttf/table/cmap.rb +0 -408
  61. data/vendor/ttf-ruby-0.1/lib/ttf/table/cvt.rb +0 -49
  62. data/vendor/ttf-ruby-0.1/lib/ttf/table/fpgm.rb +0 -48
  63. data/vendor/ttf-ruby-0.1/lib/ttf/table/gasp.rb +0 -88
  64. data/vendor/ttf-ruby-0.1/lib/ttf/table/glyf.rb +0 -452
  65. data/vendor/ttf-ruby-0.1/lib/ttf/table/head.rb +0 -86
  66. data/vendor/ttf-ruby-0.1/lib/ttf/table/hhea.rb +0 -96
  67. data/vendor/ttf-ruby-0.1/lib/ttf/table/hmtx.rb +0 -98
  68. data/vendor/ttf-ruby-0.1/lib/ttf/table/kern.rb +0 -186
  69. data/vendor/ttf-ruby-0.1/lib/ttf/table/loca.rb +0 -75
  70. data/vendor/ttf-ruby-0.1/lib/ttf/table/maxp.rb +0 -81
  71. data/vendor/ttf-ruby-0.1/lib/ttf/table/name.rb +0 -226
  72. data/vendor/ttf-ruby-0.1/lib/ttf/table/os2.rb +0 -172
  73. data/vendor/ttf-ruby-0.1/lib/ttf/table/post.rb +0 -120
  74. data/vendor/ttf-ruby-0.1/lib/ttf/table/prep.rb +0 -27
  75. data/vendor/ttf-ruby-0.1/lib/ttf/table/vhea.rb +0 -45
  76. data/vendor/ttf-ruby-0.1/lib/ttf/table/vmtx.rb +0 -36
  77. data/vendor/ttf-ruby-0.1/setup.rb +0 -1558
  78. data/vendor/ttf-ruby-0.1/tools/README +0 -44
  79. data/vendor/ttf-ruby-0.1/tools/ttfcairoglyphviewer +0 -229
  80. data/vendor/ttf-ruby-0.1/tools/ttfdump +0 -396
  81. data/vendor/ttf-ruby-0.1/tools/ttfglyph2svg +0 -144
  82. data/vendor/ttf-ruby-0.1/tools/ttfsubset +0 -273
@@ -1,75 +0,0 @@
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 TTFFont
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 < TTFFont::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 TTFFont::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 TTFFont::TTF::File#get_table or TTFFont::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 TTFFont::TTF::Table::Head::SHORT_FORMAT
49
- @glyph_offsets = @font.read_ushorts(n)
50
- @glyph_offsets.collect! { |o| o * 2 }
51
- when TTFFont::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 TTFFont::TTF::Table::Head::SHORT_FORMAT
64
- @glyph_offsets.collect { |o| o / 2 }.to_ushorts
65
- when TTFFont::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
@@ -1,81 +0,0 @@
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 TTFFont
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 < TTFFont::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
@@ -1,226 +0,0 @@
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 TTFFont
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 < TTFFont::TTF::FontChunk
27
-
28
- # A NameRecord holds a string for a given Platform and Encoding.
29
- class NameRecord < TTFFont::TTF::FontChunk
30
- include TTFFont::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
- def find_record_by_id(id)
186
- @name_records.detect { |r| r.name_id == id }
187
- end
188
-
189
- # Gets a new empty NameRecord which may then be added to the
190
- # name_records array.
191
- def get_new_name_record
192
- NameRecord.new(self)
193
- end
194
-
195
- # Dumps the name table in binary raw format as may be found in a font
196
- # file.
197
- def dump
198
- raw = (@format_selector || 0).to_ushort
199
-
200
- nr_num = @name_records.length || 0
201
- raw += nr_num.to_ushort
202
-
203
- string_storage_offset = 3 * IO::SIZEOF_USHORT + \
204
- nr_num * NameRecord::SIZEOF_NAME_RECORD
205
- raw += string_storage_offset.to_ushort
206
-
207
- str_offset = 0 # starting from string_storage_offset
208
- strs = []
209
- @name_records.each do |nr|
210
- raw += nr.dump
211
- raw += str_offset.to_ushort
212
- str_offset += nr.str.length
213
- strs << nr.str
214
- end
215
-
216
- strs.each do |str|
217
- raw += str
218
- end
219
- raw
220
- end
221
-
222
- end
223
-
224
- end
225
- end
226
- end
@@ -1,172 +0,0 @@
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 TTFFont
19
- module TTF
20
- module Table
21
-
22
- # OS2 is the OS/2 and Windows font metrics table.
23
- class OS2 < TTFFont::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