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.
Source Code
lib/ttfunk/table/cff/font_dict.rb, line 25
25 | def initialize(top_dict, file, offset, length = nil) |
26 | @top_dict = top_dict |
27 | super(file, offset, length) |
28 | end
|
Instance Attribute Details
#top_dict ⇒ TTFunk::Table::Cff::TopDict (readonly)
Top dict.
Source Code
lib/ttfunk/table/cff/font_dict.rb, line 19
19 | def top_dict |
20 | @top_dict
|
21 | end
|
Instance Method Details
#encode ⇒ TTFunk::EncodedString
Encode dict.
Source Code
lib/ttfunk/table/cff/font_dict.rb, line 33
33 | def encode |
34 | EncodedString.new do |result| |
35 | each do |operator, operands| |
36 | case OPERATOR_CODES[operator] |
37 | when :private |
38 | result << encode_private |
39 | else
|
40 | operands.each { |operand| result << encode_operand(operand) } |
41 | end
|
42 | |
43 | result << encode_operator(operator) |
44 | end
|
45 | end
|
46 | end
|
#finalize(new_cff_data) ⇒ void
This method returns an undefined value.
Finalize dict.
Source Code
lib/ttfunk/table/cff/font_dict.rb, line 52
52 | def finalize(new_cff_data) |
53 | encoded_private_dict = private_dict.encode |
54 | encoded_offset = encode_integer32(new_cff_data.length) |
55 | encoded_length = encode_integer32(encoded_private_dict.length) |
56 | |
57 | new_cff_data.resolve_placeholder(:"private_length_#{@table_offset}", encoded_length) |
58 | new_cff_data.resolve_placeholder(:"private_offset_#{@table_offset}", encoded_offset) |
59 | |
60 | private_dict.finalize(encoded_private_dict) |
61 | new_cff_data << encoded_private_dict |
62 | end
|
#private_dict ⇒ TTFunk::Table::Cff::PrivateDict?
Private dict.
Source Code
lib/ttfunk/table/cff/font_dict.rb, line 67
67 | def private_dict |
68 | @private_dict ||= |
69 | if (info = self[OPERATORS[:private]]) |
70 | private_dict_length, private_dict_offset = info |
71 | |
72 | PrivateDict.new( |
73 | file, |
74 | top_dict.cff_offset + private_dict_offset, |
75 | private_dict_length, |
76 | )
|
77 | end
|
78 | end
|