Class: Fontisan::Models::FontExport

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/fontisan/models/font_export.rb

Overview

FontExport represents complete font structure for export to YAML/JSON

This model encapsulates the entire font structure including header information, all tables (parsed and binary), and metadata. It supports round-trip conversion: font → export → import → font.

Examples:

Exporting a font

export = FontExport.new(source_file: "font.ttf")
export.extract_from_font(font)
yaml_output = export.to_yaml

Importing from YAML

export = FontExport.from_yaml(yaml_string)
font = export.rebuild_font

Defined Under Namespace

Classes: Header, Metadata, TableExport

Instance Method Summary collapse

Instance Method Details

#add_table(tag:, checksum:, parsed: false, data: nil, fields: nil) ⇒ void

This method returns an undefined value.

Add a table to the export

Parameters:

  • tag (String)

    Table tag

  • checksum (String)

    Table checksum

  • parsed (Boolean) (defaults to: false)

    Whether table is parsed

  • data (String, nil) (defaults to: nil)

    Binary data (hex/base64)

  • fields (Hash, nil) (defaults to: nil)

    Parsed fields as Hash/JSON



140
141
142
143
144
145
146
147
148
# File 'lib/fontisan/models/font_export.rb', line 140

def add_table(tag:, checksum:, parsed: false, data: nil, fields: nil)
  tables << TableExport.new(
    tag: tag,
    checksum: checksum,
    parsed: parsed,
    data: data,
    fields: fields,
  )
end

#binary_tablesArray<TableExport>

Get all binary-only tables

Returns:



128
129
130
# File 'lib/fontisan/models/font_export.rb', line 128

def binary_tables
  tables.reject(&:parsed)
end

#find_table(tag) ⇒ TableExport?

Find a table by tag

Parameters:

  • tag (String)

    The table tag (e.g., "head", "name")

Returns:



114
115
116
# File 'lib/fontisan/models/font_export.rb', line 114

def find_table(tag)
  tables.find { |t| t.tag == tag }
end

#parsed_tablesArray<TableExport>

Get all parsed tables

Returns:



121
122
123
# File 'lib/fontisan/models/font_export.rb', line 121

def parsed_tables
  tables.select(&:parsed)
end

#valid?Boolean

Validate export structure

Returns:

  • (Boolean)

    True if export is valid



153
154
155
# File 'lib/fontisan/models/font_export.rb', line 153

def valid?
  !.nil? && !header.nil? && !tables.empty?
end