class TTFunk::Table::Cff::FontDict
CFF Font dict.
Constants
- OPERATORS
Operators we care about in this dict.
- OPERATOR_CODES
Inverse operator mapping.
- PLACEHOLDER_LENGTH
Length of placeholders.
Attributes
top_dict[R]
Top dict. @return [TTFunk::Table::Cff::TopDict]
Public Class Methods
new(top_dict, file, offset, length = nil)
click to toggle source
@param top_dict
[TTFunk::Table:Cff::TopDict] @param file [TTFunk::File] @param offset [Integer] @param length [Integer]
Calls superclass method
TTFunk::SubTable::new
# File lib/ttfunk/table/cff/font_dict.rb, line 25 def initialize(top_dict, file, offset, length = nil) @top_dict = top_dict super(file, offset, length) end
Public Instance Methods
encode()
click to toggle source
Encode dict.
@return [TTFunk::EncodedString]
# File lib/ttfunk/table/cff/font_dict.rb, line 33 def encode EncodedString.new do |result| each do |operator, operands| case OPERATOR_CODES[operator] when :private result << encode_private else operands.each { |operand| result << encode_operand(operand) } end result << encode_operator(operator) end end end
finalize(new_cff_data)
click to toggle source
Finalize dict.
@param new_cff_data [TTFunk::EncodedString] @return [void]
# File lib/ttfunk/table/cff/font_dict.rb, line 52 def finalize(new_cff_data) encoded_private_dict = private_dict.encode encoded_offset = encode_integer32(new_cff_data.length) encoded_length = encode_integer32(encoded_private_dict.length) new_cff_data.resolve_placeholder(:"private_length_#{@table_offset}", encoded_length) new_cff_data.resolve_placeholder(:"private_offset_#{@table_offset}", encoded_offset) private_dict.finalize(encoded_private_dict) new_cff_data << encoded_private_dict end
private_dict()
click to toggle source
Private dict.
@return [TTFunk::Table::Cff::PrivateDict, nil]
# File lib/ttfunk/table/cff/font_dict.rb, line 67 def private_dict @private_dict ||= if (info = self[OPERATORS[:private]]) private_dict_length, private_dict_offset = info PrivateDict.new( file, top_dict.cff_offset + private_dict_offset, private_dict_length, ) end end
Private Instance Methods
encode_private()
click to toggle source
# File lib/ttfunk/table/cff/font_dict.rb, line 82 def encode_private EncodedString.new do |result| result << Placeholder.new(:"private_length_#{@table_offset}", length: PLACEHOLDER_LENGTH) result << Placeholder.new(:"private_offset_#{@table_offset}", length: PLACEHOLDER_LENGTH) end end