Class: Fontisan::Type1::ConversionOptions
- Inherits:
-
Object
- Object
- Fontisan::Type1::ConversionOptions
- Defined in:
- lib/fontisan/type1/conversion_options.rb
Overview
Conversion options for Type 1 font generation
ConversionOptions provides a unified
configuration interface for converting outline fonts (TTF, OTF, TTC, etc.) to
Type 1 formats (PFA, PFB, AFM, PFM, INF).
Constant Summary collapse
- DEFAULTS =
Default values based on TypeTool 3 and Adobe Type 1 specifications
{ upm_scale: 1000, encoding: Encodings::AdobeStandard, decompose_composites: false, convert_curves: true, autohint: false, preserve_hinting: false, format: :pfb, }.freeze
Instance Attribute Summary collapse
-
#autohint ⇒ Boolean
Apply autohinting to generated Type 1.
-
#convert_curves ⇒ Boolean
Convert quadratic curves to cubic.
-
#decompose_composites ⇒ Boolean
Decompose composite glyphs into base glyphs.
-
#encoding ⇒ Class
Encoding class (AdobeStandard, ISOLatin1, Unicode).
-
#format ⇒ Symbol
Output format (:pfb or :pfa).
-
#preserve_hinting ⇒ Boolean
Preserve native hinting from source font.
-
#upm_scale ⇒ Integer, :native
Target UPM (1000 for Type 1, :native to keep source UPM).
Class Method Summary collapse
-
.high_quality ⇒ ConversionOptions
Create options for high-quality output (with curve conversion).
-
.iso_latin1 ⇒ ConversionOptions
Create options for ISO-8859-1 encoding.
-
.minimal_size ⇒ ConversionOptions
Create options for minimal file size.
-
.native_upm ⇒ ConversionOptions
Create options with native UPM (no scaling).
-
.unicode_encoding ⇒ ConversionOptions
Create options with Unicode encoding.
-
.unix_type1 ⇒ ConversionOptions
Create options for Unix Type 1 output.
-
.windows_type1 ⇒ ConversionOptions
Create options for Windows Type 1 output.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ConversionOptions
constructor
Initialize conversion options.
-
#needs_autohinting? ⇒ Boolean
Check if autohinting is requested.
-
#needs_curve_conversion? ⇒ Boolean
Check if curve conversion is needed.
-
#needs_scaling? ⇒ Boolean
Check if UPM scaling is needed.
-
#to_hash ⇒ Hash
Convert to hash.
Constructor Details
#initialize(options = {}) ⇒ ConversionOptions
Initialize conversion options
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/fontisan/type1/conversion_options.rb', line 68 def initialize( = {}) @upm_scale = [:upm_scale] || DEFAULTS[:upm_scale] @encoding = [:encoding] || DEFAULTS[:encoding] @decompose_composites = [:decompose_composites] || DEFAULTS[:decompose_composites] @convert_curves = .fetch(:convert_curves, DEFAULTS[:convert_curves]) @autohint = [:autohint] || DEFAULTS[:autohint] @preserve_hinting = [:preserve_hinting] || DEFAULTS[:preserve_hinting] @format = [:format] || DEFAULTS[:format] validate! end |
Instance Attribute Details
#autohint ⇒ Boolean
Returns Apply autohinting to generated Type 1.
39 40 41 |
# File 'lib/fontisan/type1/conversion_options.rb', line 39 def autohint @autohint end |
#convert_curves ⇒ Boolean
Returns Convert quadratic curves to cubic.
36 37 38 |
# File 'lib/fontisan/type1/conversion_options.rb', line 36 def convert_curves @convert_curves end |
#decompose_composites ⇒ Boolean
Returns Decompose composite glyphs into base glyphs.
33 34 35 |
# File 'lib/fontisan/type1/conversion_options.rb', line 33 def decompose_composites @decompose_composites end |
#encoding ⇒ Class
Returns Encoding class (AdobeStandard, ISOLatin1, Unicode).
30 31 32 |
# File 'lib/fontisan/type1/conversion_options.rb', line 30 def encoding @encoding end |
#format ⇒ Symbol
Returns Output format (:pfb or :pfa).
45 46 47 |
# File 'lib/fontisan/type1/conversion_options.rb', line 45 def format @format end |
#preserve_hinting ⇒ Boolean
Returns Preserve native hinting from source font.
42 43 44 |
# File 'lib/fontisan/type1/conversion_options.rb', line 42 def preserve_hinting @preserve_hinting end |
#upm_scale ⇒ Integer, :native
Returns Target UPM (1000 for Type 1, :native to keep source UPM).
27 28 29 |
# File 'lib/fontisan/type1/conversion_options.rb', line 27 def upm_scale @upm_scale end |
Class Method Details
.high_quality ⇒ ConversionOptions
Create options for high-quality output (with curve conversion)
175 176 177 178 179 180 181 182 183 |
# File 'lib/fontisan/type1/conversion_options.rb', line 175 def self.high_quality new( upm_scale: 1000, encoding: Encodings::AdobeStandard, convert_curves: true, decompose_composites: true, format: :pfb, ) end |
.iso_latin1 ⇒ ConversionOptions
Create options for ISO-8859-1 encoding
153 154 155 156 157 158 159 |
# File 'lib/fontisan/type1/conversion_options.rb', line 153 def self.iso_latin1 new( upm_scale: 1000, encoding: Encodings::ISOLatin1, format: :pfb, ) end |
.minimal_size ⇒ ConversionOptions
Create options for minimal file size
188 189 190 191 192 193 194 195 196 |
# File 'lib/fontisan/type1/conversion_options.rb', line 188 def self.minimal_size new( upm_scale: 1000, encoding: Encodings::AdobeStandard, convert_curves: false, decompose_composites: false, format: :pfa, ) end |
.native_upm ⇒ ConversionOptions
Create options with native UPM (no scaling)
142 143 144 145 146 147 148 |
# File 'lib/fontisan/type1/conversion_options.rb', line 142 def self.native_upm new( upm_scale: :native, encoding: Encodings::Unicode, format: :pfb, ) end |
.unicode_encoding ⇒ ConversionOptions
Create options with Unicode encoding
164 165 166 167 168 169 170 |
# File 'lib/fontisan/type1/conversion_options.rb', line 164 def self.unicode_encoding new( upm_scale: 1000, encoding: Encodings::Unicode, format: :pfb, ) end |
.unix_type1 ⇒ ConversionOptions
Create options for Unix Type 1 output
131 132 133 134 135 136 137 |
# File 'lib/fontisan/type1/conversion_options.rb', line 131 def self.unix_type1 new( upm_scale: 1000, encoding: Encodings::AdobeStandard, format: :pfa, ) end |
.windows_type1 ⇒ ConversionOptions
Create options for Windows Type 1 output
120 121 122 123 124 125 126 |
# File 'lib/fontisan/type1/conversion_options.rb', line 120 def self.windows_type1 new( upm_scale: 1000, encoding: Encodings::AdobeStandard, format: :pfb, ) end |
Instance Method Details
#needs_autohinting? ⇒ Boolean
Check if autohinting is requested
98 99 100 |
# File 'lib/fontisan/type1/conversion_options.rb', line 98 def needs_autohinting? @autohint end |
#needs_curve_conversion? ⇒ Boolean
Check if curve conversion is needed
91 92 93 |
# File 'lib/fontisan/type1/conversion_options.rb', line 91 def needs_curve_conversion? @convert_curves end |
#needs_scaling? ⇒ Boolean
Check if UPM scaling is needed
84 85 86 |
# File 'lib/fontisan/type1/conversion_options.rb', line 84 def needs_scaling? @upm_scale != :native end |
#to_hash ⇒ Hash
Convert to hash
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fontisan/type1/conversion_options.rb', line 105 def to_hash { upm_scale: @upm_scale, encoding: @encoding, decompose_composites: @decompose_composites, convert_curves: @convert_curves, autohint: @autohint, preserve_hinting: @preserve_hinting, format: @format, } end |