Class: Fontisan::Subset::SharedState

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

Overview

Per-subsetting shared state.

Several subset strategies depend on values computed by earlier strategies during the same subsetting run:

- `subset_max_advance` is computed by the Hmtx strategy and read
by Hhea (because hhea is processed alphabetically before hmtx).
- `glyf_data`, `loca_offsets`, and `subset_bbox` are computed by
the Glyf strategy and consumed by Loca and Head.

Rather than giving each TableStrategy access to the entire TableSubsetter (which would couple them to internals), the cross-strategy state lives here. Each strategy receives a Context exposing [font], [mapping], [options], and this [SharedState].

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSharedState

Returns a new instance of SharedState.



37
38
39
# File 'lib/fontisan/subset/shared_state.rb', line 37

def initialize
  @subset_max_advance = 0
end

Instance Attribute Details

#color_bitmap_subsetterTableStrategy::ColorBitmapSubsetter?

Returns cached paired CBDT+CBLC subsetter so both strategies reuse the same pass.

Returns:



35
36
37
# File 'lib/fontisan/subset/shared_state.rb', line 35

def color_bitmap_subsetter
  @color_bitmap_subsetter
end

#glyf_dataString?

Returns binary glyf data built by the Glyf strategy.

Returns:

  • (String, nil)

    binary glyf data built by the Glyf strategy



21
22
23
# File 'lib/fontisan/subset/shared_state.rb', line 21

def glyf_data
  @glyf_data
end

#loca_offsetsArray<Integer>?

Returns loca offsets produced by the Glyf strategy.

Returns:

  • (Array<Integer>, nil)

    loca offsets produced by the Glyf strategy



24
25
26
# File 'lib/fontisan/subset/shared_state.rb', line 24

def loca_offsets
  @loca_offsets
end

#subset_bboxArray(Integer, Integer, Integer, Integer)?

Returns union xMin/yMin/xMax/yMax over the subset's glyphs.

Returns:

  • (Array(Integer, Integer, Integer, Integer), nil)

    union xMin/yMin/xMax/yMax over the subset's glyphs



28
29
30
# File 'lib/fontisan/subset/shared_state.rb', line 28

def subset_bbox
  @subset_bbox
end

#subset_max_advanceInteger

Returns largest advanceWidth seen while subsetting hmtx.

Returns:

  • (Integer)

    largest advanceWidth seen while subsetting hmtx



31
32
33
# File 'lib/fontisan/subset/shared_state.rb', line 31

def subset_max_advance
  @subset_max_advance
end