Class: Fontisan::Export::Exporter
- Inherits:
-
Object
- Object
- Fontisan::Export::Exporter
- Defined in:
- lib/fontisan/export/exporter.rb
Overview
Exporter orchestrates font export to YAML/JSON/TTX
Main entry point for exporting fonts to debugging formats. Handles table extraction, serialization, and metadata generation.
Instance Method Summary collapse
-
#export(options = {}) ⇒ Models::FontExport, String
Export font to FontExport model.
-
#initialize(font, source_path, options = {}) ⇒ Exporter
constructor
Initialize exporter.
-
#to_json(options = {}) ⇒ String
Export font and return as JSON string.
-
#to_ttx(options = {}) ⇒ String
Export font and return as TTX XML string.
-
#to_yaml(options = {}) ⇒ String
Export font and return as YAML string.
Constructor Details
#initialize(font, source_path, options = {}) ⇒ Exporter
Initialize exporter
29 30 31 32 33 34 |
# File 'lib/fontisan/export/exporter.rb', line 29 def initialize(font, source_path, = {}) @font = font @source_path = source_path @binary_format = .fetch(:binary_format, :hex) @serializer = TableSerializer.new(binary_format: @binary_format) end |
Instance Method Details
#export(options = {}) ⇒ Models::FontExport, String
Export font to FontExport model
42 43 44 45 46 47 48 49 50 |
# File 'lib/fontisan/export/exporter.rb', line 42 def export( = {}) format = [:format] || :yaml if format == :ttx to_ttx() else export_to_model() end end |
#to_json(options = {}) ⇒ String
Export font and return as JSON string
65 66 67 68 |
# File 'lib/fontisan/export/exporter.rb', line 65 def to_json( = {}) export_model = export_to_model() export_model.to_json end |
#to_ttx(options = {}) ⇒ String
Export font and return as TTX XML string
Uses model-based architecture with FontToTtx transformer and lutaml-model serialization.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/fontisan/export/exporter.rb', line 80 def to_ttx( = {}) # Use new model-based architecture transformer = Transformers::FontToTtx.new(@font) ttx_model = transformer.transform() # Let lutaml-model handle XML serialization ttx_model.to_xml( pretty: .fetch(:pretty, true), indent: .fetch(:indent, 2), ) end |
#to_yaml(options = {}) ⇒ String
Export font and return as YAML string
56 57 58 59 |
# File 'lib/fontisan/export/exporter.rb', line 56 def to_yaml( = {}) export_model = export_to_model() export_model.to_yaml end |