Class: Uniword::Drawingml::FontScheme

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/drawingml/font_scheme.rb

Overview

Represents a font scheme from a Word document theme.

Font schemes define the major (heading) and minor (body) fonts used throughout the document.

Examples:

Create a custom font scheme

scheme = Uniword::FontScheme.new
scheme.major_font = 'Helvetica'
scheme.minor_font = 'Arial'

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ FontScheme

Initialize font scheme

Parameters:

  • attributes (Hash) (defaults to: {})

    Font scheme attributes



148
149
150
151
152
# File 'lib/uniword/drawingml/font_scheme.rb', line 148

def initialize(attributes = {})
  super
  @major_font_obj ||= MajorFont.new
  @minor_font_obj ||= MinorFont.new
end

Instance Method Details

#dupFontScheme

Duplicate the font scheme

Returns:

  • (FontScheme)

    A deep copy of this font scheme



229
230
231
232
233
234
235
236
237
238
# File 'lib/uniword/drawingml/font_scheme.rb', line 229

def dup
  new_scheme = FontScheme.new(name: name)
  new_scheme.major_font = major_font
  new_scheme.minor_font = minor_font
  new_scheme.major_east_asian = major_east_asian if major_east_asian
  new_scheme.major_complex_script = major_complex_script if major_complex_script
  new_scheme.minor_east_asian = minor_east_asian if minor_east_asian
  new_scheme.minor_complex_script = minor_complex_script if minor_complex_script
  new_scheme
end

#major_complex_scriptObject

Get major complex script font



191
192
193
# File 'lib/uniword/drawingml/font_scheme.rb', line 191

def major_complex_script
  @major_font_obj&.cs&.typeface
end

#major_complex_script=(typeface) ⇒ Object

Set major complex script font



196
197
198
199
200
# File 'lib/uniword/drawingml/font_scheme.rb', line 196

def major_complex_script=(typeface)
  @major_font_obj ||= MajorFont.new
  @major_font_obj.cs ||= CsFont.new
  @major_font_obj.cs.typeface = typeface
end

#major_east_asianObject

Get major East Asian font



179
180
181
# File 'lib/uniword/drawingml/font_scheme.rb', line 179

def major_east_asian
  @major_font_obj&.ea&.typeface
end

#major_east_asian=(typeface) ⇒ Object

Set major East Asian font



184
185
186
187
188
# File 'lib/uniword/drawingml/font_scheme.rb', line 184

def major_east_asian=(typeface)
  @major_font_obj ||= MajorFont.new
  @major_font_obj.ea ||= EaFont.new
  @major_font_obj.ea.typeface = typeface
end

#major_fontObject

Get major font name (compatibility accessor)



155
156
157
# File 'lib/uniword/drawingml/font_scheme.rb', line 155

def major_font
  @major_font_obj&.latin&.typeface
end

#major_font=(typeface) ⇒ Object

Set major font name (compatibility accessor)



160
161
162
163
164
# File 'lib/uniword/drawingml/font_scheme.rb', line 160

def major_font=(typeface)
  @major_font_obj ||= MajorFont.new
  @major_font_obj.latin ||= LatinFont.new
  @major_font_obj.latin.typeface = typeface
end

#minor_complex_scriptObject

Get minor complex script font



215
216
217
# File 'lib/uniword/drawingml/font_scheme.rb', line 215

def minor_complex_script
  @minor_font_obj&.cs&.typeface
end

#minor_complex_script=(typeface) ⇒ Object

Set minor complex script font



220
221
222
223
224
# File 'lib/uniword/drawingml/font_scheme.rb', line 220

def minor_complex_script=(typeface)
  @minor_font_obj ||= MinorFont.new
  @minor_font_obj.cs ||= CsFont.new
  @minor_font_obj.cs.typeface = typeface
end

#minor_east_asianObject

Get minor East Asian font



203
204
205
# File 'lib/uniword/drawingml/font_scheme.rb', line 203

def minor_east_asian
  @minor_font_obj&.ea&.typeface
end

#minor_east_asian=(typeface) ⇒ Object

Set minor East Asian font



208
209
210
211
212
# File 'lib/uniword/drawingml/font_scheme.rb', line 208

def minor_east_asian=(typeface)
  @minor_font_obj ||= MinorFont.new
  @minor_font_obj.ea ||= EaFont.new
  @minor_font_obj.ea.typeface = typeface
end

#minor_fontObject

Get minor font name (compatibility accessor)



167
168
169
# File 'lib/uniword/drawingml/font_scheme.rb', line 167

def minor_font
  @minor_font_obj&.latin&.typeface
end

#minor_font=(typeface) ⇒ Object

Set minor font name (compatibility accessor)



172
173
174
175
176
# File 'lib/uniword/drawingml/font_scheme.rb', line 172

def minor_font=(typeface)
  @minor_font_obj ||= MinorFont.new
  @minor_font_obj.latin ||= LatinFont.new
  @minor_font_obj.latin.typeface = typeface
end