Class: Fontisan::Tables::Cff::HintOperationInjector
- Inherits:
-
Object
- Object
- Fontisan::Tables::Cff::HintOperationInjector
- Defined in:
- lib/fontisan/tables/cff/hint_operation_injector.rb
Overview
Injects hint operations into CharString operation lists
HintOperationInjector converts abstract Hint objects into CFF CharString operations and injects them at the appropriate position. It handles:
-
Stem hints (hstem, vstem, hstemhm, vstemhm)
-
Hint masks (hintmask with mask data)
-
Counter masks (cntrmask with mask data)
-
Stack management (hints are stack-neutral)
**Position Rules:**
-
Hints must appear BEFORE any path construction operators
-
Width (if present) comes first
-
Stem hints come before hintmask/cntrmask
-
Once path construction begins, no more hints allowed
**Stack Neutrality:**
-
Hint operators consume their operands
-
They don’t leave anything on the stack
-
Path construction starts with clean stack
Reference: Type 2 CharString Format Section 4 Adobe Technical Note #5177
Instance Attribute Summary collapse
-
#stem_count ⇒ Integer
readonly
Get stem count after injection (needed for hintmask).
Instance Method Summary collapse
-
#initialize ⇒ HintOperationInjector
constructor
Initialize injector.
-
#inject(hints, operations) ⇒ Array<Hash>
Inject hint operations into operation list.
Constructor Details
#initialize ⇒ HintOperationInjector
Initialize injector
39 40 41 |
# File 'lib/fontisan/tables/cff/hint_operation_injector.rb', line 39 def initialize @stem_count = 0 end |
Instance Attribute Details
#stem_count ⇒ Integer (readonly)
Get stem count after injection (needed for hintmask)
65 66 67 |
# File 'lib/fontisan/tables/cff/hint_operation_injector.rb', line 65 def stem_count @stem_count end |
Instance Method Details
#inject(hints, operations) ⇒ Array<Hash>
Inject hint operations into operation list
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fontisan/tables/cff/hint_operation_injector.rb', line 48 def inject(hints, operations) return operations if hints.nil? || hints.empty? # Convert hints to operations hint_ops = convert_hints_to_operations(hints) return operations if hint_ops.empty? # Find injection point (before first path operator) inject_index = find_injection_point(operations) # Insert hint operations operations.dup.insert(inject_index, *hint_ops) end |