Class: Fontisan::Audit::Checks::Woff2ValidationCheck

Inherits:
Fontisan::Audit::Check show all
Defined in:
lib/fontisan/audit/checks/woff2_validation_check.rb

Overview

Validates WOFF2 (Web Open Font Format 2) wrapper structure per the W3C WOFF2 spec. Only runs when the font IS a Woff2Font — plain TTF/OTF inputs are skipped.

Checks:

- Signature must be 0x774F4632 ('wOF2')
- Flavor must be a valid SFNT version
- reserved field must be 0
- major_version should be 1
- total_compressed_size must be positive
- If metadata block is present, lengths must be consistent
- num_tables must match the table directory count

Constant Summary collapse

WOFF2_SIGNATURE =
0x774F4632
VALID_FLAVORS =
[
  0x00010000, # TrueType
  0x74727565, # 'true' (Apple TrueType)
  0x4F54544F, # 'OTTO' (OpenType CFF)
  0x74746366, # 'ttcf' (collection)
].freeze

Class Method Summary collapse

Methods inherited from Fontisan::Audit::Check

issue

Class Method Details

.call(font) ⇒ Array<Models::ValidationReport::Issue>

Parameters:

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fontisan/audit/checks/woff2_validation_check.rb', line 32

def self.call(font)
  return [] unless woff2?(font)

  header = font.header
  issues = []
  issues.concat(validate_signature(header))
  issues.concat(validate_flavor(header))
  issues.concat(validate_reserved(header))
  issues.concat(validate_version(header))
  issues.concat(validate_sizes(header))
  issues.concat((header))
  issues
end

.codeObject



46
47
48
# File 'lib/fontisan/audit/checks/woff2_validation_check.rb', line 46

def self.code
  :woff2_validation
end