Class: Magick::RVG::Utility::TextAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/rvg/misc.rb

Constant Summary collapse

WRITING_MODE =
%w[lr-tb lr rl-tb rl tb-rl tb]

Instance Method Summary collapse

Constructor Details

#initializeTextAttributes

Returns a new instance of TextAttributes.



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/rvg/misc.rb', line 318

def initialize
  @affine = []
  @affine << Magick::AffineMatrix.new(1, 0, 0, 1, 0, 0)
  @baseline_shift = []
  @baseline_shift << :baseline
  @glyph_orientation_horizontal = []
  @glyph_orientation_horizontal << 0
  @glyph_orientation_vertical = []
  @glyph_orientation_vertical << 90
  @letter_spacing = []
  @letter_spacing << 0
  @text_anchor = []
  @text_anchor << :start
  @word_spacing = []
  @word_spacing << 0
  @writing_mode = []
  @writing_mode << 'lr-tb'
end

Instance Method Details

#affineObject



368
369
370
# File 'lib/rvg/misc.rb', line 368

def affine
  @affine[-1]
end

#baseline_shiftObject



372
373
374
# File 'lib/rvg/misc.rb', line 372

def baseline_shift
  @baseline_shift[-1]
end

#baseline_shift=(value) ⇒ Object



376
377
378
# File 'lib/rvg/misc.rb', line 376

def baseline_shift=(value)
  @baseline_shift[-1] = value
end

#glyph_orientation_horizontalObject



396
397
398
# File 'lib/rvg/misc.rb', line 396

def glyph_orientation_horizontal
  @glyph_orientation_horizontal[-1]
end

#glyph_orientation_horizontal=(angle) ⇒ Object



400
401
402
# File 'lib/rvg/misc.rb', line 400

def glyph_orientation_horizontal=(angle)
  @glyph_orientation_horizontal[-1] = angle
end

#glyph_orientation_verticalObject



388
389
390
# File 'lib/rvg/misc.rb', line 388

def glyph_orientation_vertical
  @glyph_orientation_vertical[-1]
end

#glyph_orientation_vertical=(angle) ⇒ Object



392
393
394
# File 'lib/rvg/misc.rb', line 392

def glyph_orientation_vertical=(angle)
  @glyph_orientation_vertical[-1] = angle
end

#letter_spacingObject



404
405
406
# File 'lib/rvg/misc.rb', line 404

def letter_spacing
  @letter_spacing[-1]
end

#letter_spacing=(value) ⇒ Object



408
409
410
# File 'lib/rvg/misc.rb', line 408

def letter_spacing=(value)
  @letter_spacing[-1] = value
end

#non_default?Boolean

Returns:

  • (Boolean)


412
413
414
415
416
# File 'lib/rvg/misc.rb', line 412

def non_default?
  @baseline_shift[-1] != :baseline || @letter_spacing[-1] != 0 ||
    @word_spacing[-1] != 0 || @writing_mode[-1][/\Alr/].nil? ||
    @glyph_orientation_horizontal[-1] != 0
end

#popObject



348
349
350
351
352
353
354
355
356
357
# File 'lib/rvg/misc.rb', line 348

def pop
  @affine.pop
  @baseline_shift.pop
  @text_anchor.pop
  @writing_mode.pop
  @glyph_orientation_vertical.pop
  @glyph_orientation_horizontal.pop
  @letter_spacing.pop
  @word_spacing.pop
end

#pushObject



337
338
339
340
341
342
343
344
345
346
# File 'lib/rvg/misc.rb', line 337

def push
  @affine.push(@affine.last.dup)
  @baseline_shift.push(@baseline_shift.last)
  @text_anchor.push(@text_anchor.last)
  @writing_mode.push(@writing_mode.last.dup)
  @glyph_orientation_vertical.push(@glyph_orientation_vertical.last)
  @glyph_orientation_horizontal.push(@glyph_orientation_horizontal.last)
  @letter_spacing.push(@letter_spacing.last)
  @word_spacing.push(@word_spacing.last)
end

#set_affine(sx, rx, ry, sy, tx, ty) ⇒ Object



359
360
361
362
363
364
365
366
# File 'lib/rvg/misc.rb', line 359

def set_affine(sx, rx, ry, sy, tx, ty)
  @affine[-1].sx = sx
  @affine[-1].rx = rx
  @affine[-1].ry = ry
  @affine[-1].sy = sy
  @affine[-1].tx = tx
  @affine[-1].ty = ty
end

#text_anchorObject



380
381
382
# File 'lib/rvg/misc.rb', line 380

def text_anchor
  @text_anchor[-1]
end

#text_anchor=(anchor) ⇒ Object



384
385
386
# File 'lib/rvg/misc.rb', line 384

def text_anchor=(anchor)
  @text_anchor[-1] = anchor
end

#word_spacingObject



418
419
420
# File 'lib/rvg/misc.rb', line 418

def word_spacing
  @word_spacing[-1]
end

#word_spacing=(value) ⇒ Object



422
423
424
# File 'lib/rvg/misc.rb', line 422

def word_spacing=(value)
  @word_spacing[-1] = value
end

#writing_modeObject



426
427
428
# File 'lib/rvg/misc.rb', line 426

def writing_mode
  @writing_mode[-1]
end

#writing_mode=(mode) ⇒ Object



430
431
432
# File 'lib/rvg/misc.rb', line 430

def writing_mode=(mode)
  @writing_mode[-1] = WRITING_MODE.include?(mode) ? mode : 'lr-tb'
end