Class: Fontisan::Optimizers::PatternAnalyzer::Pattern
- Inherits:
-
Struct
- Object
- Struct
- Fontisan::Optimizers::PatternAnalyzer::Pattern
- Defined in:
- lib/fontisan/optimizers/pattern_analyzer.rb
Overview
Pattern data structure representing a repeated CharString sequence
Instance Attribute Summary collapse
-
#bytes ⇒ Object
Returns the value of attribute bytes.
-
#frequency ⇒ Object
Returns the value of attribute frequency.
-
#glyphs ⇒ Object
Returns the value of attribute glyphs.
-
#length ⇒ Object
Returns the value of attribute length.
-
#positions ⇒ Object
Returns the value of attribute positions.
-
#savings ⇒ Object
Returns the value of attribute savings.
-
#stack_neutral ⇒ Object
Returns the value of attribute stack_neutral.
Instance Method Summary collapse
-
#call_overhead ⇒ Integer
Calculate overhead for calling this pattern as a subroutine.
-
#number_size(num) ⇒ Integer
Calculate CFF integer encoding size.
Instance Attribute Details
#bytes ⇒ Object
Returns the value of attribute bytes
27 28 29 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 27 def bytes @bytes end |
#frequency ⇒ Object
Returns the value of attribute frequency
27 28 29 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 27 def frequency @frequency end |
#glyphs ⇒ Object
Returns the value of attribute glyphs
27 28 29 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 27 def glyphs @glyphs end |
#length ⇒ Object
Returns the value of attribute length
27 28 29 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 27 def length @length end |
#positions ⇒ Object
Returns the value of attribute positions
27 28 29 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 27 def positions @positions end |
#savings ⇒ Object
Returns the value of attribute savings
27 28 29 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 27 def savings @savings end |
#stack_neutral ⇒ Object
Returns the value of attribute stack_neutral
27 28 29 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 27 def stack_neutral @stack_neutral end |
Instance Method Details
#call_overhead ⇒ Integer
Calculate overhead for calling this pattern as a subroutine
38 39 40 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 38 def call_overhead 1 + number_size(frequency) + 1 # callsubr + number + return end |
#number_size(num) ⇒ Integer
Calculate CFF integer encoding size
45 46 47 48 49 50 51 |
# File 'lib/fontisan/optimizers/pattern_analyzer.rb', line 45 def number_size(num) return 1 if num >= -107 && num <= 107 return 2 if num >= -1131 && num <= 1131 return 3 if num >= -32768 && num <= 32767 5 end |