Class: TTFunk::Table::Cff::FontDict
- Defined in:
- lib/ttfunk/table/cff/font_dict.rb
Overview
CFF Font dict.
Constant Summary collapse
- PLACEHOLDER_LENGTH =
Length of placeholders.
5
- OPERATORS =
Operators we care about in this dict.
{ private: 18 }.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 collapse
-
#top_dict ⇒ TTFunk::Table::Cff::TopDict
readonly
Top dict.
Attributes inherited from SubTable
Instance Method Summary collapse
-
#encode ⇒ TTFunk::EncodedString
Encode dict.
-
#finalize(new_cff_data) ⇒ void
Finalize dict.
-
#initialize(top_dict, file, offset, length = nil) ⇒ FontDict
constructor
A new instance of FontDict.
-
#private_dict ⇒ TTFunk::Table::Cff::PrivateDict?
Private dict.
Methods inherited from Dict
Methods inherited from SubTable
Constructor Details
#initialize(top_dict, file, offset, length = nil) ⇒ FontDict
Returns a new instance of FontDict.
25 26 27 28 |
# 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 |
Instance Attribute Details
#top_dict ⇒ TTFunk::Table::Cff::TopDict (readonly)
Top dict.
19 20 21 |
# File 'lib/ttfunk/table/cff/font_dict.rb', line 19 def top_dict @top_dict end |
Instance Method Details
#encode ⇒ TTFunk::EncodedString
Encode dict.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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) ⇒ void
This method returns an undefined value.
Finalize dict.
52 53 54 55 56 57 58 59 60 61 62 |
# 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 ⇒ TTFunk::Table::Cff::PrivateDict?
Private dict.
67 68 69 70 71 72 73 74 75 76 77 78 |
# 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 |