class TTFunk::Table::Cff::PrivateDict
CFF Private dict.
Constants
- DEFAULT_WIDTH_X_DEFAULT
-
Default value of Default Width X.
- DEFAULT_WIDTH_X_NOMINAL
-
Default value of Nominal Width X.
- OPERATORS
-
Operators we care about in this dict.
- OPERATOR_CODES
-
Inverse operator mapping.
- PLACEHOLDER_LENGTH
-
Length of placeholders.
Public Instance Methods
Source
# 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
Default Width X.
@return [Integer]
Source
# 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
Encode dict.
@return [TTFunk::EncodedString]
Source
# 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
Finalize dict.
@param private_dict_data [TTFunk::EncodedString] @return [void]
Source
# 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
Nominal Width X.
@return [Integer]
Source
# 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
Subroutine index.
@return [TTFunk::Table::Cff::SubrIndex, nil]
Private Instance Methods
Source
# File lib/ttfunk/table/cff/private_dict.rb, line 96 def encode_subrs EncodedString.new do |result| result << Placeholder.new(:"subrs_#{@table_offset}", length: PLACEHOLDER_LENGTH) end end