Class: Fontisan::Ufo::Compile::BaseCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/ufo/compile/base_compiler.rb

Overview

Common orchestrator for TTF and OTF compilers. Subclasses implement #build_outline_tables (returning the format-specific table set: glyf+loca for TTF, CFF for OTF) and sfnt_version (0x00010000 for TTF, 0x4F54544F for OTF).

Direct Known Subclasses

OtfCompiler, TtfCompiler

Constant Summary collapse

SFNT_VERSION_TRUE_TYPE =
0x00010000
SFNT_VERSION_OPEN_TYPE =

"OTTO"

0x4F54544F

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(font) ⇒ BaseCompiler

Returns a new instance of BaseCompiler.



18
19
20
# File 'lib/fontisan/ufo/compile/base_compiler.rb', line 18

def initialize(font)
  @font = font
end

Instance Attribute Details

#fontObject (readonly)

Returns the value of attribute font.



16
17
18
# File 'lib/fontisan/ufo/compile/base_compiler.rb', line 16

def font
  @font
end

Instance Method Details

#build_outline_tablesHash<String, #to_binary_s, String>

Format-specific extra tables. Override in subclasses.

Returns:

  • (Hash<String, #to_binary_s, String>)


32
33
34
# File 'lib/fontisan/ufo/compile/base_compiler.rb', line 32

def build_outline_tables
  {}
end

#compile(output_path:) ⇒ String

Returns the path.

Parameters:

  • output_path (String)

    where to write the binary font

Returns:

  • (String)

    the path



24
25
26
27
28
# File 'lib/fontisan/ufo/compile/base_compiler.rb', line 24

def compile(output_path:)
  tables = build_tables
  write(tables, output_path)
  output_path
end

#sfnt_versionInteger

Returns 0x00010000 (TTF) or 0x4F54544F (OTF).

Returns:

  • (Integer)

    0x00010000 (TTF) or 0x4F54544F (OTF)



37
38
39
# File 'lib/fontisan/ufo/compile/base_compiler.rb', line 37

def sfnt_version
  self.class::SFNT_VERSION
end