Class: Fontisan::Woff2TableDirectoryEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/woff2_font.rb

Overview

WOFF2 Table Directory Entry structure

WOFF2 table directory entries are more complex than WOFF, with transformation flags and variable-length sizes.

Constant Summary collapse

TRANSFORM_NONE =

Transformation version flags

0
TRANSFORM_GLYF_LOCA =
0
TRANSFORM_LOCA =
1
TRANSFORM_HMTX =
2
KNOWN_TAGS =

Known table tags with assigned indices (0-62)

[
  "cmap", "head", "hhea", "hmtx", "maxp", "name", "OS/2", "post",
  "cvt ", "fpgm", "glyf", "loca", "prep", "CFF ", "VORG", "EBDT",
  "EBLC", "gasp", "hdmx", "kern", "LTSH", "PCLT", "VDMX", "vhea",
  "vmtx", "BASE", "GDEF", "GPOS", "GSUB", "EBSC", "JSTF", "MATH",
  "CBDT", "CBLC", "COLR", "CPAL", "SVG ", "sbix", "acnt", "avar",
  "bdat", "bloc", "bsln", "cvar", "fdsc", "feat", "fmtx", "fvar",
  "gvar", "hsty", "just", "lcar", "mort", "morx", "opbd", "prop",
  "trak", "Zapf", "Silf", "Glat", "Gloc", "Feat", "Sill"
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWoff2TableDirectoryEntry

Returns a new instance of Woff2TableDirectoryEntry.



57
58
59
60
# File 'lib/fontisan/woff2_font.rb', line 57

def initialize
  @flags = 0
  @transform_version = TRANSFORM_NONE
end

Instance Attribute Details

#flagsObject

Returns the value of attribute flags.



36
37
38
# File 'lib/fontisan/woff2_font.rb', line 36

def flags
  @flags
end

#offsetObject

Returns the value of attribute offset.



36
37
38
# File 'lib/fontisan/woff2_font.rb', line 36

def offset
  @offset
end

#orig_lengthObject

Returns the value of attribute orig_length.



36
37
38
# File 'lib/fontisan/woff2_font.rb', line 36

def orig_length
  @orig_length
end

#tagObject

Returns the value of attribute tag.



36
37
38
# File 'lib/fontisan/woff2_font.rb', line 36

def tag
  @tag
end

#transform_lengthObject

Returns the value of attribute transform_length.



36
37
38
# File 'lib/fontisan/woff2_font.rb', line 36

def transform_length
  @transform_length
end

#transform_versionObject

Get transform version for this table



68
69
70
# File 'lib/fontisan/woff2_font.rb', line 68

def transform_version
  @transform_version
end

Instance Method Details

#transformed?Boolean

Check if table is transformed

Returns:

  • (Boolean)


63
64
65
# File 'lib/fontisan/woff2_font.rb', line 63

def transformed?
  (@flags & 0x3F) != 0x3F && KNOWN_TAGS[tag_index]&.start_with?(/glyf|loca|hmtx/)
end