Class: Plurimath::Math::Function::FontStyle

Inherits:
BinaryFunction show all
Defined in:
lib/plurimath/math/function/font_style.rb,
lib/plurimath/math/function/font_style/bold.rb,
lib/plurimath/math/function/font_style/italic.rb,
lib/plurimath/math/function/font_style/normal.rb,
lib/plurimath/math/function/font_style/script.rb,
lib/plurimath/math/function/font_style/fraktur.rb,
lib/plurimath/math/function/font_style/monospace.rb,
lib/plurimath/math/function/font_style/sans-serif.rb,
lib/plurimath/math/function/font_style/bold-italic.rb,
lib/plurimath/math/function/font_style/bold-script.rb,
lib/plurimath/math/function/font_style/bold-fraktur.rb,
lib/plurimath/math/function/font_style/double_struck.rb,
lib/plurimath/math/function/font_style/bold-sans-serif.rb,
lib/plurimath/math/function/font_style/sans-serif-italic.rb,
lib/plurimath/math/function/font_style/sans-serif-bold-italic.rb

Defined Under Namespace

Classes: Bold, BoldFraktur, BoldItalic, BoldSansSerif, BoldScript, DoubleStruck, Fraktur, Italic, Monospace, Normal, SansSerif, SansSerifBoldItalic, SansSerifItalic, Script

Constant Summary

Constants inherited from Core

Core::REPLACABLES

Instance Attribute Summary

Attributes inherited from BinaryFunction

#hide_function_name, #parameter_one, #parameter_two

Instance Method Summary collapse

Methods inherited from BinaryFunction

#==, #all_values_exist?, #any_value_exist?, #initialize

Methods inherited from Core

#ascii_fields_to_print, #class_name, #cloned_objects, #common_math_zone_conversion, #dump_mathml, #dump_nodes, #dump_omml, #dump_ox_nodes, #empty_tag, #filtered_values, #font_style_t_tag, #get, #gsub_spacing, #insert_t_tag, #invert_unicode_symbols, #is_unary?, #latex_fields_to_print, #linebreak, #mathml_fields_to_print, #nary_attr_value, #omml_fields_to_print, #omml_nodes, #omml_parameter, #omml_tag_name, #ox_element, #r_element, #replacable_values, #result, #separate_table, #set, #tag_name, #updated_object_values, #validate_mathml_fields, #variable_value, #variables

Constructor Details

This class inherits a constructor from Plurimath::Math::Function::BinaryFunction

Instance Method Details

#extract_class_name_from_textObject



40
41
42
43
# File 'lib/plurimath/math/function/font_style.rb', line 40

def extract_class_name_from_text
  parameter_one.parameter_one if parameter_one.is_a?(Text)
  parameter_one.class_name
end

#extractable?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/plurimath/math/function/font_style.rb', line 45

def extractable?
  parameter_one.is_a?(Text)
end

#font_styles(display_style, sty: "p", scr: nil) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/plurimath/math/function/font_style.rb', line 49

def font_styles(display_style, sty: "p", scr: nil)
  r_tag = Utility.ox_element("r", namespace: "m")
  rpr_tag = Utility.ox_element("rPr", namespace: "m")
  rpr_tag << Utility.ox_element("scr", namespace: "m", attributes: { "m:val": scr }) if scr
  rpr_tag << Utility.ox_element("sty", namespace: "m", attributes: { "m:val": sty }) if sty
  Utility.update_nodes(
    (r_tag << rpr_tag),
    Array(parameter_one&.font_style_t_tag(display_style)),
  )
  [r_tag]
end

#line_breaking(obj) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/plurimath/math/function/font_style.rb', line 106

def line_breaking(obj)
  parameter_one&.line_breaking(obj)
  return unless obj.value_exist?

  obj.update(
    self.class.new(
      Utility.filter_values(obj.value),
      self.parameter_two,
    )
  )
end

#omml_and_mathml_font_familyObject



101
102
103
104
# File 'lib/plurimath/math/function/font_style.rb', line 101

def omml_and_mathml_font_family
  fonts = Utility::FONT_STYLES.select { |_font, font_class| font_class == self.class }.keys.map(&:to_s)
  Omml::Parser::SUPPORTED_FONTS.values.find { |value| fonts.include?(value) }
end

#to_asciimathObject



9
10
11
# File 'lib/plurimath/math/function/font_style.rb', line 9

def to_asciimath
  parameter_one&.to_asciimath
end

#to_asciimath_math_zone(spacing, last = false, _) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/plurimath/math/function/font_style.rb', line 61

def to_asciimath_math_zone(spacing, last = false, _)
  new_spacing = gsub_spacing(spacing, last)
  new_arr = [
    "#{spacing}\"#{to_asciimath}\" function apply\n",
    "#{new_spacing}|_ \"#{parameter_two}\" font family\n",
  ]
  ascii_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "|  |_ " , array: new_arr })
  new_arr
end

#to_htmlObject



28
29
30
# File 'lib/plurimath/math/function/font_style.rb', line 28

def to_html
  parameter_one&.to_html
end

#to_latexObject



32
33
34
# File 'lib/plurimath/math/function/font_style.rb', line 32

def to_latex
  parameter_one&.to_latex
end

#to_latex_math_zone(spacing, last = false, _) ⇒ Object



71
72
73
74
75
76
77
78
79
# File 'lib/plurimath/math/function/font_style.rb', line 71

def to_latex_math_zone(spacing, last = false, _)
  new_spacing = gsub_spacing(spacing, last)
  new_arr = [
    "#{spacing}\"#{to_latex}\" function apply\n",
    "#{new_spacing}|_ \"#{parameter_two}\" font family\n",
  ]
  latex_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "|  |_ " , array: new_arr })
  new_arr
end

#to_mathml_math_zone(spacing, last = false, _) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/plurimath/math/function/font_style.rb', line 81

def to_mathml_math_zone(spacing, last = false, _)
  new_spacing = gsub_spacing(spacing, last)
  new_arr = [
    "#{spacing}\"#{dump_mathml(self)}\" function apply\n",
    "#{new_spacing}|_ \"#{omml_and_mathml_font_family}\" font family\n",
  ]
  mathml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "|  |_ ", array: new_arr })
  new_arr
end

#to_mathml_without_math_tagObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/plurimath/math/function/font_style.rb', line 13

def to_mathml_without_math_tag
  first_value = parameter_one&.to_mathml_without_math_tag
  Utility.update_nodes(
    Utility.ox_element(
      "mstyle",
      attributes: { mathvariant: parameter_two },
    ),
    [first_value],
  )
end

#to_omml_math_zone(spacing, last = false, _, display_style:) ⇒ Object



91
92
93
94
95
96
97
98
99
# File 'lib/plurimath/math/function/font_style.rb', line 91

def to_omml_math_zone(spacing, last = false, _, display_style:)
  new_spacing = gsub_spacing(spacing, last)
  new_arr = [
    "#{spacing}\"#{dump_omml(self, display_style)}\" function apply\n",
    "#{new_spacing}|_ \"#{omml_and_mathml_font_family}\" font family\n",
  ]
  omml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "|  |_ ", array: new_arr, display_style: display_style })
  new_arr
end

#to_omml_without_math_tag(display_style) ⇒ Object



24
25
26
# File 'lib/plurimath/math/function/font_style.rb', line 24

def to_omml_without_math_tag(display_style)
  font_styles(display_style)
end

#validate_function_formulaObject



36
37
38
# File 'lib/plurimath/math/function/font_style.rb', line 36

def validate_function_formula
  true
end