Class: TTFunk::Table::Sbix

Inherits:
TTFunk::Table show all
Defined in:
lib/ttfunk/table/sbix.rb

Overview

Standard Bitmap Graphics (sbix) table.

Defined Under Namespace

Classes: BitmapData

Instance Attribute Summary collapse

Attributes inherited from TTFunk::Table

#file, #length, #offset

Instance Method Summary collapse

Methods inherited from TTFunk::Table

#exists?, #initialize, #raw, #tag

Constructor Details

This class inherits a constructor from TTFunk::Table

Instance Attribute Details

#flagsInteger (readonly)

Flags.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/sbix.rb, line 15
15
def flags
16
  @flags
17
end

#num_strikesInteger (readonly)

Number of bitmap strikes.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/sbix.rb, line 19
19
def num_strikes
20
  @num_strikes
21
end

#strikesArray<Hash> (readonly)

Strikes.

Returns:

  • (Array<Hash>)
Source Code
lib/ttfunk/table/sbix.rb, line 23
23
def strikes
24
  @strikes
25
end

#versionInteger (readonly)

Table version.

Returns:

  • (Integer)
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.

Parameters:

  • glyph_id (Integer)

Returns:

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.

Parameters:

  • glyph_id (Integer)
  • strike_index (Integer)

Returns:

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