Font.hpp
Go to the documentation of this file.
1 
4 #ifndef GOSU_FONT_HPP
5 #define GOSU_FONT_HPP
6 
7 #include <Gosu/Fwd.hpp>
8 #include <Gosu/Color.hpp>
9 #include <Gosu/GraphicsBase.hpp>
10 #include <Gosu/Platform.hpp>
11 #include <Gosu/TR1.hpp>
12 #include <string>
13 
14 namespace Gosu
15 {
20  class Font
21  {
22  struct Impl;
23  std::tr1::shared_ptr<Impl> pimpl;
24 
25  public:
32  Font(Graphics& graphics, const std::wstring& fontName,
33  unsigned fontHeight, unsigned fontFlags = ffBold);
34 
36  std::wstring name() const;
37 
39  unsigned height() const;
40 
42  unsigned flags() const;
43 
45  double textWidth(const std::wstring& text, double factorX = 1) const;
46 
49  void draw(const std::wstring& text, double x, double y, ZPos z,
50  double factorX = 1, double factorY = 1,
51  Color c = Color::WHITE, AlphaMode mode = amDefault) const;
52 
59  void drawRel(const std::wstring& text, double x, double y, ZPos z,
60  double relX, double relY, double factorX = 1, double factorY = 1,
61  Color c = Color::WHITE, AlphaMode mode = amDefault) const;
62 
67  void setImage(wchar_t wc, unsigned fontFlags, const Gosu::Image& image);
70  void setImage(wchar_t wc, const Gosu::Image& image);
71 
72  #ifndef SWIG
74  #endif
75  void drawRot(const std::wstring& text, double x, double y, ZPos z, double angle,
78  double factorX = 1, double factorY = 1,
79  Color c = Color::WHITE, AlphaMode mode = amDefault) const;
80  };
81 }
82 
83 #endif
Includes all parts of C++03 (TR1) that are relevant for Gosu.
#define GOSU_DEPRECATED
Definition: Platform.hpp:85
void setImage(wchar_t wc, unsigned fontFlags, const Gosu::Image &image)
Maps a letter to a specific image instead of generating one using Gosu&#39;s built-in text rendering...
Contains declarations of all of Gosu&#39;s available classes.
Represents an RGBA color value with 8 bits for each channel.
Definition: Color.hpp:18
double textWidth(const std::wstring &text, double factorX=1) const
Returns the width, in pixels, the given text would occupy if drawn.
unsigned flags() const
Returns the flags used to create the font characters.
GOSU_DEPRECATED void drawRot(const std::wstring &text, double x, double y, ZPos z, double angle, double factorX=1, double factorY=1, Color c=Color::WHITE, AlphaMode mode=amDefault) const
DEPRECATED: Analogous to draw, but rotates the text by a given angle.
double ZPos
Represents the Z position of something drawn with Gosu&#39;s graphics system.
A font can be used to draw text on a Graphics object very flexibly.
Definition: Font.hpp:20
The color&#39;s channels will be interpolated.
void draw(const std::wstring &text, double x, double y, ZPos z, double factorX=1, double factorY=1, Color c=Color::WHITE, AlphaMode mode=amDefault) const
Draws text so the top left corner of the text is at (x; y).
Font(Graphics &graphics, const std::wstring &fontName, unsigned fontHeight, unsigned fontFlags=ffBold)
Constructs a font that can be drawn onto the graphics object.
Macros and utility functions to facilitate programming on all of Gosu&#39;s supported platforms...
Serves as the target of all drawing and provides primitive drawing functionality. ...
Definition: Graphics.hpp:49
std::wstring name() const
Returns the name of the font that was used to create it.
AlphaMode
Determines the way colors are combined when one is drawn onto another.
Interface of the Color class.
Provides functionality for drawing rectangular images.
Definition: Image.hpp:17
void drawRel(const std::wstring &text, double x, double y, ZPos z, double relX, double relY, double factorX=1, double factorY=1, Color c=Color::WHITE, AlphaMode mode=amDefault) const
Draws text at a position relative to (x; y).
static const Color WHITE
Definition: Color.hpp:150
double angle(double fromX, double fromY, double toX, double toY, double def=0)
Returns the angle from point 1 to point 2 in degrees, where 0.0 means upwards.
unsigned height() const
Returns the height of the font, in pixels.
Contains general typedefs and enums related to graphics.