Method: Processing::GraphicsContext#textFont

Defined in:
lib/processing/graphics_context.rb

#textFontFont #textFont(font) ⇒ Font #textFont(name) ⇒ Font #textFont(font, size) ⇒ Font #textFont(name, size) ⇒ Font

Sets text font. (Passing a font name as the first parameter is deprecated)

Parameters:

  • font (Font) (defaults to: nil)

    font

  • name (String)

    font name

  • size (Numeric) (defaults to: nil)

    font size (max 256)

Returns:

  • (Font)

    current font

See Also:



1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
# File 'lib/processing/graphics_context.rb', line 1231

def textFont(font = nil, size = nil)
  if font != nil || size != nil
    size = FONT_SIZE_MAX__ if size && size > FONT_SIZE_MAX__
    if font.nil? || font.kind_of?(String)
      font = createFont font, size
    elsif size
      font.setSize__ size
    end
    @painter__.font = font.getInternal__
    @textFont__     = font
  end
  @textFont__
end