Class: Fontisan::Subset::TableStrategy::ColorBitmapSubsetPlan

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

Overview

Plan for the subset of color bitmaps: which source strikes have any surviving glyph, and the per-strike runs of surviving new GIDs. Built once by [ColorBitmapSubsetter] from a CBLC + a GlyphMapping, then used to drive both CBDT and CBLC emission.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mapping) ⇒ ColorBitmapSubsetPlan

Returns a new instance of ColorBitmapSubsetPlan.



13
14
15
16
17
18
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subset_plan.rb', line 13

def initialize(mapping)
  @mapping = mapping
  @strikes = []
  @strike_plans = []
  @placements = []
end

Instance Attribute Details

#placementsObject (readonly)

Returns the value of attribute placements.



11
12
13
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subset_plan.rb', line 11

def placements
  @placements
end

#strike_plansObject (readonly)

Returns the value of attribute strike_plans.



11
12
13
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subset_plan.rb', line 11

def strike_plans
  @strike_plans
end

#strikesObject (readonly)

Returns the value of attribute strikes.



11
12
13
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subset_plan.rb', line 11

def strikes
  @strikes
end

Instance Method Details

#collect!(cblc) ⇒ Object

Walk every (gid, strike) location in CBLC and capture the ones whose source gid is in the subset. Remaps the gid via the supplied mapping.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subset_plan.rb', line 23

def collect!(cblc)
  cblc.bitmap_sizes.each do |strike|
    strike_plan = ColorBitmapStrikePlan.new(strike)

    cblc.sub_tables_for(strike).each do |sub|
      sub.locations.each do |loc|
        new_gid = @mapping.new_id(loc.glyph_id)
        next unless new_gid

        placement = ColorBitmapPlacement.new(
          source_gid: loc.glyph_id,
          new_gid: new_gid,
          source_offset: loc.cbdt_offset,
          byte_length: loc.byte_length,
          image_format: loc.image_format,
          strike_ppem: strike.ppem,
        )
        @placements << placement
        strike_plan.add(placement)
      end
    end

    next if strike_plan.empty?

    @strikes << strike
    @strike_plans << strike_plan
  end
end

#each_placementObject



52
53
54
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subset_plan.rb', line 52

def each_placement(&)
  @placements.each(&)
end

#each_strike_planObject



56
57
58
# File 'lib/fontisan/subset/table_strategy/color_bitmap_subset_plan.rb', line 56

def each_strike_plan(&)
  @strike_plans.each(&)
end