Class: TTFunk::Table::Cff::PrivateDict
- Defined in:
- lib/ttfunk/table/cff/private_dict.rb
Overview
CFF Private dict.
Constant Summary collapse
- DEFAULT_WIDTH_X_DEFAULT =
Default value of Default Width X.
0
- DEFAULT_WIDTH_X_NOMINAL =
Default value of Nominal Width X.
0
- PLACEHOLDER_LENGTH =
Length of placeholders.
5
- OPERATORS =
Operators we care about in this dict.
{ subrs: 19, default_width_x: 20, nominal_width_x: 21, }.freeze
- OPERATOR_CODES =
Inverse operator mapping.
OPERATORS.invert
Constants inherited from Dict
Dict::MAX_OPERANDS, Dict::OPERAND_BZERO, Dict::OPERATOR_BZERO, Dict::VALID_SCI_EXPONENT_RE, Dict::VALID_SCI_SIGNIFICAND_RE, Dict::WIDE_OPERATOR_ADJUSTMENT, Dict::WIDE_OPERATOR_BZERO
Instance Attribute Summary
Attributes inherited from SubTable
Instance Method Summary collapse
-
#default_width_x ⇒ Integer
Default Width X.
-
#encode ⇒ TTFunk::EncodedString
Encode dict.
-
#finalize(private_dict_data) ⇒ void
Finalize dict.
-
#nominal_width_x ⇒ Integer
Nominal Width X.
-
#subr_index ⇒ TTFunk::Table::Cff::SubrIndex?
Subroutine index.
Methods inherited from Dict
Methods inherited from SubTable
Constructor Details
This class inherits a constructor from TTFunk::SubTable
Instance Method Details
#default_width_x ⇒ Integer
Default Width X.
75 76 77 78 79 80 81 |
# File 'lib/ttfunk/table/cff/private_dict.rb', line 75 def default_width_x if (width = self[OPERATORS[:default_width_x]]) width.first else DEFAULT_WIDTH_X_DEFAULT end end |
#encode ⇒ TTFunk::EncodedString
Encode dict.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ttfunk/table/cff/private_dict.rb', line 30 def encode # TODO: use mapping to determine which subroutines are still used. # For now, just encode them all. EncodedString.new do |result| each do |operator, operands| case OPERATOR_CODES[operator] when :subrs result << encode_subrs else operands.each { |operand| result << encode_operand(operand) } end result << encode_operator(operator) end end end |
#finalize(private_dict_data) ⇒ void
This method returns an undefined value.
Finalize dict.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ttfunk/table/cff/private_dict.rb', line 51 def finalize(private_dict_data) return unless subr_index encoded_subr_index = subr_index.encode encoded_offset = encode_integer32(private_dict_data.length) private_dict_data.resolve_placeholder(:"subrs_#{@table_offset}", encoded_offset) private_dict_data << encoded_subr_index end |
#nominal_width_x ⇒ Integer
Nominal Width X.
86 87 88 89 90 91 92 |
# File 'lib/ttfunk/table/cff/private_dict.rb', line 86 def nominal_width_x if (width = self[OPERATORS[:nominal_width_x]]) width.first else DEFAULT_WIDTH_X_NOMINAL end end |
#subr_index ⇒ TTFunk::Table::Cff::SubrIndex?
Subroutine index.
65 66 67 68 69 70 |
# File 'lib/ttfunk/table/cff/private_dict.rb', line 65 def subr_index @subr_index ||= if (subr_offset = self[OPERATORS[:subrs]]) SubrIndex.new(file, table_offset + subr_offset.first) end end |