Class: Fontisan::Tables::Cff::PrivateDict
- Defined in:
- lib/fontisan/tables/cff/private_dict.rb
Overview
CFF Private DICT structure
The Private DICT contains glyph-specific hinting and width data. Each font has its own Private DICT (or multiple for CIDFonts).
Private DICT Operators:
- blue_values: Alignment zones for overshoot suppression
- other_blues: Additional alignment zones
- family_blues: Family-wide alignment zones
- family_other_blues: Family-wide additional alignment zones
- blue_scale: Point size for overshoot suppression
- blue_shift: Pixels to shift alignment zones
- blue_fuzz: Tolerance for alignment zones
- std_hw: Standard horizontal stem width
- std_vw: Standard vertical stem width
- stem_snap_h: Horizontal stem snap widths
- stem_snap_v: Vertical stem snap widths
- force_bold: Force bold flag
- language_group: Language group (0=Latin, 1=CJK)
- expansion_factor: Expansion factor for counters
- initial_random_seed: Random seed for Type 1 hinting
- subrs: Offset to Local Subr INDEX (relative to Private DICT)
- default_width_x: Default glyph width
- nominal_width_x: Nominal glyph width
Reference: CFF specification section 10 "Private DICT" https://adobe-type-tools.github.io/font-tech-notes/pdfs/5176.CFF.pdf
Constant Summary collapse
- PRIVATE_DICT_OPERATORS =
Private DICT specific operators
These extend the common operators defined in the base Dict class
{ 6 => :blue_values, 7 => :other_blues, 8 => :family_blues, 9 => :family_other_blues, [12, 9] => :blue_scale, [12, 10] => :blue_shift, [12, 11] => :blue_fuzz, 10 => :std_hw, 11 => :std_vw, [12, 12] => :stem_snap_h, [12, 13] => :stem_snap_v, [12, 14] => :force_bold, [12, 17] => :language_group, [12, 18] => :expansion_factor, [12, 19] => :initial_random_seed, 19 => :subrs, 20 => :default_width_x, 21 => :nominal_width_x, }.freeze
- DEFAULTS =
Default values for Private DICT operators
These are used when an operator is not present in the DICT
{ blue_scale: 0.039625, blue_shift: 7, blue_fuzz: 1, force_bold: false, language_group: 0, expansion_factor: 0.06, initial_random_seed: 0, default_width_x: 0, nominal_width_x: 0, }.freeze
Constants inherited from Dict
Instance Attribute Summary
Attributes inherited from Dict
Instance Method Summary collapse
-
#blue_fuzz ⇒ Integer
Get the blue fuzz.
-
#blue_scale ⇒ Float
Get the blue scale.
-
#blue_shift ⇒ Integer
Get the blue shift.
-
#blue_values ⇒ Array<Integer>?
Get the blue values (alignment zones).
-
#cjk? ⇒ Boolean
Check if this is for CJK language group.
-
#default_width_x ⇒ Integer
Get the default glyph width.
-
#expansion_factor ⇒ Float
Get the expansion factor.
-
#family_blues ⇒ Array<Integer>?
Get the family blue values.
-
#family_other_blues ⇒ Array<Integer>?
Get the family other blue values.
-
#fetch(key, default = nil) ⇒ Object
Get a value with default fallback.
-
#force_bold? ⇒ Boolean
Check if force bold is enabled.
-
#has_blue_values? ⇒ Boolean
Check if this Private DICT has blue values defined.
-
#has_local_subrs? ⇒ Boolean
Check if this Private DICT has local subroutines.
-
#initial_random_seed ⇒ Integer
Get the initial random seed.
-
#language_group ⇒ Integer
Get the language group.
-
#nominal_width_x ⇒ Integer
Get the nominal glyph width.
-
#other_blues ⇒ Array<Integer>?
Get the other blue values.
-
#std_hw ⇒ Integer?
Get the standard horizontal width.
-
#std_vw ⇒ Integer?
Get the standard vertical width.
-
#stem_snap_h ⇒ Array<Integer>?
Get the horizontal stem snap widths.
-
#stem_snap_v ⇒ Array<Integer>?
Get the vertical stem snap widths.
-
#subrs ⇒ Integer?
Get the Local Subr INDEX offset.
Methods inherited from Dict
#[], #[]=, #empty?, #has_key?, #initialize, #keys, #size, #to_h, #values
Constructor Details
This class inherits a constructor from Fontisan::Tables::Cff::Dict
Instance Method Details
#blue_fuzz ⇒ Integer
Get the blue fuzz
Tolerance for alignment zone matching
145 146 147 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 145 def blue_fuzz fetch(:blue_fuzz) end |
#blue_scale ⇒ Float
Get the blue scale
Point size at which overshoot suppression is maximum
127 128 129 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 127 def blue_scale fetch(:blue_scale) end |
#blue_shift ⇒ Integer
Get the blue shift
Number of device pixels to shift alignment zones
136 137 138 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 136 def blue_shift fetch(:blue_shift) end |
#blue_values ⇒ Array<Integer>?
Get the blue values (alignment zones)
Blue values define vertical zones for overshoot suppression
93 94 95 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 93 def blue_values @dict[:blue_values] end |
#cjk? ⇒ Boolean
Check if this is for CJK language group
267 268 269 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 267 def cjk? language_group == 1 end |
#default_width_x ⇒ Integer
Get the default glyph width
Used when width is not explicitly specified in CharString
237 238 239 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 237 def default_width_x fetch(:default_width_x) end |
#expansion_factor ⇒ Float
Get the expansion factor
Controls horizontal counter expansion
210 211 212 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 210 def expansion_factor fetch(:expansion_factor) end |
#family_blues ⇒ Array<Integer>?
Get the family blue values
Family-wide alignment zones shared across fonts in a family
111 112 113 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 111 def family_blues @dict[:family_blues] end |
#family_other_blues ⇒ Array<Integer>?
Get the family other blue values
118 119 120 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 118 def family_other_blues @dict[:family_other_blues] end |
#fetch(key, default = nil) ⇒ Object
Get a value with default fallback
84 85 86 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 84 def fetch(key, default = nil) @dict.fetch(key, DEFAULTS.fetch(key, default)) end |
#force_bold? ⇒ Boolean
Check if force bold is enabled
192 193 194 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 192 def force_bold? fetch(:force_bold) end |
#has_blue_values? ⇒ Boolean
Check if this Private DICT has blue values defined
260 261 262 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 260 def has_blue_values? !blue_values.nil? && !blue_values.empty? end |
#has_local_subrs? ⇒ Boolean
Check if this Private DICT has local subroutines
253 254 255 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 253 def has_local_subrs? !subrs.nil? end |
#initial_random_seed ⇒ Integer
Get the initial random seed
Seed for pseudo-random number generation in Type 1 hinting
219 220 221 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 219 def initial_random_seed fetch(:initial_random_seed) end |
#language_group ⇒ Integer
Get the language group
0 = Latin/Greek/Cyrillic, 1 = CJK
201 202 203 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 201 def language_group fetch(:language_group) end |
#nominal_width_x ⇒ Integer
Get the nominal glyph width
Base value for width calculations in CharStrings
246 247 248 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 246 def nominal_width_x fetch(:nominal_width_x) end |
#other_blues ⇒ Array<Integer>?
Get the other blue values
Additional alignment zones beyond the baseline and cap height
102 103 104 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 102 def other_blues @dict[:other_blues] end |
#std_hw ⇒ Integer?
Get the standard horizontal width
Dominant horizontal stem width
154 155 156 157 158 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 154 def std_hw value = @dict[:std_hw] # std_hw is stored as an array with one element value.is_a?(Array) ? value.first : value end |
#std_vw ⇒ Integer?
Get the standard vertical width
Dominant vertical stem width
165 166 167 168 169 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 165 def std_vw value = @dict[:std_vw] # std_vw is stored as an array with one element value.is_a?(Array) ? value.first : value end |
#stem_snap_h ⇒ Array<Integer>?
Get the horizontal stem snap widths
Array of horizontal stem widths for stem snapping
176 177 178 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 176 def stem_snap_h @dict[:stem_snap_h] end |
#stem_snap_v ⇒ Array<Integer>?
Get the vertical stem snap widths
Array of vertical stem widths for stem snapping
185 186 187 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 185 def stem_snap_v @dict[:stem_snap_v] end |
#subrs ⇒ Integer?
Get the Local Subr INDEX offset
Offset is relative to the beginning of the Private DICT
228 229 230 |
# File 'lib/fontisan/tables/cff/private_dict.rb', line 228 def subrs @dict[:subrs] end |