GRAPHICS: Rename NewFont to BdfFont.
This commit is contained in:
parent
9e3366d66e
commit
fa5f8dc703
7 changed files with 50 additions and 50 deletions
|
@ -890,7 +890,7 @@ int gen_c_source(struct font* pf, char *path) {
|
||||||
|
|
||||||
fprintf(ofp,
|
fprintf(ofp,
|
||||||
"/* Exported structure definition. */\n"
|
"/* Exported structure definition. */\n"
|
||||||
"static const FontDesc desc = {\n"
|
"static const BdfFontDesc desc = {\n"
|
||||||
"\t" "\"%s\",\n"
|
"\t" "\"%s\",\n"
|
||||||
"\t" "%d,\n"
|
"\t" "%d,\n"
|
||||||
"\t" "%d,\n"
|
"\t" "%d,\n"
|
||||||
|
@ -917,7 +917,7 @@ int gen_c_source(struct font* pf, char *path) {
|
||||||
pf->defaultchar);
|
pf->defaultchar);
|
||||||
|
|
||||||
fprintf(ofp, "\n" "#if !(defined(__GP32__))\n");
|
fprintf(ofp, "\n" "#if !(defined(__GP32__))\n");
|
||||||
fprintf(ofp, "extern const NewFont g_sysfont(desc);\n");
|
fprintf(ofp, "extern const BdfFont g_sysfont(desc);\n");
|
||||||
fprintf(ofp, "#else\n");
|
fprintf(ofp, "#else\n");
|
||||||
fprintf(ofp, "DEFINE_FONT(g_sysfont)\n");
|
fprintf(ofp, "DEFINE_FONT(g_sysfont)\n");
|
||||||
fprintf(ofp, "#endif\n");
|
fprintf(ofp, "#endif\n");
|
||||||
|
|
|
@ -29,23 +29,23 @@
|
||||||
|
|
||||||
namespace Graphics {
|
namespace Graphics {
|
||||||
|
|
||||||
void free_font(NewFontData *pf);
|
void free_font(BdfFontData *pf);
|
||||||
|
|
||||||
NewFont::~NewFont() {
|
BdfFont::~BdfFont() {
|
||||||
if (_font) {
|
if (_font) {
|
||||||
free_font(_font);
|
free_font(_font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int NewFont::getFontHeight() const {
|
int BdfFont::getFontHeight() const {
|
||||||
return _desc.height;
|
return _desc.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NewFont::getMaxCharWidth() const {
|
int BdfFont::getMaxCharWidth() const {
|
||||||
return _desc.maxwidth;
|
return _desc.maxwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NewFont::getCharWidth(byte chr) const {
|
int BdfFont::getCharWidth(byte chr) const {
|
||||||
// If no width table is specified, return the maximum width
|
// If no width table is specified, return the maximum width
|
||||||
if (!_desc.width)
|
if (!_desc.width)
|
||||||
return _desc.maxwidth;
|
return _desc.maxwidth;
|
||||||
|
@ -78,7 +78,7 @@ void drawCharIntern(byte *ptr, uint pitch, const bitmap_t *src, int h, int minX,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const uint32 color) const {
|
void BdfFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const uint32 color) const {
|
||||||
assert(dst != 0);
|
assert(dst != 0);
|
||||||
|
|
||||||
assert(_desc.bits != 0 && _desc.maxwidth <= 16);
|
assert(_desc.bits != 0 && _desc.maxwidth <= 16);
|
||||||
|
@ -135,7 +135,7 @@ void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const
|
||||||
|
|
||||||
/* builtin C-based proportional/fixed font structure */
|
/* builtin C-based proportional/fixed font structure */
|
||||||
/* based on The Microwindows Project http://microwindows.org */
|
/* based on The Microwindows Project http://microwindows.org */
|
||||||
struct NewFontData {
|
struct BdfFontData {
|
||||||
char *name; /* font name */
|
char *name; /* font name */
|
||||||
int maxwidth; /* max width in pixels */
|
int maxwidth; /* max width in pixels */
|
||||||
int height; /* height in pixels */
|
int height; /* height in pixels */
|
||||||
|
@ -166,13 +166,13 @@ struct NewFontData {
|
||||||
int start_char = 0;
|
int start_char = 0;
|
||||||
int limit_char = 255;
|
int limit_char = 255;
|
||||||
|
|
||||||
NewFontData *bdf_read_font(Common::SeekableReadStream &fp);
|
BdfFontData *bdf_read_font(Common::SeekableReadStream &fp);
|
||||||
int bdf_read_header(Common::SeekableReadStream &fp, NewFontData *pf);
|
int bdf_read_header(Common::SeekableReadStream &fp, BdfFontData *pf);
|
||||||
int bdf_read_bitmaps(Common::SeekableReadStream &fp, NewFontData *pf);
|
int bdf_read_bitmaps(Common::SeekableReadStream &fp, BdfFontData *pf);
|
||||||
char *bdf_getline(Common::SeekableReadStream &fp, char *buf, int len);
|
char *bdf_getline(Common::SeekableReadStream &fp, char *buf, int len);
|
||||||
bitmap_t bdf_hexval(unsigned char *buf);
|
bitmap_t bdf_hexval(unsigned char *buf);
|
||||||
|
|
||||||
void free_font(NewFontData *pf) {
|
void free_font(BdfFontData *pf) {
|
||||||
if (!pf)
|
if (!pf)
|
||||||
return;
|
return;
|
||||||
free(pf->name);
|
free(pf->name);
|
||||||
|
@ -185,11 +185,11 @@ void free_font(NewFontData *pf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build incore structure from .bdf file*/
|
/* build incore structure from .bdf file*/
|
||||||
NewFontData *bdf_read_font(Common::SeekableReadStream &fp) {
|
BdfFontData *bdf_read_font(Common::SeekableReadStream &fp) {
|
||||||
NewFontData *pf;
|
BdfFontData *pf;
|
||||||
uint32 pos = fp.pos();
|
uint32 pos = fp.pos();
|
||||||
|
|
||||||
pf = (NewFontData *)calloc(1, sizeof(NewFontData));
|
pf = (BdfFontData *)calloc(1, sizeof(BdfFontData));
|
||||||
if (!pf)
|
if (!pf)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ errout:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read bdf font header information, return 0 on error*/
|
/* read bdf font header information, return 0 on error*/
|
||||||
int bdf_read_header(Common::SeekableReadStream &fp, NewFontData *pf) {
|
int bdf_read_header(Common::SeekableReadStream &fp, BdfFontData *pf) {
|
||||||
int encoding = 0;
|
int encoding = 0;
|
||||||
int nchars = 0, maxwidth, maxheight;
|
int nchars = 0, maxwidth, maxheight;
|
||||||
int firstchar = 65535;
|
int firstchar = 65535;
|
||||||
|
@ -358,7 +358,7 @@ int bdf_read_header(Common::SeekableReadStream &fp, NewFontData *pf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read bdf font bitmaps, return 0 on error*/
|
/* read bdf font bitmaps, return 0 on error*/
|
||||||
int bdf_read_bitmaps(Common::SeekableReadStream &fp, NewFontData *pf) {
|
int bdf_read_bitmaps(Common::SeekableReadStream &fp, BdfFontData *pf) {
|
||||||
long ofs = 0;
|
long ofs = 0;
|
||||||
int maxwidth = 0;
|
int maxwidth = 0;
|
||||||
int i, k, encoding = 0, width = 0;
|
int i, k, encoding = 0, width = 0;
|
||||||
|
@ -590,14 +590,14 @@ bitmap_t bdf_hexval(unsigned char *buf) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewFont *NewFont::loadFont(Common::SeekableReadStream &stream) {
|
BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
|
||||||
NewFontData *data = bdf_read_font(stream);
|
BdfFontData *data = bdf_read_font(stream);
|
||||||
if (!data || stream.err()) {
|
if (!data || stream.err()) {
|
||||||
free_font(data);
|
free_font(data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontDesc desc;
|
BdfFontDesc desc;
|
||||||
desc.name = data->name;
|
desc.name = data->name;
|
||||||
desc.maxwidth = data->maxwidth;
|
desc.maxwidth = data->maxwidth;
|
||||||
desc.height = data->height;
|
desc.height = data->height;
|
||||||
|
@ -615,10 +615,10 @@ NewFont *NewFont::loadFont(Common::SeekableReadStream &stream) {
|
||||||
desc.defaultchar = data->defaultchar;
|
desc.defaultchar = data->defaultchar;
|
||||||
desc.bits_size = data->bits_size;
|
desc.bits_size = data->bits_size;
|
||||||
|
|
||||||
return new NewFont(desc, data);
|
return new BdfFont(desc, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NewFont::cacheFontData(const NewFont &font, const Common::String &filename) {
|
bool BdfFont::cacheFontData(const BdfFont &font, const Common::String &filename) {
|
||||||
Common::DumpFile cacheFile;
|
Common::DumpFile cacheFile;
|
||||||
if (!cacheFile.open(filename)) {
|
if (!cacheFile.open(filename)) {
|
||||||
warning("Couldn't open file '%s' for writing", filename.c_str());
|
warning("Couldn't open file '%s' for writing", filename.c_str());
|
||||||
|
@ -674,14 +674,14 @@ bool NewFont::cacheFontData(const NewFont &font, const Common::String &filename)
|
||||||
return !cacheFile.err();
|
return !cacheFile.err();
|
||||||
}
|
}
|
||||||
|
|
||||||
NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
|
BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) {
|
||||||
NewFont *font = 0;
|
BdfFont *font = 0;
|
||||||
|
|
||||||
NewFontData *data = (NewFontData *)malloc(sizeof(NewFontData));
|
BdfFontData *data = (BdfFontData *)malloc(sizeof(BdfFontData));
|
||||||
if (!data)
|
if (!data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset(data, 0, sizeof(NewFontData));
|
memset(data, 0, sizeof(BdfFontData));
|
||||||
|
|
||||||
data->maxwidth = stream.readUint16BE();
|
data->maxwidth = stream.readUint16BE();
|
||||||
data->height = stream.readUint16BE();
|
data->height = stream.readUint16BE();
|
||||||
|
@ -761,7 +761,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontDesc desc;
|
BdfFontDesc desc;
|
||||||
desc.name = data->name;
|
desc.name = data->name;
|
||||||
desc.maxwidth = data->maxwidth;
|
desc.maxwidth = data->maxwidth;
|
||||||
desc.height = data->height;
|
desc.height = data->height;
|
||||||
|
@ -779,7 +779,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
|
||||||
desc.defaultchar = data->defaultchar;
|
desc.defaultchar = data->defaultchar;
|
||||||
desc.bits_size = data->bits_size;
|
desc.bits_size = data->bits_size;
|
||||||
|
|
||||||
font = new NewFont(desc, data);
|
font = new BdfFont(desc, data);
|
||||||
if (!font) {
|
if (!font) {
|
||||||
free(data->bits);
|
free(data->bits);
|
||||||
free(data->offset);
|
free(data->offset);
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct BBX {
|
||||||
|
|
||||||
/* builtin C-based proportional/fixed font structure */
|
/* builtin C-based proportional/fixed font structure */
|
||||||
/* based on The Microwindows Project http://microwindows.org */
|
/* based on The Microwindows Project http://microwindows.org */
|
||||||
struct FontDesc {
|
struct BdfFontDesc {
|
||||||
const char *name; /* font name */
|
const char *name; /* font name */
|
||||||
int maxwidth; /* max width in pixels */
|
int maxwidth; /* max width in pixels */
|
||||||
int height; /* height in pixels */
|
int height; /* height in pixels */
|
||||||
|
@ -59,16 +59,16 @@ struct FontDesc {
|
||||||
long bits_size; /* # words of bitmap_t bits */
|
long bits_size; /* # words of bitmap_t bits */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NewFontData;
|
struct BdfFontData;
|
||||||
|
|
||||||
class NewFont : public Font {
|
class BdfFont : public Font {
|
||||||
protected:
|
protected:
|
||||||
FontDesc _desc;
|
BdfFontDesc _desc;
|
||||||
NewFontData *_font;
|
BdfFontData *_font;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NewFont(const FontDesc &desc, NewFontData *font = 0) : _desc(desc), _font(font) {}
|
BdfFont(const BdfFontDesc &desc, BdfFontData *font = 0) : _desc(desc), _font(font) {}
|
||||||
~NewFont();
|
~BdfFont();
|
||||||
|
|
||||||
virtual int getFontHeight() const;
|
virtual int getFontHeight() const;
|
||||||
virtual int getMaxCharWidth() const;
|
virtual int getMaxCharWidth() const;
|
||||||
|
@ -76,19 +76,19 @@ public:
|
||||||
virtual int getCharWidth(byte chr) const;
|
virtual int getCharWidth(byte chr) const;
|
||||||
virtual void drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const;
|
virtual void drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const;
|
||||||
|
|
||||||
static NewFont *loadFont(Common::SeekableReadStream &stream);
|
static BdfFont *loadFont(Common::SeekableReadStream &stream);
|
||||||
static bool cacheFontData(const NewFont &font, const Common::String &filename);
|
static bool cacheFontData(const BdfFont &font, const Common::String &filename);
|
||||||
static NewFont *loadFromCache(Common::SeekableReadStream &stream);
|
static BdfFont *loadFromCache(Common::SeekableReadStream &stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFINE_FONT(n) \
|
#define DEFINE_FONT(n) \
|
||||||
const NewFont *n = 0; \
|
const BdfFont *n = 0; \
|
||||||
void create_##n() { \
|
void create_##n() { \
|
||||||
n = new NewFont(desc); \
|
n = new BdfFont(desc); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FORWARD_DECLARE_FONT(n) \
|
#define FORWARD_DECLARE_FONT(n) \
|
||||||
extern const NewFont *n; \
|
extern const BdfFont *n; \
|
||||||
extern void create_##n()
|
extern void create_##n()
|
||||||
|
|
||||||
#define INIT_FONT(n) \
|
#define INIT_FONT(n) \
|
||||||
|
|
|
@ -5635,7 +5635,7 @@ static const unsigned long _sysfont_offset[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Exported structure definition. */
|
/* Exported structure definition. */
|
||||||
static const FontDesc desc = {
|
static const BdfFontDesc desc = {
|
||||||
"5x8-L1",
|
"5x8-L1",
|
||||||
5,
|
5,
|
||||||
8,
|
8,
|
||||||
|
|
|
@ -7419,7 +7419,7 @@ static const unsigned long _sysfont_offset[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Exported structure definition. */
|
/* Exported structure definition. */
|
||||||
static const FontDesc desc = {
|
static const BdfFontDesc desc = {
|
||||||
"clR6x12-L1",
|
"clR6x12-L1",
|
||||||
6,
|
6,
|
||||||
12,
|
12,
|
||||||
|
|
|
@ -5523,7 +5523,7 @@ static const BBX _sysfont_bbx[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Exported structure definition. */
|
/* Exported structure definition. */
|
||||||
static const FontDesc desc = {
|
static const BdfFontDesc desc = {
|
||||||
"helvB12-L1",
|
"helvB12-L1",
|
||||||
13,
|
13,
|
||||||
14,
|
14,
|
||||||
|
|
|
@ -1395,7 +1395,7 @@ const Graphics::Font *ThemeEngine::loadFontFromArchive(const Common::String &fil
|
||||||
if (_themeArchive)
|
if (_themeArchive)
|
||||||
stream = _themeArchive->createReadStreamForMember(filename);
|
stream = _themeArchive->createReadStreamForMember(filename);
|
||||||
if (stream) {
|
if (stream) {
|
||||||
font = Graphics::NewFont::loadFont(*stream);
|
font = Graphics::BdfFont::loadFont(*stream);
|
||||||
delete stream;
|
delete stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1409,7 +1409,7 @@ const Graphics::Font *ThemeEngine::loadCachedFontFromArchive(const Common::Strin
|
||||||
if (_themeArchive)
|
if (_themeArchive)
|
||||||
stream = _themeArchive->createReadStreamForMember(filename);
|
stream = _themeArchive->createReadStreamForMember(filename);
|
||||||
if (stream) {
|
if (stream) {
|
||||||
font = Graphics::NewFont::loadFromCache(*stream);
|
font = Graphics::BdfFont::loadFromCache(*stream);
|
||||||
delete stream;
|
delete stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1423,7 +1423,7 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) {
|
||||||
|
|
||||||
if (!cacheFilename.empty()) {
|
if (!cacheFilename.empty()) {
|
||||||
if (fontFile.open(cacheFilename)) {
|
if (fontFile.open(cacheFilename)) {
|
||||||
font = Graphics::NewFont::loadFromCache(fontFile);
|
font = Graphics::BdfFont::loadFromCache(fontFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font)
|
if (font)
|
||||||
|
@ -1435,7 +1435,7 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) {
|
||||||
|
|
||||||
// normal open
|
// normal open
|
||||||
if (fontFile.open(filename)) {
|
if (fontFile.open(filename)) {
|
||||||
font = Graphics::NewFont::loadFont(fontFile);
|
font = Graphics::BdfFont::loadFont(fontFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!font) {
|
if (!font) {
|
||||||
|
@ -1444,7 +1444,7 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) {
|
||||||
|
|
||||||
if (font) {
|
if (font) {
|
||||||
if (!cacheFilename.empty()) {
|
if (!cacheFilename.empty()) {
|
||||||
if (!Graphics::NewFont::cacheFontData(*(const Graphics::NewFont *)font, cacheFilename)) {
|
if (!Graphics::BdfFont::cacheFontData(*(const Graphics::BdfFont *)font, cacheFilename)) {
|
||||||
warning("Couldn't create cache file for font '%s'", filename.c_str());
|
warning("Couldn't create cache file for font '%s'", filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue