Class: SvgConform::Requirements::NoExternalFontsRequirement
- Inherits:
-
BaseRequirement
- Object
- Lutaml::Model::Serializable
- BaseRequirement
- SvgConform::Requirements::NoExternalFontsRequirement
- Defined in:
- lib/svg_conform/requirements/no_external_fonts_requirement.rb
Overview
Validates that no external font references are present All fonts must be embedded in the SVG
Instance Method Summary collapse
- #check(node, context) ⇒ Object
- #should_check_node?(node, context = nil) ⇒ Boolean
- #validate_sax_element(element, context) ⇒ Object
Methods inherited from BaseRequirement
#collect_sax_data, #get_attributes, #needs_deferred_validation?, #skip_attribute_validation?, #to_s, #validate_document, #validate_sax_complete
Methods included from Interfaces::RequirementInterface
#collect_sax_data, #needs_deferred_validation?, #reset_state, #to_s, #validate_document, #validate_sax_complete
Methods included from NodeHelpers
#element?, #get_attribute, #has_attribute?, #remove_attribute, #set_attribute, #text?
Instance Method Details
#check(node, context) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/svg_conform/requirements/no_external_fonts_requirement.rb', line 22 def check(node, context) return unless element?(node) case node.name when "style" check_style_element(node, context) if check_style_fonts when "font-face" check_font_face_element(node, context) if check_font_face else check_style_attribute(node, context) if check_style_fonts end end |
#should_check_node?(node, context = nil) ⇒ Boolean
35 36 37 38 39 40 41 42 |
# File 'lib/svg_conform/requirements/no_external_fonts_requirement.rb', line 35 def should_check_node?(node, context = nil) return false unless element?(node) return false if context&.node_structurally_invalid?(node) node.name == "style" || node.name == "font-face" || has_style_attribute?(node) end |
#validate_sax_element(element, context) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/svg_conform/requirements/no_external_fonts_requirement.rb', line 44 def validate_sax_element(element, context) case element.name when "style" check_style_element_sax(element, context) if check_style_fonts when "font-face" check_font_face_element_sax(element, context) if check_font_face else check_style_attribute_sax(element, context) if check_style_fonts end end |