Class: Fontisan::Pipeline::OutputWriter
- Inherits:
-
Object
- Object
- Fontisan::Pipeline::OutputWriter
- Defined in:
- lib/fontisan/pipeline/output_writer.rb
Overview
Handles writing font tables to various output formats
This class abstracts the complexity of writing different font formats:
- SFNT formats (TTF, OTF) via FontWriter
- WOFF via WoffWriter
- WOFF2 via Woff2Encoder
Single Responsibility: Coordinate output writing for different formats
Instance Attribute Summary collapse
-
#format ⇒ Symbol
readonly
Target format.
-
#options ⇒ Hash
readonly
Writing options.
-
#output_path ⇒ String
readonly
Output file path.
Instance Method Summary collapse
-
#initialize(output_path, format, options = {}) ⇒ OutputWriter
constructor
Initialize output writer.
-
#write(tables) ⇒ Integer
Write font tables to output file.
Constructor Details
#initialize(output_path, format, options = {}) ⇒ OutputWriter
Initialize output writer
37 38 39 40 41 |
# File 'lib/fontisan/pipeline/output_writer.rb', line 37 def initialize(output_path, format, = {}) @output_path = output_path @format = format @options = end |
Instance Attribute Details
#format ⇒ Symbol (readonly)
Returns Target format.
26 27 28 |
# File 'lib/fontisan/pipeline/output_writer.rb', line 26 def format @format end |
#options ⇒ Hash (readonly)
Returns Writing options.
29 30 31 |
# File 'lib/fontisan/pipeline/output_writer.rb', line 29 def @options end |
#output_path ⇒ String (readonly)
Returns Output file path.
23 24 25 |
# File 'lib/fontisan/pipeline/output_writer.rb', line 23 def output_path @output_path end |
Instance Method Details
#write(tables) ⇒ Integer
Write font tables to output file
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fontisan/pipeline/output_writer.rb', line 48 def write(tables) # Catch cross-format misuse before delegating, so the error message # is consistent regardless of whether the format goes through # FormatConverter (outline conversions) or this writer (packaging # changes for WOFF/WOFF2). Converters::FormatConverter.(@format, @options) case @format when :ttf, :otf write_sfnt(tables) when :woff write_woff(tables) when :woff2 write_woff2(tables) when :svg write_svg(tables) else raise ArgumentError, "Unsupported output format: #{@format}" end end |