Font Collections
Fontisan supports font collections (TTC, OTC, dfont) with pack, unpack, and format conversion capabilities.
Overview
| Format | Description | Font Types |
|---|---|---|
| TTC | TrueType Collection | TrueType fonts only |
| OTC | OpenType Collection | CFF/OpenType fonts only |
| dfont | Apple Data Fork Font | Mixed TrueType and CFF |
Listing Fonts in Collections
CLI
bash
# List fonts in a collection
fontisan ls fonts.ttc
# Output example:
# Collection: fonts.ttc
# Fonts: 2
#
# 0. Helvetica Regular
# PostScript: Helvetica-Regular
# Format: TrueType
# Glyphs: 268, Tables: 14
#
# 1. Helvetica Bold
# PostScript: Helvetica-Bold
# Format: TrueType
# Glyphs: 268, Tables: 14API
ruby
collection = Fontisan::FontLoader.load('fonts.ttc')
collection.each_with_index do |font, index|
puts "#{index}. #{font.family_name} #{font.style}"
endExtracting Fonts (Unpack)
CLI
bash
# Extract all fonts from collection
fontisan unpack fonts.ttc --output-dir ./extracted
# Extract specific font by index
fontisan unpack fonts.ttc --index 0 --output first.ttf
# Extract with format conversion
fontisan unpack fonts.ttc --output-dir ./extracted --format otfAPI
ruby
collection = Fontisan::FontLoader.load('fonts.ttc')
collection.each_with_index do |font, index|
output = "extracted/font-#{index}.ttf"
Fontisan::FontWriter.write(font, output)
endCreating Collections (Pack)
CLI
bash
# Pack fonts into TTC
fontisan pack font1.ttf font2.ttf font3.ttf --output family.ttc
# Pack with deduplication
fontisan pack font1.ttf font2.ttf --output family.ttc --deduplicate
# Pack as OTC (OpenType collection)
fontisan pack font1.otf font2.otf --output family.otcAPI
ruby
fonts = [
Fontisan::FontLoader.load('regular.ttf'),
Fontisan::FontLoader.load('bold.ttf'),
Fontisan::FontLoader.load('italic.ttf')
]
Fontisan::CollectionWriter.pack(fonts, 'family.ttc')Collection Conversions
TTC → OTC
ruby
Fontisan::ConversionOptions.recommended(from: :ttc, to: :otc)
# opening: { convert_curves: true, decompose_composites: false, autohint: false }
# generating: { target_format: "otf", decompose_on_output: false,
# hinting_mode: "preserve" }Converts all TrueType fonts to OpenType/CFF, then repacks as OTC.
bash
fontisan convert family.ttc --to otc --output family.otc --target-format otfOTC → TTC
ruby
Fontisan::ConversionOptions.recommended(from: :otc, to: :ttc)
# opening: { convert_curves: true, decompose_composites: false, interpret_ot: true }
# generating: { target_format: "ttf", decompose_on_output: false,
# hinting_mode: "auto" }Converts all OpenType/CFF fonts to TrueType, then repacks as TTC.
bash
fontisan convert family.otc --to ttc --output family.ttc --target-format ttfTTC/OTC → dfont
ruby
Fontisan::ConversionOptions.recommended(from: :ttc, to: :dfont)
# opening: {}
# generating: { target_format: "preserve", decompose_on_output: false,
# write_custom_tables: true }Notes: dfont supports both TrueType and OpenType/CFF, or mixed formats.
bash
fontisan convert family.ttc --to dfont --output family.dfontTable Sharing
Collections share common tables to reduce file size:
cmap— Character mappingsloca— Glyph locations (TrueType)maxp— Maximum profilename— Font namespost— PostScript names
Analyzing Table Sharing
bash
fontisan info fonts.ttc
# Output includes:
# Table Sharing Statistics:
# Shared tables: 4
# Unique tables per font: 10
# Space saved: 45%Deduplication
When packing collections, Fontisan can deduplicate tables:
bash
fontisan pack font1.ttf font2.ttf --output family.ttc --deduplicateHow It Works
- Analyze all tables across fonts
- Identify identical tables by checksum
- Share tables where possible
- Reduce overall file size
Presets
archive_to_modern
Convert font archives to modern format:
ruby
Fontisan::ConversionOptions.from_preset(:archive_to_modern)
# From: :ttc, To: :otf
# opening: { convert_curves: true, decompose_composites: false }
# generating: { target_format: "otf", hinting_mode: "preserve" }Use cases:
- Extracting fonts from TTC archives
- Standardizing collection formats
- Converting legacy font collections
Examples
Extract and Convert Collection
bash
# Extract all fonts as OTF
fontisan unpack fonts.ttc --output-dir ./family --format otf
# Results in:
# family/font-0.otf
# family/font-1.otf
# family/font-2.otfConvert Collection Format
bash
# Convert TTC to OTC
fontisan convert truetype-collection.ttc --to otc \
--output opentype-collection.otc \
--target-format otf \
--hinting-mode autoMerge Multiple Collections
ruby
# Load multiple collections
collection1 = Fontisan::FontLoader.load('set1.ttc')
collection2 = Fontisan::FontLoader.load('set2.ttc')
# Combine fonts
all_fonts = collection1.to_a + collection2.to_a
# Pack as new collection
Fontisan::CollectionWriter.pack(all_fonts, 'combined.ttc')Optimize Collection
bash
# Pack with deduplication
fontisan pack *.ttf --output optimized.ttc --deduplicate
# Check space savings
fontisan info optimized.ttc