Class: Fontisan::Validation::Woff2HeaderValidator
- Inherits:
-
Object
- Object
- Fontisan::Validation::Woff2HeaderValidator
- Defined in:
- lib/fontisan/validation/woff2_header_validator.rb
Overview
Woff2HeaderValidator validates the WOFF2 header structure
This validator checks the WOFF2 header for:
-
Valid signature (0x774F4632 ‘wOF2’)
-
Valid flavor (TrueType or CFF)
-
Reserved field is zero
-
File length consistency
-
Valid table count
-
Valid compressed size
-
Metadata offset/length consistency
-
Private data offset/length consistency
Single Responsibility: WOFF2 header validation
Constant Summary collapse
- VALID_FLAVORS =
Valid WOFF2 flavors
[ 0x00010000, # TrueType 0x74727565, # 'true' (TrueType) 0x4F54544F, # 'OTTO' (CFF/OpenType) ].freeze
Instance Method Summary collapse
-
#initialize(rules) ⇒ Woff2HeaderValidator
constructor
Initialize WOFF2 header validator.
-
#validate(woff2_font) ⇒ Array<Hash>
Validate WOFF2 header.
Constructor Details
#initialize(rules) ⇒ Woff2HeaderValidator
Initialize WOFF2 header validator
33 34 35 36 |
# File 'lib/fontisan/validation/woff2_header_validator.rb', line 33 def initialize(rules) @rules = rules @woff2_config = rules["woff2_validation"] || {} end |
Instance Method Details
#validate(woff2_font) ⇒ Array<Hash>
Validate WOFF2 header
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fontisan/validation/woff2_header_validator.rb', line 42 def validate(woff2_font) issues = [] header = woff2_font.header return issues unless header # Check signature issues.concat(check_signature(header)) # Check flavor issues.concat(check_flavor(header)) # Check reserved field issues.concat(check_reserved_field(header)) # Check table count issues.concat(check_table_count(header, woff2_font)) # Check compressed size issues.concat(check_compressed_size(header)) # Check metadata consistency issues.concat((header)) # Check private data consistency issues.concat(check_private_data(header)) issues end |