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
Direct Known Subclasses
Bold, BoldFraktur, BoldItalic, BoldSansSerif, BoldScript, DoubleStruck, Fraktur, Italic, Monospace, Normal, SansSerif, SansSerifBoldItalic, SansSerifItalic, Script
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::ALL_PARAMETERS, Core::REPLACABLES
Instance Attribute Summary
#hide_function_name, #parameter_one, #parameter_two
Instance Method Summary
collapse
-
#extract_class_name_from_text ⇒ Object
-
#extractable? ⇒ Boolean
-
#font_classes(object = self) ⇒ Object
-
#font_family(unicode: false, omml: false, mathml: false) ⇒ Object
-
#font_styles(display_style, sty: "p", scr: nil, options:) ⇒ Object
-
#line_breaking(obj) ⇒ Object
-
#parameter_to_class ⇒ Object
-
#supported_fonts(fonts_array = [], unicode: false, omml: false, mathml: false) ⇒ Object
-
#to_asciimath(options:) ⇒ Object
-
#to_asciimath_math_zone(spacing, last = false, _, options:) ⇒ Object
-
#to_html(options:) ⇒ Object
-
#to_latex(options:) ⇒ Object
-
#to_latex_math_zone(spacing, last = false, _, options:) ⇒ Object
-
#to_mathml_math_zone(spacing, last = false, _, options:) ⇒ Object
-
#to_mathml_without_math_tag(intent, options:) ⇒ Object
-
#to_omml_math_zone(spacing, last = false, _, display_style:, options:) ⇒ Object
-
#to_omml_without_math_tag(display_style, options:) ⇒ Object
-
#to_unicodemath(options:) ⇒ Object
-
#to_unicodemath_math_zone(spacing, last = false, _, options:) ⇒ Object
-
#validate_function_formula ⇒ Object
#==, #all_values_exist?, #any_value_exist?, #initialize
Methods inherited from Core
#ascii_fields_to_print, #class_name, #cloned_objects, #common_math_zone_conversion, descendants, #dump_mathml, #dump_nodes, #dump_omml, #dump_ox_nodes, #empty_tag, #filtered_values, #font_style_t_tag, #get, #gsub_spacing, inherited, #insert_t_tag, #invert_unicode_symbols, #is_binary_function?, #is_mrow?, #is_mstyle?, #is_nary_function?, #is_nary_symbol?, #is_ternary_function?, #is_unary?, #latex_fields_to_print, #linebreak?, #mathml_fields_to_print, #mini_sized?, #nary_attr_value, #nary_intent_name, #omml_fields_to_print, #omml_nodes, #omml_parameter, #omml_tag_name, #ox_element, #paren?, #pretty_print_instance_variables, #prime_unicode?, #r_element, #replacable_values, #result, #separate_table, #set, #symbol?, #tag_name, #to_ms_value, #unicodemath_fields_to_print, #unicodemath_parens, #updated_object_values, #validate_mathml_fields, #variable_value, #variables
Instance Method Details
44
45
46
47
|
# File 'lib/plurimath/math/function/font_style.rb', line 44
def
parameter_one.parameter_one if parameter_one.is_a?(Text)
parameter_one.class_name
end
|
49
50
51
|
# File 'lib/plurimath/math/function/font_style.rb', line 49
def
parameter_one.is_a?(Text)
end
|
#font_classes(object = self) ⇒ Object
145
146
147
|
# File 'lib/plurimath/math/function/font_style.rb', line 145
def font_classes(object = self)
Utility::FONT_STYLES.select { |_font, font_class| font_class == object.class }.keys.map(&:to_s)
end
|
#font_family(unicode: false, omml: false, mathml: false) ⇒ Object
105
106
107
108
109
|
# File 'lib/plurimath/math/function/font_style.rb', line 105
def font_family(unicode: false, omml: false, mathml: false)
fonts = font_classes
fonts = font_classes(parameter_to_class) if fonts.empty?
supported_fonts(fonts, unicode: unicode, omml: omml, mathml: mathml)
end
|
#font_styles(display_style, sty: "p", scr: nil, options:) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/plurimath/math/function/font_style.rb', line 53
def font_styles(display_style, sty: "p", scr: nil, options:)
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, options: options)),
)
[r_tag]
end
|
#line_breaking(obj) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/plurimath/math/function/font_style.rb', line 133
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
|
#parameter_to_class ⇒ Object
149
150
151
|
# File 'lib/plurimath/math/function/font_style.rb', line 149
def parameter_to_class
Utility::FONT_STYLES.select { |font, _font_class| font == parameter_two.to_sym }&.values&.first&.new('')
end
|
#supported_fonts(fonts_array = [], unicode: false, omml: false, mathml: false) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/plurimath/math/function/font_style.rb', line 111
def supported_fonts(fonts_array = [], unicode: false, omml: false, mathml: false)
if unicode
font = UnicodeMath::Constants::FONTS_CLASSES.find { |value| fonts_array.include?(value) }
return "\\#{font}" if font
end
return Omml::Parser::SUPPORTED_FONTS.values.find { |value| fonts_array.include?(value) } if omml
if mathml
Mathml::Constants::SUPPORTED_FONT_STYLES.find { |string, object| fonts_array.include?(string.to_s) }&.first ||
parameter_two
end
end
|
#to_asciimath(options:) ⇒ Object
9
10
11
|
# File 'lib/plurimath/math/function/font_style.rb', line 9
def to_asciimath(options:)
parameter_one&.to_asciimath(options: options)
end
|
#to_asciimath_math_zone(spacing, last = false, _, options:) ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'lib/plurimath/math/function/font_style.rb', line 65
def to_asciimath_math_zone(spacing, last = false, _, options:)
new_spacing = gsub_spacing(spacing, last)
new_arr = [
"#{spacing}\"#{to_asciimath(options: options)}\" 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, options: options })
new_arr
end
|
#to_html(options:) ⇒ Object
28
29
30
|
# File 'lib/plurimath/math/function/font_style.rb', line 28
def to_html(options:)
parameter_one&.to_html(options: options)
end
|
#to_latex(options:) ⇒ Object
32
33
34
|
# File 'lib/plurimath/math/function/font_style.rb', line 32
def to_latex(options:)
parameter_one&.to_latex(options: options)
end
|
#to_latex_math_zone(spacing, last = false, _, options:) ⇒ Object
75
76
77
78
79
80
81
82
83
|
# File 'lib/plurimath/math/function/font_style.rb', line 75
def to_latex_math_zone(spacing, last = false, _, options:)
new_spacing = gsub_spacing(spacing, last)
new_arr = [
"#{spacing}\"#{to_latex(options: options)}\" 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, options: options })
new_arr
end
|
#to_mathml_math_zone(spacing, last = false, _, options:) ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/plurimath/math/function/font_style.rb', line 85
def to_mathml_math_zone(spacing, last = false, _, options:)
new_spacing = gsub_spacing(spacing, last)
new_arr = [
"#{spacing}\"#{dump_mathml(self, options: options)}\" function apply\n",
"#{new_spacing}|_ \"#{font_family(mathml: true)}\" font family\n",
]
mathml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr, options: options })
new_arr
end
|
#to_mathml_without_math_tag(intent, options:) ⇒ Object
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(intent, options:)
first_value = parameter_one&.to_mathml_without_math_tag(intent, options: options)
Utility.update_nodes(
Utility.ox_element(
"mstyle",
attributes: { mathvariant: font_family(mathml: true) },
),
[first_value],
)
end
|
#to_omml_math_zone(spacing, last = false, _, display_style:, options:) ⇒ Object
95
96
97
98
99
100
101
102
103
|
# File 'lib/plurimath/math/function/font_style.rb', line 95
def to_omml_math_zone(spacing, last = false, _, display_style:, options:)
new_spacing = gsub_spacing(spacing, last)
new_arr = [
"#{spacing}\"#{dump_omml(self, display_style, options: options)}\" function apply\n",
"#{new_spacing}|_ \"#{font_family(omml: true)}\" font family\n",
]
omml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr, display_style: display_style, options: options })
new_arr
end
|
#to_omml_without_math_tag(display_style, options:) ⇒ Object
24
25
26
|
# File 'lib/plurimath/math/function/font_style.rb', line 24
def to_omml_without_math_tag(display_style, options:)
font_styles(display_style, options: options)
end
|
#to_unicodemath(options:) ⇒ Object
36
37
38
|
# File 'lib/plurimath/math/function/font_style.rb', line 36
def to_unicodemath(options:)
"#{font_family(unicode: true)}#{parameter_one&.to_unicodemath(options: options)}"
end
|
#to_unicodemath_math_zone(spacing, last = false, _, options:) ⇒ Object
123
124
125
126
127
128
129
130
131
|
# File 'lib/plurimath/math/function/font_style.rb', line 123
def to_unicodemath_math_zone(spacing, last = false, _, options:)
new_spacing = gsub_spacing(spacing, last)
new_arr = [
"#{spacing}\"#{dump_unicodemath(self, options: options)}\" function apply\n",
"#{new_spacing}|_ \"#{font_family(unicode: true, options: options)}\" font family\n",
]
unicodemath_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr, options: options })
new_arr
end
|
40
41
42
|
# File 'lib/plurimath/math/function/font_style.rb', line 40
def validate_function_formula
true
end
|