Class: Fontisan::Commands::ScriptsCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/fontisan/commands/scripts_command.rb

Overview

Command to extract and display scripts from GSUB/GPOS tables

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Constructor Details

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

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fontisan/commands/scripts_command.rb', line 9

def run
  result = Models::ScriptsInfo.new
  scripts_set = Set.new

  # Collect scripts from GSUB table
  if font.has_table?(Constants::GSUB_TAG)
    gsub = font.table(Constants::GSUB_TAG)
    scripts_set.merge(gsub.scripts)
  end

  # Collect scripts from GPOS table
  if font.has_table?(Constants::GPOS_TAG)
    gpos = font.table(Constants::GPOS_TAG)
    scripts_set.merge(gpos.scripts)
  end

  # Load script descriptions from configuration
  descriptions = load_script_descriptions

  # Build script records
  result.scripts = scripts_set.sort.map do |tag|
    Models::ScriptRecord.new(
      tag: tag,
      description: descriptions[tag] || "Unknown script",
    )
  end

  result.script_count = result.scripts.length
  result
end