Class: RubySketch::Processing::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/rubysketch/processing.rb

Overview

Font object.

Instance Method Summary collapse

Instance Method Details

#textBounds(str) ⇒ TextBounds #textBounds(str, x, y) ⇒ TextBounds #textBounds(str, x, y, fontSize) ⇒ TextBounds

Returns bounding box.

Parameters:

  • str (String)

    text to calculate bounding box

  • x (Numeric) (defaults to: 0)

    horizontal position of bounding box

  • y (Numeric) (defaults to: 0)

    vertical position of bounding box

  • fontSize (Numeric) (defaults to: nil)

    font size

Returns:



671
672
673
674
# File 'lib/rubysketch/processing.rb', line 671

def textBounds(str, x = 0, y = 0, fontSize = nil)
  f = fontSize ? Rays::Font.new(@font.name, fontSize) : @font
  TextBounds.new x, y, x + f.width(str), y + f.height
end