Class: GD2::Font

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

Overview

Description

Font objects represent a particular font in a particular size.

Built-in Fonts

The following font classes may be used without further instantiation:

Font::Tiny
Font::Small
Font::MediumBold
Font::Large
Font::Giant

TrueType Fonts

To use a TrueType font, first instantiate the font at a particular size:

font = Font::TrueType[fontname, ptsize]

Here fontname may be a path to a TrueType font, or a fontconfig pattern if fontconfig support is enabled (see Font::TrueType.fontconfig).

See Font::TrueType.new for further options.

Direct Known Subclasses

Giant, Large, MediumBold, Small, Tiny

Defined Under Namespace

Classes: Giant, Large, MediumBold, Small, Tiny, TrueType

Class Method Summary collapse

Class Method Details

.draw(image_ptr, x, y, angle, string, fg) ⇒ Object

:nodoc:

Raises:

  • (ArgumentError)


56
57
58
59
60
61
62
63
# File 'lib/gd2/font.rb', line 56

def self.draw(image_ptr, x, y, angle, string, fg)   #:nodoc:
  raise ArgumentError, "Angle #{angle} not supported for #{self}" unless
    angle == 0.degrees || angle == 90.degrees

  GD2FFI.send(angle > 0 ? :gdImageStringUp : :gdImageString, image_ptr,
    font_ptr, x.to_i, y.to_i, string, fg.to_i)
  nil
end

.font_ptrObject

:nodoc:



52
53
54
# File 'lib/gd2/font.rb', line 52

def self.font_ptr   #:nodoc:
  GD2FFI.send(font_sym)
end