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.
Source Code
lib/ttfunk/table/cff/dict.rb, line 43
43 | def [](operator) |
44 | @dict[operator] |
45 | end
|
#[]=(operator, *operands) ⇒ Object
Add dict entry.
Source Code
lib/ttfunk/table/cff/dict.rb, line 51
51 | def []=(operator, *operands) |
52 | @dict[operator] = Array(*operands) |
53 | end
|
#each {|key, value| ... } ⇒ void Also known as: each_pair
This method returns an undefined value.
Iterate over dict entries.
Source Code
lib/ttfunk/table/cff/dict.rb, line 60
60 | def each(&block) |
61 | @dict.each(&block) |
62 | end
|
#encode ⇒ String
Encode dict.
Source Code
lib/ttfunk/table/cff/dict.rb, line 69
69 | def encode |
70 | sort_by(&:first) |
71 | .map { |(operator, operands)| |
72 | operands.map { |operand| encode_operand(operand) }.join + |
73 | encode_operator(operator) |
74 | }
|
75 | .join |
76 | end
|