Class: Fontisan::Variable::GlyphDeltaProcessor
- Inherits:
-
Object
- Object
- Fontisan::Variable::GlyphDeltaProcessor
- Defined in:
- lib/fontisan/variable/glyph_delta_processor.rb
Overview
Applies glyph outline deltas from gvar table
Processes delta values for glyph control points and phantom points, applying them based on region scalars to modify glyph outlines.
Handles both simple and compound glyphs, and processes phantom points which affect glyph metrics.
Instance Attribute Summary collapse
-
#config ⇒ Hash
readonly
Configuration settings.
Instance Method Summary collapse
-
#apply_deltas(glyph_id, region_scalars) ⇒ Hash?
Apply deltas to a glyph.
-
#glyph_count ⇒ Integer
Get number of glyphs with variations.
-
#has_variations?(glyph_id) ⇒ Boolean
Check if glyph has variation data.
-
#initialize(gvar, config = {}) ⇒ GlyphDeltaProcessor
constructor
Initialize the processor.
Constructor Details
#initialize(gvar, config = {}) ⇒ GlyphDeltaProcessor
Initialize the processor
27 28 29 30 31 |
# File 'lib/fontisan/variable/glyph_delta_processor.rb', line 27 def initialize(gvar, config = {}) @gvar = gvar @config = load_config.merge(config) @shared_tuples = gvar&.shared_tuples || [] end |
Instance Attribute Details
#config ⇒ Hash (readonly)
Returns Configuration settings.
21 22 23 |
# File 'lib/fontisan/variable/glyph_delta_processor.rb', line 21 def config @config end |
Instance Method Details
#apply_deltas(glyph_id, region_scalars) ⇒ Hash?
Apply deltas to a glyph
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fontisan/variable/glyph_delta_processor.rb', line 38 def apply_deltas(glyph_id, region_scalars) return nil unless @gvar # Get tuple variations for this glyph tuple_info = @gvar.glyph_tuple_variations(glyph_id) return nil unless tuple_info # Calculate accumulated deltas calculate_accumulated_deltas(tuple_info, region_scalars) end |
#glyph_count ⇒ Integer
Get number of glyphs with variations
63 64 65 |
# File 'lib/fontisan/variable/glyph_delta_processor.rb', line 63 def glyph_count @gvar&.glyph_count || 0 end |
#has_variations?(glyph_id) ⇒ Boolean
Check if glyph has variation data
53 54 55 56 57 58 |
# File 'lib/fontisan/variable/glyph_delta_processor.rb', line 53 def has_variations?(glyph_id) return false unless @gvar data = @gvar.glyph_variation_data(glyph_id) !data.nil? && !data.empty? end |