Class: TTFunk::Table::Sbix
- Inherits:
-
TTFunk::Table
- Object
- TTFunk::Table
- TTFunk::Table::Sbix
- Defined in:
- lib/ttfunk/table/sbix.rb
Overview
Standard Bitmap Graphics (sbix
) table.
Defined Under Namespace
Classes: BitmapData
Instance Attribute Summary collapse
-
#flags ⇒ Integer
readonly
Flags.
-
#num_strikes ⇒ Integer
readonly
Number of bitmap strikes.
-
#strikes ⇒ Array<Hash>
readonly
Strikes.
-
#version ⇒ Integer
readonly
Table version.
Attributes inherited from TTFunk::Table
Instance Method Summary collapse
-
#all_bitmap_data_for(glyph_id) ⇒ Array<BitmapData>
Get all bitmaps for glyph.
-
#bitmap_data_for(glyph_id, strike_index) ⇒ BitmapData
Get bitmap for glyph strike.
Methods inherited from TTFunk::Table
#exists?, #initialize, #raw, #tag
Constructor Details
This class inherits a constructor from TTFunk::Table
Instance Attribute Details
#flags ⇒ Integer (readonly)
Flags.
Source Code
lib/ttfunk/table/sbix.rb, line 15
15 | def flags |
16 | @flags
|
17 | end
|
#num_strikes ⇒ Integer (readonly)
Number of bitmap strikes.
Source Code
lib/ttfunk/table/sbix.rb, line 19
19 | def num_strikes |
20 | @num_strikes
|
21 | end
|
#strikes ⇒ Array<Hash> (readonly)
Strikes.
Source Code
lib/ttfunk/table/sbix.rb, line 23
23 | def strikes |
24 | @strikes
|
25 | end
|
#version ⇒ Integer (readonly)
Table version.
Source Code
lib/ttfunk/table/sbix.rb, line 11
11 | def version |
12 | @version
|
13 | end
|
Instance Method Details
#all_bitmap_data_for(glyph_id) ⇒ Array<BitmapData>
Get all bitmaps for glyph.
Source Code
lib/ttfunk/table/sbix.rb, line 72
72 | def all_bitmap_data_for(glyph_id) |
73 | strikes.each_index.filter_map { |strike_index| |
74 | bitmap_data_for(glyph_id, strike_index) |
75 | }
|
76 | end
|
#bitmap_data_for(glyph_id, strike_index) ⇒ BitmapData
Get bitmap for glyph strike.
Source Code
lib/ttfunk/table/sbix.rb, line 49
49 | def bitmap_data_for(glyph_id, strike_index) |
50 | strike = strikes[strike_index] |
51 | return if strike.nil? |
52 | |
53 | glyph_offset = strike[:glyph_data_offset][glyph_id] |
54 | next_glyph_offset = strike[:glyph_data_offset][glyph_id + 1] |
55 | |
56 | if glyph_offset && next_glyph_offset |
57 | bytes = next_glyph_offset - glyph_offset |
58 | if bytes.positive? |
59 | parse_from(offset + strike[:offset] + glyph_offset) { |
60 | x, y, type = read(8, 's2A4') |
61 | data = StringIO.new(io.read(bytes - 8)) |
62 | BitmapData.new(x, y, type, data, strike[:ppem], strike[:resolution]) |
63 | }
|
64 | end
|
65 | end
|
66 | end
|