Class: Fontisan::Audit::Checks::NamingConsistencyCheck

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

Overview

Validates name-table consistency across name IDs. Catches common real-world bugs where font metadata disagrees with itself:

- PostScript name should start with the Family name (minus
spaces) — e.g. Family "Source Sans" → PS "SourceSans-Regular"
- Subfamily should be a recognized style ("Regular", "Bold",
"Italic", "Bold Italic") for non-variable fonts
- Full name should be Family + " " + Subfamily
- Version string should start with "Version "

These rules catch typo-level errors that confuse font pickers, package managers, and PDF embedding workflows.

Constant Summary collapse

RECOGNIZED_SUBFAMILIES =
%w[
  Regular Italic Bold BoldItalic Thin Light Medium SemiBold Black
  Condensed Extended Oblique Book Normal
].freeze

Class Method Summary collapse

Methods inherited from Fontisan::Audit::Check

issue

Class Method Details

.call(font) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/fontisan/audit/checks/naming_consistency_check.rb', line 27

def self.call(font)
  return [] unless font.has_table?("name")

  name = font.table("name")
  issues = []
  issues.concat(check_ps_name_prefix(name))
  issues.concat(check_full_name_composition(name))
  issues.concat(check_subfamily_style(name, font))
  issues
end

.codeObject



38
39
40
# File 'lib/fontisan/audit/checks/naming_consistency_check.rb', line 38

def self.code
  :naming_consistency
end