Class: Fontisan::Models::ColorGlyph

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/fontisan/models/color_glyph.rb

Overview

Color glyph information model

Represents a complete color glyph from the COLR table, containing multiple layers that are rendered in order to create the final multi-colored glyph.

This model uses lutaml-model for structured serialization to YAML/JSON/XML.

Examples:

Creating a color glyph

glyph = ColorGlyph.new
glyph.glyph_id = 100
glyph.num_layers = 3
glyph.layers = [layer1, layer2, layer3]

Serializing to JSON

json = glyph.to_json
# {
#   "glyph_id": 100,
#   "num_layers": 3,
#   "layers": [...]
# }

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#glyph_idInteger

Returns Base glyph ID.

Returns:

  • (Integer)

    Base glyph ID



31
# File 'lib/fontisan/models/color_glyph.rb', line 31

attribute :glyph_id, :integer

#layersArray<ColorLayer>

Returns Array of color layers.

Returns:



39
# File 'lib/fontisan/models/color_glyph.rb', line 39

attribute :layers, ColorLayer, collection: true

#num_layersInteger

Returns Number of color layers.

Returns:

  • (Integer)

    Number of color layers



35
# File 'lib/fontisan/models/color_glyph.rb', line 35

attribute :num_layers, :integer

Instance Method Details

#empty?Boolean

Check if glyph is empty

Returns:

  • (Boolean)

    True if no layers



51
52
53
# File 'lib/fontisan/models/color_glyph.rb', line 51

def empty?
  !has_layers?
end

#has_layers?Boolean

Check if glyph has color layers

Returns:

  • (Boolean)

    True if glyph has layers



44
45
46
# File 'lib/fontisan/models/color_glyph.rb', line 44

def has_layers?
  num_layers&.positive? || false
end