Class: TTFunk::Table::Cff::Dict
- Includes:
- Enumerable
- Defined in:
- lib/ttfunk/table/cff/dict.rb
Overview
CFF Dict.
Direct Known Subclasses
Defined Under Namespace
Classes: InvalidOperandError, TooManyOperandsError
Constant Summary collapse
- OPERATOR_BZERO =
Single-byte operators.
(0..21).freeze
- OPERAND_BZERO =
Bytes indicating an operand.
[28..30, 32..254].freeze
- WIDE_OPERATOR_BZERO =
Two-byte operator
12
- WIDE_OPERATOR_ADJUSTMENT =
Two-byte operator adjustment. Used for encoding and decoding of wide operators.
1200
- MAX_OPERANDS =
Maximum number of operands allowed per operator.
48
- VALID_SCI_SIGNIFICAND_RE =
Scientific notation operand significand validation regular experession.
/\A-?(\.\d+|\d+|\d+\.\d+)\z/.freeze
- VALID_SCI_EXPONENT_RE =
Scientific notation operand exponent validation regular experession.
/\A-?\d+\z/.freeze
Instance Attribute Summary
Attributes inherited from SubTable
Instance Method Summary collapse
-
#[](operator) ⇒ Array<Integer, TTFunk::SciForm>
Get dict value by operator.
-
#[]=(operator, *operands) ⇒ Object
Add dict entry.
-
#each {|key, value| ... } ⇒ void
(also: #each_pair)
Iterate over dict entries.
-
#encode ⇒ String
Encode dict.
Methods inherited from SubTable
Constructor Details
This class inherits a constructor from TTFunk::SubTable
Instance Method Details
#[](operator) ⇒ Array<Integer, TTFunk::SciForm>
Get dict value by operator.
43 44 45 |
# File 'lib/ttfunk/table/cff/dict.rb', line 43 def [](operator) @dict[operator] end |
#[]=(operator, *operands) ⇒ Object
Add dict entry.
51 52 53 |
# File 'lib/ttfunk/table/cff/dict.rb', line 51 def []=(operator, *operands) @dict[operator] = Array(*operands) end |
#each {|key, value| ... } ⇒ void Also known as: each_pair
This method returns an undefined value.
Iterate over dict entries.
60 61 62 |
# File 'lib/ttfunk/table/cff/dict.rb', line 60 def each(&block) @dict.each(&block) end |
#encode ⇒ String
Encode dict.
69 70 71 72 73 74 75 76 |
# File 'lib/ttfunk/table/cff/dict.rb', line 69 def encode sort_by(&:first) .map { |(operator, operands)| operands.map { |operand| encode_operand(operand) }.join + encode_operator(operator) } .join end |