aboutsummaryrefslogtreecommitdiff
path: root/graphics/fonts/bdf.h
diff options
context:
space:
mode:
authorJohannes Schickel2011-07-01 21:10:25 +0200
committerJohannes Schickel2011-07-01 21:10:25 +0200
commit8201df7bb6b7c5174b86599bcb3aa3130db30bf8 (patch)
tree74d21281d0ebc46e5839306c556ed706aaa13cd1 /graphics/fonts/bdf.h
parent12c94f749d9d0db98d7e410b0e5df6b1ef49a938 (diff)
downloadscummvm-rg350-8201df7bb6b7c5174b86599bcb3aa3130db30bf8.tar.gz
scummvm-rg350-8201df7bb6b7c5174b86599bcb3aa3130db30bf8.tar.bz2
scummvm-rg350-8201df7bb6b7c5174b86599bcb3aa3130db30bf8.zip
GRAPHICS: Move NewFont code to a separate file.
Diffstat (limited to 'graphics/fonts/bdf.h')
-rw-r--r--graphics/fonts/bdf.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/graphics/fonts/bdf.h b/graphics/fonts/bdf.h
new file mode 100644
index 0000000000..02bf23b211
--- /dev/null
+++ b/graphics/fonts/bdf.h
@@ -0,0 +1,100 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GRAPHICS_FONTS_BDF_H
+#define GRAPHICS_FONTS_BDF_H
+
+#include "common/system.h"
+
+#include "graphics/font.h"
+
+namespace Common {
+class SeekableReadStream;
+}
+
+namespace Graphics {
+
+typedef uint16 bitmap_t; /* bitmap image unit size*/
+
+struct BBX {
+ int8 w;
+ int8 h;
+ int8 x;
+ int8 y;
+};
+
+/* builtin C-based proportional/fixed font structure */
+/* based on The Microwindows Project http://microwindows.org */
+struct FontDesc {
+ const char * name; /* font name*/
+ int maxwidth; /* max width in pixels*/
+ int height; /* height in pixels*/
+ int fbbw, fbbh, fbbx, fbby; /* max bounding box */
+ int ascent; /* ascent (baseline) height*/
+ int firstchar; /* first character in bitmap*/
+ int size; /* font size in glyphs*/
+ const bitmap_t* bits; /* 16-bit right-padded bitmap data*/
+ const unsigned long* offset; /* offsets into bitmap data*/
+ const unsigned char* width; /* character widths or NULL if fixed*/
+ const BBX* bbx; /* character bounding box or NULL if fixed */
+ int defaultchar; /* default char (not glyph index)*/
+ long bits_size; /* # words of bitmap_t bits*/
+};
+
+struct NewFontData;
+
+class NewFont : public Font {
+protected:
+ FontDesc _desc;
+ NewFontData *_font;
+
+public:
+ NewFont(const FontDesc &desc, NewFontData *font = 0) : _desc(desc), _font(font) {}
+ ~NewFont();
+
+ virtual int getFontHeight() const { return _desc.height; }
+ virtual int getMaxCharWidth() const { return _desc.maxwidth; }
+
+ virtual int getCharWidth(byte chr) const;
+ virtual void drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const;
+
+ static NewFont *loadFont(Common::SeekableReadStream &stream);
+ static bool cacheFontData(const NewFont &font, const Common::String &filename);
+ static NewFont *loadFromCache(Common::SeekableReadStream &stream);
+};
+
+#define DEFINE_FONT(n) \
+ const NewFont *n = 0; \
+ void create_##n() { \
+ n = new NewFont(desc); \
+ }
+
+#define FORWARD_DECLARE_FONT(n) \
+ extern const NewFont *n; \
+ extern void create_##n()
+
+#define INIT_FONT(n) \
+ create_##n()
+
+} // End of namespace Graphics
+
+#endif
+