Class: Fontisan::Woff2::SfntChecksum
- Inherits:
-
Object
- Object
- Fontisan::Woff2::SfntChecksum
- Defined in:
- lib/fontisan/woff2/sfnt_checksum.rb
Overview
Computes head.checksumAdjustment for the SFNT the WOFF2 decoder
reconstructs at runtime.
Per OpenType spec ("Calculating Checksums"), checksumAdjustment must be set so the uint32-wise sum of the entire SFNT file (offset table + table directory + all tables) equals the magic 0xB1B0AFBA. Chrome's OTS validates this; a stale value from the source font causes rejection with "Failed to convert WOFF 2.0 font to SFNT" once any table has been modified (head.flags bit 11, glyf/loca transformation, etc.).
Delegates the per-table uint32 sum to Utilities::ChecksumCalculator — that is the single source of truth for the OpenType checksum algorithm. This class orchestrates the per-table layout: building the offset table + table directory bytes, zeroing head's checksumAdjustment field for its own checksum per spec, then subtracting the total from the magic.
Defined Under Namespace
Classes: Table
Instance Method Summary collapse
-
#adjustment ⇒ Integer
Compute the head.checksumAdjustment value (uint32).
-
#initialize(flavor:, tables:) ⇒ SfntChecksum
constructor
tag order.
Constructor Details
#initialize(flavor:, tables:) ⇒ SfntChecksum
tag order
30 31 32 33 |
# File 'lib/fontisan/woff2/sfnt_checksum.rb', line 30 def initialize(flavor:, tables:) @flavor = flavor @tables = tables end |
Instance Method Details
#adjustment ⇒ Integer
Compute the head.checksumAdjustment value (uint32).
38 39 40 |
# File 'lib/fontisan/woff2/sfnt_checksum.rb', line 38 def adjustment Utilities::ChecksumCalculator.calculate_adjustment(total_checksum) end |