Class: Fontisan::Subset::Profile
- Inherits:
-
Object
- Object
- Fontisan::Subset::Profile
- Defined in:
- lib/fontisan/subset/profile.rb
Overview
Subsetting profiles
This class manages font subsetting profiles that specify which font tables should be included in the subset. Profiles are loaded from an external YAML configuration file for flexibility and maintainability.
Constant Summary collapse
- KNOWN_TABLES =
All known font table tags
Comprehensive list of all standard TrueType/OpenType tables
%w[ cmap head hhea hmtx maxp name OS/2 post loca glyf cvt fpgm prep gasp GSUB GPOS GDEF BASE JSTF CFF CFF2 VORG EBDT EBLC EBSC CBDT CBLC sbix kern vhea vmtx LTSH PCLT VDMX hdmx fvar gvar avar cvar HVAR VVAR MVAR STAT DSIG ].freeze
Class Method Summary collapse
-
.custom(tables) ⇒ Array<String>
Create a custom profile with specified tables.
-
.description(name) ⇒ String?
Get profile description.
-
.for_name(name) ⇒ Array<String>
Get table list for a named profile.
-
.known_table?(table) ⇒ Boolean
Check if a table tag is recognized.
-
.valid_names ⇒ Array<String>
Get list of all valid profile names.
Class Method Details
.custom(tables) ⇒ Array<String>
Create a custom profile with specified tables
Validates that all provided table tags are recognized and returns the list of tables in a consistent format.
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fontisan/subset/profile.rb', line 79 def custom(tables) tables = Array(tables) unknown = tables - KNOWN_TABLES unless unknown.empty? raise ArgumentError, "Unknown table tags: #{unknown.join(', ')}" end tables.dup end |
.description(name) ⇒ String?
Get profile description
121 122 123 124 125 |
# File 'lib/fontisan/subset/profile.rb', line 121 def description(name) profiles = load_profiles profile_config = profiles[name.to_s.downcase] profile_config&.dig("description") end |
.for_name(name) ⇒ Array<String>
Get table list for a named profile
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fontisan/subset/profile.rb', line 51 def for_name(name) profiles = load_profiles profile_config = profiles[name.to_s.downcase] unless profile_config raise ArgumentError, "Unknown profile '#{name}'. Valid profiles: #{valid_names.join(', ')}" end profile_config["tables"].dup end |
.known_table?(table) ⇒ Boolean
Check if a table tag is recognized
99 100 101 |
# File 'lib/fontisan/subset/profile.rb', line 99 def known_table?(table) KNOWN_TABLES.include?(table.to_s) end |
.valid_names ⇒ Array<String>
Get list of all valid profile names
109 110 111 |
# File 'lib/fontisan/subset/profile.rb', line 109 def valid_names load_profiles.keys.sort end |