Class: Magick::RVG::Utility::TextAttributes
- Inherits:
-
Object
- Object
- Magick::RVG::Utility::TextAttributes
- Defined in:
- lib/rvg/misc.rb
Constant Summary collapse
- WRITING_MODE =
%w[lr-tb lr rl-tb rl tb-rl tb].freeze
Instance Method Summary collapse
- #affine ⇒ Object
- #baseline_shift ⇒ Object
- #baseline_shift=(value) ⇒ Object
- #glyph_orientation_horizontal ⇒ Object
- #glyph_orientation_horizontal=(angle) ⇒ Object
- #glyph_orientation_vertical ⇒ Object
- #glyph_orientation_vertical=(angle) ⇒ Object
-
#initialize ⇒ TextAttributes
constructor
A new instance of TextAttributes.
- #letter_spacing ⇒ Object
- #letter_spacing=(value) ⇒ Object
- #non_default? ⇒ Boolean
- #pop ⇒ Object
- #push ⇒ Object
- #set_affine(sx, rx, ry, sy, tx, ty) ⇒ Object
- #text_anchor ⇒ Object
- #text_anchor=(anchor) ⇒ Object
- #word_spacing ⇒ Object
- #word_spacing=(value) ⇒ Object
- #writing_mode ⇒ Object
- #writing_mode=(mode) ⇒ Object
Constructor Details
#initialize ⇒ TextAttributes
Returns a new instance of TextAttributes.
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/rvg/misc.rb', line 321 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
#affine ⇒ Object
371 372 373 |
# File 'lib/rvg/misc.rb', line 371 def affine @affine[-1] end |
#baseline_shift ⇒ Object
375 376 377 |
# File 'lib/rvg/misc.rb', line 375 def baseline_shift @baseline_shift[-1] end |
#baseline_shift=(value) ⇒ Object
379 380 381 |
# File 'lib/rvg/misc.rb', line 379 def baseline_shift=(value) @baseline_shift[-1] = value end |
#glyph_orientation_horizontal ⇒ Object
399 400 401 |
# File 'lib/rvg/misc.rb', line 399 def glyph_orientation_horizontal @glyph_orientation_horizontal[-1] end |
#glyph_orientation_horizontal=(angle) ⇒ Object
403 404 405 |
# File 'lib/rvg/misc.rb', line 403 def glyph_orientation_horizontal=(angle) @glyph_orientation_horizontal[-1] = angle end |
#glyph_orientation_vertical ⇒ Object
391 392 393 |
# File 'lib/rvg/misc.rb', line 391 def glyph_orientation_vertical @glyph_orientation_vertical[-1] end |
#glyph_orientation_vertical=(angle) ⇒ Object
395 396 397 |
# File 'lib/rvg/misc.rb', line 395 def glyph_orientation_vertical=(angle) @glyph_orientation_vertical[-1] = angle end |
#letter_spacing ⇒ Object
407 408 409 |
# File 'lib/rvg/misc.rb', line 407 def letter_spacing @letter_spacing[-1] end |
#letter_spacing=(value) ⇒ Object
411 412 413 |
# File 'lib/rvg/misc.rb', line 411 def letter_spacing=(value) @letter_spacing[-1] = value end |
#non_default? ⇒ Boolean
415 416 417 418 419 |
# File 'lib/rvg/misc.rb', line 415 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 |
#pop ⇒ Object
351 352 353 354 355 356 357 358 359 360 |
# File 'lib/rvg/misc.rb', line 351 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 |
#push ⇒ Object
340 341 342 343 344 345 346 347 348 349 |
# File 'lib/rvg/misc.rb', line 340 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
362 363 364 365 366 367 368 369 |
# File 'lib/rvg/misc.rb', line 362 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_anchor ⇒ Object
383 384 385 |
# File 'lib/rvg/misc.rb', line 383 def text_anchor @text_anchor[-1] end |
#text_anchor=(anchor) ⇒ Object
387 388 389 |
# File 'lib/rvg/misc.rb', line 387 def text_anchor=(anchor) @text_anchor[-1] = anchor end |
#word_spacing ⇒ Object
421 422 423 |
# File 'lib/rvg/misc.rb', line 421 def word_spacing @word_spacing[-1] end |
#word_spacing=(value) ⇒ Object
425 426 427 |
# File 'lib/rvg/misc.rb', line 425 def word_spacing=(value) @word_spacing[-1] = value end |
#writing_mode ⇒ Object
429 430 431 |
# File 'lib/rvg/misc.rb', line 429 def writing_mode @writing_mode[-1] end |
#writing_mode=(mode) ⇒ Object
433 434 435 |
# File 'lib/rvg/misc.rb', line 433 def writing_mode=(mode) @writing_mode[-1] = WRITING_MODE.include?(mode) ? mode : 'lr-tb' end |