lib/ray/font.rb in ray-0.1.0.pre1 vs lib/ray/font.rb in ray-0.1.0
- old
+ new
@@ -1,50 +1,8 @@
-# -*- coding: utf-8 -*-
-
module Ray
class Font
include Ray::TextHelper
extend Ray::ResourceSet
add_set(/^(.*)$/) { |filename| new(filename) }
-
- # @param [String] string The string which should be drawn.
- #
- # @option opts [Integer] :size Size of the font
- # @option opts [String, nil] :encoding Encoding of the text. Guessed in
- # Ruby 1.9, assumes UTF-8 otherwise.
- # @option opts [Integer, Array<Symbol>] :style Flags for the font style.
- # Valid symbols are :normal, :italic, :bold, and :underline.
- # @option opts [Ray::Color] :color Color to draw the text in. Defaults to
- # white.
- # @option opts [Ray::Image] :on The image to draw on. In this case,
- # it will directly draw instead of returning an image containing nothing
- # but the drawn text.
- # @option opts [Ray::Vector2, #to_vector2] :to or :at where to draw on the image.
- # @return The surface it drew the string on.
- def draw(string, opts)
- enc = opts[:encoding] || (string.respond_to?(:encoding) && string.encoding.to_s)
- enc ||= "UTF-8"
-
- opts[:style] = parse_style(opts[:style])
-
- simple_draw internal_string(string, enc), opts
- end
-
- # @param [Hash] opts (See #draw)
- # @return [Ray::Vector2] Size of the text using this font.
- def size_of(string, opts)
- enc = opts[:encoding] || (string.respond_to?(:encoding) && string.encoding.to_s)
- enc ||= "UTF-8"
-
- opts[:style] = parse_style(opts[:style])
-
- simple_size_of internal_string(string, enc), opts
- end
-
- # @return [Integer] Width required to draw the sring with this font.
- # @see #size_of
- def width_of(string, opts)
- size_of(string, opts).width
- end
end
end