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.



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

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



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def bbox_bitmap
  @bbox_bitmap
end

#bbox_dataObject

Returns the value of attribute bbox_data

Returns:

  • (Object)

    the current value of bbox_data



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def bbox_data
  @bbox_data
end

#compositeObject

Returns the value of attribute composite

Returns:

  • (Object)

    the current value of composite



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def composite
  @composite
end

#flagsObject

Returns the value of attribute flags

Returns:

  • (Object)

    the current value of flags



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def flags
  @flags
end

#glyphObject

Returns the value of attribute glyph

Returns:

  • (Object)

    the current value of glyph



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def glyph
  @glyph
end

#instructionsObject

Returns the value of attribute instructions

Returns:

  • (Object)

    the current value of instructions



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def instructions
  @instructions
end

#n_contourObject

Returns the value of attribute n_contour

Returns:

  • (Object)

    the current value of n_contour



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def n_contour
  @n_contour
end

#n_pointsObject

Returns the value of attribute n_points

Returns:

  • (Object)

    the current value of n_points



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def n_points
  @n_points
end

#overlap_bitmapObject

Returns the value of attribute overlap_bitmap

Returns:

  • (Object)

    the current value of overlap_bitmap



94
95
96
# File 'lib/fontisan/woff2/glyf_loca_transform.rb', line 94

def overlap_bitmap
  @overlap_bitmap
end

Instance Method Details

#bbox_wireObject

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



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

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

#has_overlap?Boolean

Returns:

  • (Boolean)


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

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