Class: Fontisan::Commands::TablesCommand

Inherits:
BaseCommand show all
Defined in:
lib/fontisan/commands/tables_command.rb

Overview

Command to list all tables in a font file.

This command extracts metadata about all tables present in a font file, including their tags, lengths, offsets, and checksums.

Examples:

List font tables

command = TablesCommand.new("path/to/font.ttf")
table_info = command.run
puts "Tables: #{table_info.num_tables}"

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Constructor Details

This class inherits a constructor from Fontisan::Commands::BaseCommand

Instance Method Details

#runModels::TableInfo

Extract table information from the font.

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fontisan/commands/tables_command.rb', line 18

def run
  table_info = Models::TableInfo.new
  table_info.sfnt_version = format_sfnt_version(font.header.sfnt_version)
  table_info.num_tables = font.tables.length

  table_info.tables = font.tables.map do |entry|
    Models::TableEntry.new(
      tag: entry.tag,
      length: entry.table_length,
      offset: entry.offset,
      checksum: entry.checksum,
    )
  end

  table_info
end