#include <font.h>
Public Member Functions | |
virtual int | getFontHeight () const =0 |
virtual Common::String | getFontName () const |
virtual int | getFontAscent () const |
virtual int | getFontDescent () const |
virtual int | getFontLeading () const |
virtual int | getMaxCharWidth () const =0 |
virtual int | getCharWidth (uint32 chr) const =0 |
virtual int | getKerningOffset (uint32 left, uint32 right) const |
virtual Common::Rect | getBoundingBox (uint32 chr) const |
Common::Rect | getBoundingBox (const Common::String &str, int x=0, int y=0, const int w=0, TextAlign align=kTextAlignLeft, int deltax=0, bool useEllipsis=false) const |
Common::Rect | getBoundingBox (const Common::U32String &str, int x=0, int _y=0, const int w=0, TextAlign align=kTextAlignLeft, int deltax=0, bool useEllipsis=false) const |
virtual void | drawChar (Surface *dst, uint32 chr, int x, int y, uint32 color) const =0 |
virtual void | drawChar (ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const |
void | drawString (Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align=kTextAlignLeft, int deltax=0, bool useEllipsis=false) const |
void | drawString (Surface *dst, const Common::U32String &str, int x, int y, int w, uint32 color, TextAlign align=kTextAlignLeft, int deltax=0, bool useEllipsis=false) const |
void | drawString (ManagedSurface *dst, const Common::String &str, int x, int _y, int w, uint32 color, TextAlign align=kTextAlignLeft, int deltax=0, bool useEllipsis=false) const |
void | drawString (ManagedSurface *dst, const Common::U32String &str, int x, int y, int w, uint32 color, TextAlign align=kTextAlignLeft, int deltax=0, bool useEllipsis=false) const |
int | getStringWidth (const Common::String &str) const |
int | getStringWidth (const Common::U32String &str) const |
int | wordWrapText (const Common::String &str, int maxWidth, Common::Array< Common::String > &lines, int initWidth=0, uint32 mode=kWordWrapOnExplicitNewLines) const |
int | wordWrapText (const Common::U32String &str, int maxWidth, Common::Array< Common::U32String > &lines, int initWidth=0, uint32 mode=kWordWrapOnExplicitNewLines) const |
int | wordWrapText (const Common::U32String &str, int maxWidth, Common::Array< Common::U32String > &lines, Common::Array< bool > &lineContinuation, int initWidth=0, uint32 mode=kWordWrapOnExplicitNewLines) const |
void | scaleSingleGlyph (Surface *scaleSurface, int *grayScaleMap, int grayScaleMapSize, int width, int height, int xOffset, int yOffset, int grayLevel, int chr, int srcheight, int srcwidth, float scale) const |
Instances of this class represent a distinct font, with a built-in renderer.
|
pure virtual |
Return the height of the font.
Implemented in Graphics::MacFONTFont, Graphics::AmigaFont, Tetraedge::TeFont2, Graphics::BdfFont, Graphics::WinFont, BladeRunner::Font, MM::XeenFont, MM::BitmapFont, Dgds::DgdsFont, Nancy::Font, CryOmni3D::CryoExtFont, MutationOfJB::Font, CryOmni3D::CryoFont, Darkseed::GameFont, Freescape::Font, Prince::Font, and Groovie::T7GFont.
|
inlinevirtual |
Returns the font's name, if one is available
|
virtual |
Return the ascent of the font.
Reimplemented in Graphics::MacFONTFont, Graphics::BdfFont, and Graphics::WinFont.
|
virtual |
Return the descent of the font.
Reimplemented in Graphics::MacFONTFont.
|
virtual |
Return the leading of the font. This is the distance between the descent line and the ascent line below it.
Reimplemented in Graphics::MacFONTFont.
|
pure virtual |
Return the maximum width of the font.
Implemented in Graphics::MacFONTFont, Graphics::AmigaFont, Tetraedge::TeFont2, Graphics::BdfFont, Graphics::WinFont, MM::XeenFont, BladeRunner::Font, MM::BitmapFont, Dgds::DgdsFont, Nancy::Font, CryOmni3D::CryoExtFont, MutationOfJB::Font, CryOmni3D::CryoFont, Darkseed::GameFont, Freescape::Font, Prince::Font, and Groovie::T7GFont.
|
pure virtual |
Return the width of a specific character.
chr | The character to query the width of. |
Implemented in Graphics::MacFONTFont, Dgds::FFont, Graphics::AmigaFont, Tetraedge::TeFont2, Dgds::PFont, MM::XeenFont, Graphics::BdfFont, Graphics::WinFont, BladeRunner::Font, MM::BitmapFont, Dgds::DgdsFont, CryOmni3D::CryoExtFont, Nancy::Font, CryOmni3D::CryoFont, MutationOfJB::Font, Prince::Font, Darkseed::GameFont, Freescape::Font, and Groovie::T7GFont.
|
virtual |
Query the kerning offset between two characters.
left | Left character. Can be 0. |
right | Right character. Can be 0. |
Reimplemented in Graphics::MacFONTFont, Graphics::AmigaFont, Tetraedge::TeFont2, Nancy::Font, Prince::Font, MutationOfJB::Font, and Freescape::Font.
|
virtual |
Calculate the bounding box of a character.
It is assumed that the character shall be drawn at position (0, 0).
The idea here is that the character might be drawn outside the rect (0, 0) to (getCharWidth(chr), getFontHeight()) for some fonts. This is common among TTF fonts.
The default implementation simply returns the rect with a width of getCharWidth(chr) and height of getFontHeight().
chr | The character to draw. |
Reimplemented in Tetraedge::TeFont2, CryOmni3D::CryoExtFont, and CryOmni3D::CryoFont.
Common::Rect Graphics::Font::getBoundingBox | ( | const Common::String & | str, |
int | x = 0 , |
||
int | y = 0 , |
||
const int | w = 0 , |
||
TextAlign | align = kTextAlignLeft , |
||
int | deltax = 0 , |
||
bool | useEllipsis = false |
||
) | const |
Return the bounding box of a string drawn with drawString.
str | The drawn string. |
x | The x position where to start drawing. |
y | The y position where to start drawing. |
w | Width of the text area. This can be 0 to allow for obtaining the whole bounding box for a string. Note that this does not work with an align different than kTextAlignLeft or with useEllipsis . |
align | Text alignment. This can be used to center a string in the given area or to align it to the right. |
deltax | Offset to the x starting position of the string. |
useEllipsis | Try to fit the string in the area by inserting an ellipsis. Note that the default value is false for this argument, unlike for drawString. |
Common::Rect Graphics::Font::getBoundingBox | ( | const Common::U32String & | str, |
int | x = 0 , |
||
int | _y = 0 , |
||
const int | w = 0 , |
||
TextAlign | align = kTextAlignLeft , |
||
int | deltax = 0 , |
||
bool | useEllipsis = false |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
pure virtual |
Draw a character at a specific point on the surface.
Note that the point describes the top left edge point where to draw the character. This can be different from the top left edge point of the character's bounding box. For example, TTF fonts sometimes move characters like 't' by one (or more) pixels to the left to create better visual results. To query the actual bounding box of a character, use getBoundingBox.
The Font implementation should take care of not drawing outside of the specified surface.
dst | The surface to draw on. |
chr | The character to draw. |
x | The x coordinate where to draw the character. |
y | The y coordinate where to draw the character. |
color | The color of the character. |
Implemented in Graphics::MacFONTFont, Dgds::FFont, Graphics::AmigaFont, MM::XeenFont, Tetraedge::TeFont2, Dgds::PFont, Graphics::BdfFont, Graphics::WinFont, MM::BitmapFont, BladeRunner::Font, CryOmni3D::CryoExtFont, CryOmni3D::CryoFont, Nancy::Font, Freescape::Font, MutationOfJB::Font, Prince::Font, Darkseed::GameFont, Groovie::T7GFont, and MM::MM1::Gfx::BitmapFont.
void Graphics::Font::drawString | ( | Surface * | dst, |
const Common::String & | str, | ||
int | x, | ||
int | y, | ||
int | w, | ||
uint32 | color, | ||
TextAlign | align = kTextAlignLeft , |
||
int | deltax = 0 , |
||
bool | useEllipsis = false |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Draw the given str
string to the given dst
surface.
dst | The surface on which to draw the string. |
str | The string to draw. |
x | The x position where to start drawing. |
y | The y position where to start drawing. |
w | Width of the text area. |
color | The color with which to draw the string. |
align | Text alignment. This can be used to center the string in the given area or to align it to the right. |
deltax | Offset to the x starting position of the string. |
useEllipsis | Use ellipsis if needed to fit the string in the area. |
void Graphics::Font::drawString | ( | Surface * | dst, |
const Common::U32String & | str, | ||
int | x, | ||
int | y, | ||
int | w, | ||
uint32 | color, | ||
TextAlign | align = kTextAlignLeft , |
||
int | deltax = 0 , |
||
bool | useEllipsis = false |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Graphics::Font::drawString | ( | ManagedSurface * | dst, |
const Common::String & | str, | ||
int | x, | ||
int | _y, | ||
int | w, | ||
uint32 | color, | ||
TextAlign | align = kTextAlignLeft , |
||
int | deltax = 0 , |
||
bool | useEllipsis = false |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Graphics::Font::drawString | ( | ManagedSurface * | dst, |
const Common::U32String & | str, | ||
int | x, | ||
int | y, | ||
int | w, | ||
uint32 | color, | ||
TextAlign | align = kTextAlignLeft , |
||
int | deltax = 0 , |
||
bool | useEllipsis = false |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int Graphics::Font::getStringWidth | ( | const Common::String & | str | ) | const |
Compute and return the width of the string str
when rendered using this font.
This describes the logical width of the string when drawn at (0, 0). This can be different from the actual bounding box of the string. Use getBoundingBox when you need the bounding box of a drawn string.
int Graphics::Font::getStringWidth | ( | const Common::U32String & | str | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int Graphics::Font::wordWrapText | ( | const Common::String & | str, |
int | maxWidth, | ||
Common::Array< Common::String > & | lines, | ||
int | initWidth = 0 , |
||
uint32 | mode = kWordWrapOnExplicitNewLines |
||
) | const |
Word-wrap a text (that can contain newline characters) so that no text line is wider than maxWidth
pixels.
If necessary, additional line breaks are generated, preferably between words, where whitespace is. The resulting lines are appended to the lines
string list. This returns the maximal width of any of the new lines (i.e. a value that is smaller or equal to maxWidth).
str | The string to word-wrap. |
maxWidth | Maximum width that a line can have. |
lines | The string list to which the text lines from str are appended. |
initWidth | Starting width of the first line, for partially filled lines (optional). |
mode | Wrapping mode. A bitfield of WordWrapMode values. |
lines
. int Graphics::Font::wordWrapText | ( | const Common::U32String & | str, |
int | maxWidth, | ||
Common::Array< Common::U32String > & | lines, | ||
int | initWidth = 0 , |
||
uint32 | mode = kWordWrapOnExplicitNewLines |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int Graphics::Font::wordWrapText | ( | const Common::U32String & | str, |
int | maxWidth, | ||
Common::Array< Common::U32String > & | lines, | ||
Common::Array< bool > & | lineContinuation, | ||
int | initWidth = 0 , |
||
uint32 | mode = kWordWrapOnExplicitNewLines |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Word-wrap a text, and returns in lineCountination a list of lines where a word has been splitted into the next line.
lineContinuation | Bool list. If the ith element of the list is true, then the ith line in lines contains a splitted word. |
void Graphics::Font::scaleSingleGlyph | ( | Surface * | scaleSurface, |
int * | grayScaleMap, | ||
int | grayScaleMapSize, | ||
int | width, | ||
int | height, | ||
int | xOffset, | ||
int | yOffset, | ||
int | grayLevel, | ||
int | chr, | ||
int | srcheight, | ||
int | srcwidth, | ||
float | scale | ||
) | const |
Scales the single gylph at chr
the given the scale
and the pointer grayScaleMap
to the grayscale array. It fills scaleSurface
surface and then we draw the character on scaleSurface
surface. The scaleSUrface
is magnified to grayScale array and then we change the scaleSurface
using the grayScale array and grayLevel
.
grayScaleMap | The pointer to the grayScale array. |
grayScaleMapSize | The size of the grayScale array. |
scaleSurface | The surface to where character is scaled and drawn. |
width | The width of the bouding box for scaled glyph. |
height | The height of the bounding box for scaled glyph. |
grayLevel | The graylevel is the threshold value above which the pixel is considered |
chr | The character to scale. |
xOffset | The x offset of the bounding box for scaled glyph. |
yOffset | The y offset of the bounding box for scaled glyph. |
srcheight | The height of the source glyph. |
srcwidth | The width of the source glyph bounding box. |
scale | The scale factor that is equal to newSize / srcSize of initializeScaling. |