Class: Fontisan::TrueTypeFont

Inherits:
SfntFont
  • Object
show all
Extended by:
TrueTypeFontExtensions
Defined in:
lib/fontisan/true_type_font.rb

Overview

TrueType Font domain object

Represents a TrueType Font file (glyf outlines). Inherits all shared SFNT functionality from SfntFont and adds TrueType-specific behavior.

Examples:

Reading and analyzing a font

ttf = TrueTypeFont.from_file("font.ttf")
puts ttf.header.num_tables  # => 14
name_table = ttf.table("name")
puts name_table.english_name(Tables::Name::FAMILY)

Loading with metadata mode

ttf = TrueTypeFont.from_file("font.ttf", mode: :metadata)
puts ttf.loading_mode  # => :metadata
ttf.table_available?("GSUB")  # => false

Writing a font

ttf.to_file("output.ttf")

Reading from TTC collection

ttf = TrueTypeFont.from_collection(io, offset)

Constant Summary

Constants inherited from SfntFont

SfntFont::PADDING_BYTES, SfntFont::SFNT_TABLE_CLASS_MAP, SfntFont::TABLE_CLASS_MAP

Instance Attribute Summary

Attributes inherited from SfntFont

#io_source, #lazy_load_enabled, #loading_mode, #parsed_tables, #sfnt_tables, #table_data, #table_entry_cache

Instance Method Summary collapse

Methods included from TrueTypeFontExtensions

from_tables

Methods inherited from SfntFont

#all_sfnt_tables, #close, #collection?, #family_name, finalize, #find_table_entry, from_collection, from_file, #full_name, #has_table?, #head_table, #initialize_storage, #outline_type, #post_script_name, #preferred_family_name, #preferred_subfamily_name, #read_metadata_tables_batched, #read_table_data, #setup_finalizer, #sfnt_table, #subfamily_name, #table, #table_available?, #table_names, #to_file, #units_per_em, #update_checksum_adjustment_in_file, #update_checksum_adjustment_in_io, #valid?, #variation_type

Instance Method Details

#cff?Boolean

Check if font is CFF flavored

Returns:

  • (Boolean)

    false for TrueType fonts



44
45
46
# File 'lib/fontisan/true_type_font.rb', line 44

def cff?
  false
end

#formatSymbol

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

Returns:

  • (Symbol)

    :ttf



32
# File 'lib/fontisan/true_type_font.rb', line 32

def format = :ttf

#truetype?Boolean

Check if font is TrueType flavored

Returns:

  • (Boolean)

    true for TrueType fonts



37
38
39
# File 'lib/fontisan/true_type_font.rb', line 37

def truetype?
  true
end