Module: HexaPDF::Font::TrueType::Optimizer

Defined in:
lib/hexapdf/font/true_type/optimizer.rb

Overview

Provides methods for optimizing a TrueType font file in various ways.

Class Method Summary collapse

Class Method Details

.build_for_pdf(font) ⇒ Object

Returns for the given font a TrueType font file as binary string that is optimized for use in a PDF (i.e. only the essential tables are retained).



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/hexapdf/font/true_type/optimizer.rb', line 48

def self.build_for_pdf(font)
  tables = {
    'head' => font[:head].raw_data,
    'hhea' => font[:hhea].raw_data,
    'maxp' => font[:maxp].raw_data,
    'glyf' => font[:glyf].raw_data,
    'loca' => font[:loca].raw_data,
    'hmtx' => font[:hmtx].raw_data,
  }
  tables['cmap'] = font[:cmap].raw_data if font[:cmap]
  tables['cvt '] = font[:'cvt '].raw_data if font[:'cvt ']
  tables['fpgm'] = font[:fpgm].raw_data if font[:fpgm]
  tables['prep'] = font[:prep].raw_data if font[:prep]
  Builder.build(tables)
end