Class: Fontisan::Subset::Options
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Fontisan::Subset::Options
- Defined in:
- lib/fontisan/subset/options.rb
Overview
Subsetting configuration class
This class defines all available options for font subsetting operations. It provides sensible defaults for various subsetting scenarios and uses Lutaml::Model for serialization support.
Instance Method Summary collapse
-
#all_features? ⇒ Boolean
Check if all features should be retained.
-
#all_scripts? ⇒ Boolean
Check if all scripts should be retained.
-
#drop_hints ⇒ Boolean
Whether to drop hinting instructions.
-
#drop_names ⇒ Boolean
Whether to drop glyph names from the post table.
-
#features ⇒ Array<String>
OpenType features to retain in the subset.
-
#include_notdef ⇒ Boolean
Whether to include the .notdef glyph.
-
#include_null ⇒ Boolean
Whether to include the .null glyph.
-
#initialize(attributes = {}) ⇒ Options
constructor
Initialize options with custom values.
-
#profile ⇒ String
Subsetting profile name (pdf, web, minimal, or custom).
-
#retain_gids ⇒ Boolean
Whether to retain original glyph IDs.
-
#scripts ⇒ Array<String>
Script tags to retain in the subset.
-
#unicode_ranges ⇒ Boolean
Whether to prune OS/2 Unicode ranges.
-
#validate! ⇒ Boolean
Validate the options configuration.
Constructor Details
#initialize(attributes = {}) ⇒ Options
Initialize options with custom values
109 110 111 |
# File 'lib/fontisan/subset/options.rb', line 109 def initialize(attributes = {}) super end |
Instance Method Details
#all_features? ⇒ Boolean
Check if all features should be retained
116 117 118 |
# File 'lib/fontisan/subset/options.rb', line 116 def all_features? features.empty? end |
#all_scripts? ⇒ Boolean
Check if all scripts should be retained
123 124 125 |
# File 'lib/fontisan/subset/options.rb', line 123 def all_scripts? scripts.include?("*") end |
#drop_hints ⇒ Boolean
Whether to drop hinting instructions
Hinting improves text rendering at small sizes but increases file size. Web fonts typically don’t need hints due to modern rendering engines.
39 |
# File 'lib/fontisan/subset/options.rb', line 39 attribute :drop_hints, :boolean, default: -> { false } |
#drop_names ⇒ Boolean
Whether to drop glyph names from the post table
Glyph names are useful for debugging but not required for rendering. Dropping them reduces file size.
47 |
# File 'lib/fontisan/subset/options.rb', line 47 attribute :drop_names, :boolean, default: -> { false } |
#features ⇒ Array<String>
OpenType features to retain in the subset
An empty array means all features are retained. Specify feature tags (e.g., [‘liga’, ‘kern’]) to keep only those features.
87 |
# File 'lib/fontisan/subset/options.rb', line 87 attribute :features, :string, collection: true, default: -> { [] } |
#include_notdef ⇒ Boolean
Whether to include the .notdef glyph
The .notdef glyph is displayed for missing characters. It is typically required by font specifications.
72 |
# File 'lib/fontisan/subset/options.rb', line 72 attribute :include_notdef, :boolean, default: -> { true } |
#include_null ⇒ Boolean
Whether to include the .null glyph
The .null glyph (U+0000) is sometimes used for control purposes.
79 |
# File 'lib/fontisan/subset/options.rb', line 79 attribute :include_null, :boolean, default: -> { false } |
#profile ⇒ String
Subsetting profile name (pdf, web, minimal, or custom)
31 |
# File 'lib/fontisan/subset/options.rb', line 31 attribute :profile, :string, default: -> { "pdf" } |
#retain_gids ⇒ Boolean
Whether to retain original glyph IDs
When true, removed glyphs leave empty slots in the glyf table, preserving original GID assignments. When false, glyphs are compacted to eliminate gaps.
64 |
# File 'lib/fontisan/subset/options.rb', line 64 attribute :retain_gids, :boolean, default: -> { false } |
#scripts ⇒ Array<String>
Script tags to retain in the subset
An array containing “*” means all scripts are retained. Specify script tags (e.g., [‘latn’, ‘arab’]) to keep only those scripts.
95 |
# File 'lib/fontisan/subset/options.rb', line 95 attribute :scripts, :string, collection: true, default: -> { ["*"] } |
#unicode_ranges ⇒ Boolean
Whether to prune OS/2 Unicode ranges
Updates the OS/2 table’s Unicode range bits to reflect only the glyphs present in the subset.
55 |
# File 'lib/fontisan/subset/options.rb', line 55 attribute :unicode_ranges, :boolean, default: -> { true } |
#validate! ⇒ Boolean
Validate the options configuration
131 132 133 134 135 136 137 138 139 |
# File 'lib/fontisan/subset/options.rb', line 131 def validate! valid_profiles = %w[pdf web minimal custom] unless valid_profiles.include?(profile) raise ArgumentError, "Invalid profile '#{profile}'. Must be one of: #{valid_profiles.join(', ')}" end true end |