Module: Fontisan::Ufo::Convert::ToDfont
- Defined in:
- lib/fontisan/ufo/convert/to_dfont.rb
Overview
UFO → dfont (Mac OS resource-fork font container). Two-step:
1. Compile UFO → TTF/OTF in tmpdir.
2. Load + feed to Collection::DfontBuilder, which wraps the
SFNT binary in a Mac resource fork.
Class Method Summary collapse
-
.convert(ufo, output_path:, compiler: :ttf, **_opts) ⇒ String
The output_path.
Class Method Details
.convert(ufo, output_path:, compiler: :ttf, **_opts) ⇒ String
Returns the output_path.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fontisan/ufo/convert/to_dfont.rb', line 18 def self.convert(ufo, output_path:, compiler: :ttf, **_opts) compiler_class = Convert::COMPILER_FOR_FORMAT[compiler.to_sym] raise ArgumentError, "unknown intermediate compiler: #{compiler.inspect}" unless compiler_class Dir.mktmpdir do |dir| intermediate_path = File.join(dir, "intermediate#{ext_for(compiler)}") compiler_class.new(ufo).compile(output_path: intermediate_path) loaded = Fontisan::FontLoader.load(intermediate_path) result = Fontisan::Collection::DfontBuilder.new([loaded]).build File.binwrite(output_path, result[:binary]) end output_path end |