Class: Fontisan::Export::TtxGenerator
- Inherits:
-
Object
- Object
- Fontisan::Export::TtxGenerator
- Defined in:
- lib/fontisan/export/ttx_generator.rb
Overview
TtxGenerator generates TTX XML format from font data
Generates fonttools-compatible TTX XML format for font debugging and interoperability. Handles various table types with appropriate XML structures per the TTX specification.
Instance Method Summary collapse
-
#generate(options = {}) ⇒ String
Generate TTX XML.
-
#initialize(font, source_path, options = {}) ⇒ TtxGenerator
constructor
Initialize TTX generator.
Constructor Details
#initialize(font, source_path, options = {}) ⇒ TtxGenerator
Initialize TTX generator
28 29 30 31 32 33 |
# File 'lib/fontisan/export/ttx_generator.rb', line 28 def initialize(font, source_path, = {}) @font = font @source_path = source_path @pretty = .fetch(:pretty, true) @indent = .fetch(:indent, 2) end |
Instance Method Details
#generate(options = {}) ⇒ String
Generate TTX XML
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fontisan/export/ttx_generator.rb', line 40 def generate( = {}) table_list = [:tables] || :all builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| xml.ttFont( "sfntVersion" => format_sfnt_version(to_int(@font.header.sfnt_version)), "ttLibVersion" => "4.0", ) do generate_glyph_order(xml) tables_to_generate = select_tables(table_list) tables_to_generate.each do |tag| generate_table(xml, tag) end end end format_output(builder.to_xml) end |