Class: Fontist::Import::Google::Models::FontVariant
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Fontist::Import::Google::Models::FontVariant
- Defined in:
- lib/fontist/import/google/models/font_variant.rb
Constant Summary collapse
- VALID_FORMATS =
Valid font formats
%i[ttf woff2].freeze
Instance Method Summary collapse
-
#description ⇒ String
Get a human-readable description of the variant.
-
#extension ⇒ String
Get the file extension for this variant.
-
#ttf? ⇒ Boolean
Check if format is TTF.
-
#valid_format? ⇒ Boolean
Validate the format.
-
#variable_font?(family = nil) ⇒ Boolean
Check if this is a variable font Note: This requires access to the parent family’s axes Should be called with the parent family as context.
-
#woff2? ⇒ Boolean
Check if format is WOFF2.
Instance Method Details
#description ⇒ String
Get a human-readable description of the variant
64 65 66 |
# File 'lib/fontist/import/google/models/font_variant.rb', line 64 def description "#{name} (#{format})" end |
#extension ⇒ String
Get the file extension for this variant
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fontist/import/google/models/font_variant.rb', line 36 def extension case format.to_sym when :ttf ".ttf" when :woff2 ".woff2" else "" end end |
#ttf? ⇒ Boolean
Check if format is TTF
50 51 52 |
# File 'lib/fontist/import/google/models/font_variant.rb', line 50 def ttf? format.to_sym == :ttf end |
#valid_format? ⇒ Boolean
Validate the format
71 72 73 |
# File 'lib/fontist/import/google/models/font_variant.rb', line 71 def valid_format? VALID_FORMATS.include?(format.to_sym) end |
#variable_font?(family = nil) ⇒ Boolean
Check if this is a variable font Note: This requires access to the parent family’s axes Should be called with the parent family as context
27 28 29 30 31 |
# File 'lib/fontist/import/google/models/font_variant.rb', line 27 def variable_font?(family = nil) return false if family.nil? family.variable_font? end |
#woff2? ⇒ Boolean
Check if format is WOFF2
57 58 59 |
# File 'lib/fontist/import/google/models/font_variant.rb', line 57 def woff2? format.to_sym == :woff2 end |