Class: Fontisan::Audit::Checks::FormatRoundTripCheck

Inherits:
Fontisan::Audit::Check show all
Defined in:
lib/fontisan/audit/checks/format_round_trip_check.rb

Overview

Reports fidelity discrepancies when converting between TTF and OTF outline formats. A high-fidelity conversion preserves:

- Glyph count (maxp.numGlyphs)
- Codepoint coverage (cmap Unicode mappings)
- Font identity (name table family + PostScript name)

Any mismatch signals a bug in the outline converter or a data loss path. This check is the pure-Ruby replacement for ttx diff comparisons.

Only converts in one direction (TTF→OTF for TrueType sources, OTF→TTF for CFF sources) — full round-trip would double the conversion surface without adding signal.

Class Method Summary collapse

Methods inherited from Fontisan::Audit::Check

issue

Class Method Details

.call(font) ⇒ Array<Models::ValidationReport::Issue>

Parameters:

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fontisan/audit/checks/format_round_trip_check.rb', line 27

def self.call(font)
  target = round_trip_target(font)
  return [] unless target

  converted_path = convert_to_temp(font, target)
  return [] unless converted_path

  converted = FontLoader.load(converted_path)
  compare_fonts(font, converted, target)
rescue StandardError => e
  [issue(severity: :warning,
         message: "Round-trip conversion to #{target.upcase} failed: " \
                  "#{e.class}: #{e.message}",
         location: "round_trip.#{target}")]
ensure
  cleanup_temp(converted_path) if converted_path
end

.codeObject



45
46
47
# File 'lib/fontisan/audit/checks/format_round_trip_check.rb', line 45

def self.code
  :format_round_trip
end