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 that the WOFF2 decoder reconstructs at runtime.
Per OpenType spec, head.checksumAdjustment must be set so that 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.).
Reference: OpenType spec, "Calculating Checksums".
Defined Under Namespace
Classes: Table
Instance Method Summary collapse
-
#adjustment ⇒ Integer
Compute the head.checksumAdjustment value (uint32).
-
#initialize(flavor:, tables:) ⇒ SfntChecksum
constructor
A new instance of SfntChecksum.
Constructor Details
#initialize(flavor:, tables:) ⇒ SfntChecksum
Returns a new instance of SfntChecksum.
26 27 28 29 |
# File 'lib/fontisan/woff2/sfnt_checksum.rb', line 26 def initialize(flavor:, tables:) @flavor = flavor @tables = tables end |
Instance Method Details
#adjustment ⇒ Integer
Compute the head.checksumAdjustment value (uint32).
34 35 36 |
# File 'lib/fontisan/woff2/sfnt_checksum.rb', line 34 def adjustment (Constants::CHECKSUM_ADJUSTMENT_MAGIC - total_checksum) & 0xFFFFFFFF end |