Class: Pdfrb::Font::TrueType::Subsetter

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfrb/font/true_type/subsetter.rb

Overview

Glyph subsetting for embedded TrueType fonts. Given a set of used glyph IDs, produces a new TTF with only those glyphs. This is a stub — full subsetting (table rewriting, composite glyph handling, CMap format 4 rewrite) is complex.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_file, glyph_ids) ⇒ Subsetter

Returns a new instance of Subsetter.



13
14
15
16
# File 'lib/pdfrb/font/true_type/subsetter.rb', line 13

def initialize(source_file, glyph_ids)
  @source_file = source_file
  @glyph_ids = glyph_ids.sort.uniq
end

Instance Attribute Details

#glyph_idsObject (readonly)

Returns the value of attribute glyph_ids.



11
12
13
# File 'lib/pdfrb/font/true_type/subsetter.rb', line 11

def glyph_ids
  @glyph_ids
end

#source_fileObject (readonly)

Returns the value of attribute source_file.



11
12
13
# File 'lib/pdfrb/font/true_type/subsetter.rb', line 11

def source_file
  @source_file
end

Instance Method Details

#subsetObject

Returns the subset font bytes. Currently a stub that returns the original file unmodified (no subsetting). Full implementation would rewrite glyf, loca, cmap, hmtx, maxp, OS/2 tables.



22
23
24
# File 'lib/pdfrb/font/true_type/subsetter.rb', line 22

def subset
  @source_file.instance_variable_get(:@data)
end