Class: Fontisan::Woff2::Woff2Header
- Inherits:
-
BinData::Record
- Object
- BinData::Record
- Fontisan::Woff2::Woff2Header
- Defined in:
- lib/fontisan/woff2/header.rb
Overview
WOFF2 Header structure
Woff2::Header represents the main
header of a WOFF2 file according to W3C WOFF2 specification.
The header is more compact than WOFF, using 48 bytes.
Structure (all big-endian):
- uint32: signature (0x774F4632 'wOF2')
- uint32: flavor (0x00010000 for TTF, 0x4F54544F for CFF)
- uint32: file_length (total WOFF2 file size)
- uint16: numTables (number of font tables)
- uint16: reserved (must be 0)
- uint32: totalSfntSize (uncompressed font size)
- uint32: totalCompressedSize (size of compressed data block)
- uint16: majorVersion (major version of WOFF file)
- uint16: minorVersion (minor version of WOFF file)
- uint32: metaOffset (offset to metadata, 0 if none)
- uint32: metaLength (compressed metadata length)
- uint32: metaOrigLength (uncompressed metadata length)
- uint32: privOffset (offset to private data, 0 if none)
- uint32: privLength (length of private data)
Reference: https://www.w3.org/TR/WOFF2/#woff20Header
Constant Summary collapse
- SIGNATURE =
WOFF2 signature constant
0x774F4632
Class Method Summary collapse
-
.header_size ⇒ Integer
Get header size in bytes.
Instance Method Summary collapse
-
#cff? ⇒ Boolean
Check if font is CFF flavored.
-
#has_metadata? ⇒ Boolean
Check if metadata is present.
-
#has_private_data? ⇒ Boolean
Check if private data is present.
-
#truetype? ⇒ Boolean
Check if font is TrueType flavored.
-
#valid_signature? ⇒ Boolean
Check if signature is valid.
Class Method Details
.header_size ⇒ Integer
Get header size in bytes
96 97 98 |
# File 'lib/fontisan/woff2/header.rb', line 96 def self.header_size 48 end |
Instance Method Details
#cff? ⇒ Boolean
Check if font is CFF flavored
75 76 77 |
# File 'lib/fontisan/woff2/header.rb', line 75 def cff? flavor == 0x4F54544F # 'OTTO' end |
#has_metadata? ⇒ Boolean
Check if metadata is present
82 83 84 |
# File 'lib/fontisan/woff2/header.rb', line 82 def .positive? && .positive? end |
#has_private_data? ⇒ Boolean
Check if private data is present
89 90 91 |
# File 'lib/fontisan/woff2/header.rb', line 89 def has_private_data? priv_offset.positive? && priv_length.positive? end |
#truetype? ⇒ Boolean
Check if font is TrueType flavored
68 69 70 |
# File 'lib/fontisan/woff2/header.rb', line 68 def truetype? [0x00010000, 0x74727565].include?(flavor) # 'true' end |
#valid_signature? ⇒ Boolean
Check if signature is valid
61 62 63 |
# File 'lib/fontisan/woff2/header.rb', line 61 def valid_signature? signature == SIGNATURE end |