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.
Source Code
lib/ttfunk/table/cff/private_dict.rb, line 75
75 | def default_width_x |
76 | if (width = self[OPERATORS[:default_width_x]]) |
77 | width.first |
78 | else
|
79 | DEFAULT_WIDTH_X_DEFAULT
|
80 | end
|
81 | end
|
#encode ⇒ TTFunk::EncodedString
Encode dict.
Source Code
lib/ttfunk/table/cff/private_dict.rb, line 30
30 | def encode |
31 | # TODO: use mapping to determine which subroutines are still used.
|
32 | # For now, just encode them all.
|
33 | EncodedString.new do |result| |
34 | each do |operator, operands| |
35 | case OPERATOR_CODES[operator] |
36 | when :subrs |
37 | result << encode_subrs |
38 | else
|
39 | operands.each { |operand| result << encode_operand(operand) } |
40 | end
|
41 | |
42 | result << encode_operator(operator) |
43 | end
|
44 | end
|
45 | end
|
#finalize(private_dict_data) ⇒ void
This method returns an undefined value.
Finalize dict.
Source Code
lib/ttfunk/table/cff/private_dict.rb, line 51
51 | def finalize(private_dict_data) |
52 | return unless subr_index |
53 | |
54 | encoded_subr_index = subr_index.encode |
55 | encoded_offset = encode_integer32(private_dict_data.length) |
56 | |
57 | private_dict_data.resolve_placeholder(:"subrs_#{@table_offset}", encoded_offset) |
58 | |
59 | private_dict_data << encoded_subr_index |
60 | end
|
#nominal_width_x ⇒ Integer
Nominal Width X.
Source Code
lib/ttfunk/table/cff/private_dict.rb, line 86
86 | def nominal_width_x |
87 | if (width = self[OPERATORS[:nominal_width_x]]) |
88 | width.first |
89 | else
|
90 | DEFAULT_WIDTH_X_NOMINAL
|
91 | end
|
92 | end
|
#subr_index ⇒ TTFunk::Table::Cff::SubrIndex?
Subroutine index.
Source Code
lib/ttfunk/table/cff/private_dict.rb, line 65
65 | def subr_index |
66 | @subr_index ||= |
67 | if (subr_offset = self[OPERATORS[:subrs]]) |
68 | SubrIndex.new(file, table_offset + subr_offset.first) |
69 | end
|
70 | end
|