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

Instance Attribute Summary

Attributes inherited from BinaryFunction

#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, #common_math_zone_conversion, #dump_mathml, #dump_omml, #dump_ox_nodes, #empty_tag, #filtered_values, #font_style_t_tag, #gsub_spacing, #insert_t_tag, #invert_unicode_symbols, #latex_fields_to_print, #mathml_fields_to_print, #nary_attr_value, #omml_fields_to_print, #omml_nodes, #omml_parameter, #omml_tag_name, #r_element, #tag_name, #validate_mathml_fields

Constructor Details

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

Instance Method Details

#extract_class_from_textObject



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

def extract_class_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
60
61
# 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")
  fonts   = []
  fonts << Utility.ox_element("scr", namespace: "m", attributes: { "m:val": scr }) if scr
  fonts << Utility.ox_element("sty", namespace: "m", attributes: { "m:val": sty }) if sty
  r_tag << Utility.update_nodes(rpr_tag, fonts)
  Utility.update_nodes(
    r_tag,
    Array(parameter_one.font_style_t_tag(display_style)),
  )
  [r_tag]
end

#omml_and_mathml_font_familyObject



103
104
105
106
# File 'lib/plurimath/math/function/font_style.rb', line 103

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



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

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



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

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



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

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



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

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