Class: Processing::Font

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

Overview

Font object.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.listString

Returns available font names

Returns:

  • (String)

    font names

See Also:



51
52
53
# File 'lib/processing/font.rb', line 51

def self.list()
  Rays::Font.families.values.flatten
end

Instance Method Details

#inspectString

Returns a string containing a human-readable representation of object.

Returns:

  • (String)

    inspected text



41
42
43
# File 'lib/processing/font.rb', line 41

def inspect()
  "#<Processing::Font: name:'#{@font.name}' size:#{@font.size}>"
end

#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:

See Also:



32
33
34
35
# File 'lib/processing/font.rb', line 32

def textBounds(str, x = 0, y = 0, fontSize = nil)
  font = getInternal__ fontSize
  TextBounds.new x, y, x + font.width(str), y + font.height
end