Class: Fontist::Import::Google::Models::Axis

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/fontist/import/google/models/axis.rb

Constant Summary collapse

STANDARD_TAGS =

Standard OpenType variable font axis tags

{
  "wght" => :weight,
  "wdth" => :width,
  "slnt" => :slant,
  "ital" => :italic,
  "opsz" => :optical_size,
}.freeze

Instance Method Summary collapse

Instance Method Details

#custom_axis?Boolean

Check if this is a custom (non-standard) axis

Returns:

  • (Boolean)

    true if tag is not a standard OpenType axis



51
52
53
# File 'lib/fontist/import/google/models/axis.rb', line 51

def custom_axis?
  !STANDARD_TAGS.key?(tag)
end

#descriptionString

Get a human-readable description of the axis

Returns:

  • (String)

    description of the axis



65
66
67
68
69
70
# File 'lib/fontist/import/google/models/axis.rb', line 65

def description
  type = STANDARD_TAGS[tag] || "custom"
  start_val = format_value(start)
  end_val = format_value(self.end)
  "#{tag} (#{type}): #{start_val}#{end_val}"
end

#rangeArray<Float>

Get the range of values as an array

Returns:

  • (Array<Float>)
    start, end


58
59
60
# File 'lib/fontist/import/google/models/axis.rb', line 58

def range
  [start, self.end]
end

#slant_axis?Boolean

Check if this is the slant axis

Returns:

  • (Boolean)

    true if tag is ‘slnt’



44
45
46
# File 'lib/fontist/import/google/models/axis.rb', line 44

def slant_axis?
  tag == "slnt"
end

#weight_axis?Boolean

Check if this is the weight axis

Returns:

  • (Boolean)

    true if tag is ‘wght’



30
31
32
# File 'lib/fontist/import/google/models/axis.rb', line 30

def weight_axis?
  tag == "wght"
end

#width_axis?Boolean

Check if this is the width axis

Returns:

  • (Boolean)

    true if tag is ‘wdth’



37
38
39
# File 'lib/fontist/import/google/models/axis.rb', line 37

def width_axis?
  tag == "wdth"
end