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.



43
44
45
46
47
# File 'lib/fontisan/woff2_font.rb', line 43

def initialize
  @flags = 0
  # Don't initialize transform_version - leave it nil
  # It will be set during parsing if table is transformed
end

Instance Attribute Details

#flagsObject

Returns the value of attribute flags.



22
23
24
# File 'lib/fontisan/woff2_font.rb', line 22

def flags
  @flags
end

#offsetObject

Returns the value of attribute offset.



22
23
24
# File 'lib/fontisan/woff2_font.rb', line 22

def offset
  @offset
end

#orig_lengthObject

Returns the value of attribute orig_length.



22
23
24
# File 'lib/fontisan/woff2_font.rb', line 22

def orig_length
  @orig_length
end

#tagObject

Returns the value of attribute tag.



22
23
24
# File 'lib/fontisan/woff2_font.rb', line 22

def tag
  @tag
end

#transform_lengthObject

Returns the value of attribute transform_length.



22
23
24
# File 'lib/fontisan/woff2_font.rb', line 22

def transform_length
  @transform_length
end

#transform_versionObject

Get transform version for this table



55
56
57
# File 'lib/fontisan/woff2_font.rb', line 55

def transform_version
  @transform_version
end

Instance Method Details

#transformed?Boolean

Check if table is transformed

Returns:

  • (Boolean)


50
51
52
# File 'lib/fontisan/woff2_font.rb', line 50

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