Skip to content

API Reference

This section provides detailed API documentation for Fontisan's core classes, converters, validators, and models.

Core Classes

Converters

Validators

Models

Using the API

Loading Fonts

ruby
require 'fontisan'

# Automatic format detection
font = Fontisan::FontLoader.load('font.ttf')
font = Fontisan::FontLoader.load('font.otf')
font = Fontisan::FontLoader.load('font.pfb')

# Load from IO
font = Fontisan::FontLoader.load(io)

Converting Fonts

ruby
# Get recommended options
options = Fontisan::ConversionOptions.recommended(from: :ttf, to: :otf)

# Convert with options
converter = Fontisan::Converters::OutlineConverter.new
tables = converter.convert(font, options: options)

# Write the result
Fontisan::FontWriter.write(font, 'output.otf')

Validating Fonts

ruby
# Validate with a profile
result = Fontisan::FontValidator.validate('font.ttf', profile: :google_fonts)

# Check results
if result.passed?
  puts "Font is valid!"
else
  result.errors.each do |error|
    puts "#{error.code}: #{error.message}"
  end
end

Fontisan is a [Ribose](https://open.ribose.com/) project