Class: Fontisan::Tables::Cff::PrivateDictWriter
- Inherits:
-
Object
- Object
- Fontisan::Tables::Cff::PrivateDictWriter
- Defined in:
- lib/fontisan/tables/cff/private_dict_writer.rb
Overview
Builds CFF Private DICT with hint parameters
Private DICT contains font-level hint information used for rendering quality. This writer validates hint parameters against CFF spec limits and serializes them into binary DICT format.
Supported hint parameters:
-
blue_values: Alignment zones (max 14 values, pairs)
-
other_blues: Additional zones (max 10 values, pairs)
-
family_blues: Family alignment zones (max 14 values, pairs)
-
family_other_blues: Family zones (max 10 values, pairs)
-
std_hw: Standard horizontal stem width
-
std_vw: Standard vertical stem width
-
stem_snap_h: Horizontal stem snap widths (max 12)
-
stem_snap_v: Vertical stem snap widths (max 12)
-
blue_scale, blue_shift, blue_fuzz: Overshoot parameters
-
force_bold: Bold flag
-
language_group: 0=Latin, 1=CJK
Constant Summary collapse
- HINT_LIMITS =
CFF specification limits for hint parameters
{ blue_values: { max: 14, pairs: true }, other_blues: { max: 10, pairs: true }, family_blues: { max: 14, pairs: true }, family_other_blues: { max: 10, pairs: true }, stem_snap_h: { max: 12 }, stem_snap_v: { max: 12 }, }.freeze
Instance Method Summary collapse
-
#initialize(source_dict = nil) ⇒ PrivateDictWriter
constructor
Initialize writer with optional source Private DICT.
-
#serialize ⇒ String
Serialize to binary DICT format.
-
#size ⇒ Integer
Get serialized size in bytes.
-
#update_hints(hint_params) ⇒ Object
Update hint parameters.
Constructor Details
#initialize(source_dict = nil) ⇒ PrivateDictWriter
Initialize writer with optional source Private DICT
40 41 42 43 |
# File 'lib/fontisan/tables/cff/private_dict_writer.rb', line 40 def initialize(source_dict = nil) @params = {} parse_source(source_dict) if source_dict end |
Instance Method Details
#serialize ⇒ String
Serialize to binary DICT format
57 58 59 |
# File 'lib/fontisan/tables/cff/private_dict_writer.rb', line 57 def serialize DictBuilder.build(@params) end |
#size ⇒ Integer
Get serialized size in bytes
64 65 66 |
# File 'lib/fontisan/tables/cff/private_dict_writer.rb', line 64 def size serialize.bytesize end |
#update_hints(hint_params) ⇒ Object
Update hint parameters
49 50 51 52 |
# File 'lib/fontisan/tables/cff/private_dict_writer.rb', line 49 def update_hints(hint_params) validate!(hint_params) @params.merge!(hint_params.transform_keys(&:to_sym)) end |