Class: Fontisan::Woff2::GlyfLocaTransform::Streams

Inherits:
Struct
  • Object
show all
Defined in:
lib/fontisan/woff2/glyf_loca_transform.rb

Overview

Mutable container for the 7 streams + 2 bitmaps. Avoids passing 9 parameters through every helper. Defined at top-level so the Struct class isn't hidden behind private (Ruby treats constants as public regardless, but RuboCop flags the modifier as useless).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(num_glyphs) ⇒ Streams

Returns a new instance of Streams.



101
102
103
104
105
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 101

def initialize(num_glyphs)
  super(*Array.new(7) { String.new(encoding: Encoding::BINARY) },
        Array.new(((num_glyphs + 31) >> 5) << 2, 0),
        Array.new((num_glyphs + 7) >> 3, 0))
end

Instance Attribute Details

#bbox_bitmapObject

Returns the value of attribute bbox_bitmap

Returns:

  • (Object)

    the current value of bbox_bitmap



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def bbox_bitmap
  @bbox_bitmap
end

#bbox_dataObject

Returns the value of attribute bbox_data

Returns:

  • (Object)

    the current value of bbox_data



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def bbox_data
  @bbox_data
end

#compositeObject

Returns the value of attribute composite

Returns:

  • (Object)

    the current value of composite



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def composite
  @composite
end

#flagsObject

Returns the value of attribute flags

Returns:

  • (Object)

    the current value of flags



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def flags
  @flags
end

#glyphObject

Returns the value of attribute glyph

Returns:

  • (Object)

    the current value of glyph



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def glyph
  @glyph
end

#instructionsObject

Returns the value of attribute instructions

Returns:

  • (Object)

    the current value of instructions



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def instructions
  @instructions
end

#n_contourObject

Returns the value of attribute n_contour

Returns:

  • (Object)

    the current value of n_contour



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def n_contour
  @n_contour
end

#n_pointsObject

Returns the value of attribute n_points

Returns:

  • (Object)

    the current value of n_points



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def n_points
  @n_points
end

#overlap_bitmapObject

Returns the value of attribute overlap_bitmap

Returns:

  • (Object)

    the current value of overlap_bitmap



98
99
100
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 98

def overlap_bitmap
  @overlap_bitmap
end

Instance Method Details

#bbox_wireObject

bboxStream on the wire = bboxBitmap || bboxStream (spec section 5.1).



112
113
114
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 112

def bbox_wire
  bbox_bitmap.pack("C*") + bbox_data
end

#has_overlap?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 107

def has_overlap?
  overlap_bitmap.any?(&:nonzero?)
end