Class: Fontisan::Subset::TableStrategy::ColorBitmapSubtablePlan

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb

Overview

Plan for one IndexSubTable emitted by [ColorBitmapSubsetter]: a contiguous run of new GIDs at a single strike, with the CBDT offsets and lengths needed to emit a format 1 IndexSubTable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strike_ppem:, image_format:) ⇒ ColorBitmapSubtablePlan

Returns a new instance of ColorBitmapSubtablePlan.



12
13
14
15
16
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 12

def initialize(strike_ppem:, image_format:)
  @strike_ppem = strike_ppem
  @image_format = image_format
  @placements = []
end

Instance Attribute Details

#image_formatObject (readonly)

Returns the value of attribute image_format.



10
11
12
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 10

def image_format
  @image_format
end

#placementsObject (readonly)

Returns the value of attribute placements.



10
11
12
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 10

def placements
  @placements
end

#strike_ppemObject (readonly)

Returns the value of attribute strike_ppem.



10
11
12
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 10

def strike_ppem
  @strike_ppem
end

Instance Method Details

#add(placement) ⇒ Object



18
19
20
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 18

def add(placement)
  @placements << placement
end

#byte_lengthObject

Byte length of this IndexSubTable in the output CBLC: 8-byte header + (count + 1) × 4-byte offsets.



53
54
55
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 53

def byte_length
  8 + (@placements.size + 1) * 4
end

#first_new_gidObject



22
23
24
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 22

def first_new_gid
  @placements.first.new_gid
end

#first_new_offsetInteger

Absolute CBDT offset where this subtable's first glyph's bitmap begins. Assigned during CBDT emission.

Returns:

  • (Integer)


34
35
36
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 34

def first_new_offset
  @placements.first.new_offset
end

#last_new_gidObject



26
27
28
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 26

def last_new_gid
  @placements.last.new_gid
end

#offset_arrayArray<Integer>

IndexSubTable format 1 offset array (relative to imageDataOffset). offsets is 0 (first glyph starts at imageDataOffset); offsets = offsets + byte_length.

Returns:

  • (Array<Integer>)


43
44
45
46
47
48
49
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb', line 43

def offset_array
  arr = [0]
  @placements.each do |p|
    arr << (arr.last + p.byte_length)
  end
  arr
end