📄 eb_font.h
字号:
/*
* Created on 24 may 2004
*
* @author DigitalAirways (c) 2004
*
* This software is the confidential and proprietary information of
* DigitalAirways, sarl. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with DigitalAirways.
* A copy of this license is included in the licence.txt file included
* in this software package.
*
*/
#ifndef _EB_FONT_
#define _EB_FONT_
#include "EB_Defs.h"
class Graphics ;
class GContext ;
class PFWImage ;
#define MAX_CHAR 256
class KREBDLIBS_API Font {
protected:
GContext* gContext ;
PFWImage* bitmap;
int charPos[MAX_CHAR*2+2];
int charNum; // Number of chars defined in the font
int maxPos; // x offset of the last dot in the font's bitmap
//
void write(Graphics* surface, int x, int y, const char *text, int useColor, unsigned char tR, unsigned char tG, unsigned char tB) ;
public:
/*
<kaleidoc>
<filename>Font</filename>
<page>
<api>
<class>Font</class>
<method>Font</method>
<cpp>Font(GContext* gContext, pchar src)</cpp>
<descr>
<p>The constructor of the class. src is the ID (usually the file name) of the source of the bitmap that is defining the font.</p>
</descr>
</api>
</page>
</kaleidoc>
*/
DEFINE_NEW(Font);
DEFINE_DELETE(Font) ;
Font(GContext* gContext, pchar src);
Font(GContext* newGContext) ;
virtual ~Font() ;
/*
<kaleidoc>
<filename>Font</filename>
<page>
<api>
<class>Font</class>
<method>write</method>
<cpp>void write(Graphics* surface, int x, int y, const char *text)</cpp>
<descr>
<p>Blits a string to a surface, using the original color of the font. Note that the bitmap defining the font is not only a binary mask. It may define multicolored fonts.</p>
<itemlist>
<item><p>surface : is the destination you want to blit to</p></item>
<item><p>x, y : is the position that may be used in the destination surface to start to blit the string</p></item>
<item><p>text: is a string containing the text to blit.</p></item>
</itemlist>
</descr>
</api>
</page>
</kaleidoc>
*/
virtual void write(Graphics* surface, int x, int y, const char *text)
{ write(surface, x, y, text, false, 0,0,0); }
/*
<kaleidoc>
<filename>Font</filename>
<page>
<api>
<class>Font</class>
<method>write</method>
<cpp>void write(Graphics* surface, int x, int y, const char *text, unsigned char tR, unsigned char tG, unsigned char tB)</cpp>
<descr>
<p>Blits a string to a surface, using a specified color.</p>
<itemlist>
<item><p>surface : is the destination you want to blit to.</p></item>
<item><p>x, y : is the position that may be used in the destination surface to start to blit the string</p></item>
<item><p>text: is a string containing the text to blit.</p></item>
<item><p>tR, tG, tB : is the RGB value to use in place of the original font color(s). </p></item>
</itemlist>
</descr>
</api>
</page>
</kaleidoc>
*/
virtual void write(Graphics* surface, int x, int y, const char *text, unsigned char tR, unsigned char tG, unsigned char tB)
{ write(surface, x, y, text, true, tR, tG, tB); }
/*
<kaleidoc>
<filename>Font</filename>
<page>
<api>
<class>Font</class>
<method>textWidth</method>
<cpp>int textWidth(const char *text)</cpp>
<descr>
<p>Returns the width (in pixels) that is necessary to draw text using the current font.</p>
</descr>
</api>
</page>
</kaleidoc>
*/
virtual int textWidth(const char *text);
/*
<kaleidoc>
<filename>Font</filename>
<page>
<api>
<class>Font</class>
<method>textHeight</method>
<cpp>int textHeight()</cpp>
<descr>
<p>Returns the height (in pixels) that is necessary to draw text using the current font (that is always equal to Font->Surface->h).</p>
</descr>
</api>
</page>
</kaleidoc>
*/
virtual int textHeight(const char *text=NULL);
};
#endif // _EB_FONT_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -