Module: Fontisan::Ufo::Compile::Cff2Subrs
- Defined in:
- lib/fontisan/ufo/compile/cff2_subroutines.rb
Overview
CFF2 subroutine utilities — bias calculation and INDEX building.
Subroutines are shared charstring sequences referenced by index from the caller. CFF2 supports two kinds:
- GlobalSubr: shared across all CharStrings
- LocalSubr: per Font DICT, referenced via operator 19 (0x13)
The bias for callsubr/callgsubr index lookup is:
0-1240 → bias 107
1241-33800 → bias 1131
33801+ → bias 32768
Class Method Summary collapse
-
.bias(count) ⇒ Integer
Calculate the bias for subroutine index lookup.
-
.build_index(subrs) ⇒ String
Build a Subr INDEX (same structure for Global and Local).
Class Method Details
.bias(count) ⇒ Integer
Calculate the bias for subroutine index lookup.
23 24 25 26 27 28 |
# File 'lib/fontisan/ufo/compile/cff2_subroutines.rb', line 23 def self.bias(count) return 107 if count <= 1240 return 1131 if count <= 33800 32768 end |
.build_index(subrs) ⇒ String
Build a Subr INDEX (same structure for Global and Local).
33 34 35 |
# File 'lib/fontisan/ufo/compile/cff2_subroutines.rb', line 33 def self.build_index(subrs) Tables::Cff2::IndexBuilder.build(subrs.map(&:b)) end |