Class: Fontisan::OpenTypeCollection

Inherits:
BaseCollection show all
Defined in:
lib/fontisan/open_type_collection.rb

Overview

OpenType Collection domain object

Represents a complete OpenType Collection file (OTC). Inherits all shared functionality from BaseCollection and implements OTC-specific behavior.

Examples:

Reading and extracting fonts

File.open("fonts.otc", "rb") do |io|
  otc = OpenTypeCollection.read(io)
  puts otc.num_fonts  # => 4
  fonts = otc.extract_fonts(io)  # => [OpenTypeFont, OpenTypeFont, ...]
end

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCollection

#collection?, #collection_info, #font, #font_count, from_file, #list_fonts, #outline_type, #table_names, #valid?, #variation_type, #version, #version_string

Methods included from Collection::SharedLogic

#calculate_table_sharing_for_fonts

Class Method Details

.collection_formatString

Get the collection format identifier

Returns:

  • (String)

    "OTC" for OpenType Collection



32
33
34
# File 'lib/fontisan/open_type_collection.rb', line 32

def self.collection_format
  "OTC"
end

.font_classClass

Get the font class for OpenType collections

Returns:

  • (Class)

    OpenTypeFont class



25
26
27
# File 'lib/fontisan/open_type_collection.rb', line 25

def self.font_class
  OpenTypeFont
end

Instance Method Details

#extract_fonts(io) ⇒ Array<OpenTypeFont>

Extract fonts as OpenTypeFont objects

Reads each font from the OTC file and returns them as OpenTypeFont objects. This method uses the from_collection method.

Parameters:

  • io (IO)

    Open file handle to read fonts from

Returns:



43
44
45
46
47
# File 'lib/fontisan/open_type_collection.rb', line 43

def extract_fonts(io)
  font_offsets.map do |offset|
    OpenTypeFont.from_collection(io, offset)
  end
end

#formatSymbol

High-level pipeline format identifier. Owned by the collection class so the conversion pipeline can dispatch without case statements (OCP).

Returns:

  • (Symbol)

    :otc



20
# File 'lib/fontisan/open_type_collection.rb', line 20

def format = :otc