ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

bdf.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRAPHICS_FONTS_BDF_H
00024 #define GRAPHICS_FONTS_BDF_H
00025 
00026 #include "common/system.h"
00027 #include "common/types.h"
00028 
00029 #include "graphics/font.h"
00030 
00031 namespace Common {
00032 class SeekableReadStream;
00033 }
00034 
00035 namespace Graphics {
00036 
00037 struct BdfBoundingBox {
00038     uint8 width, height;
00039     int8 xOffset, yOffset;
00040 };
00041 
00042 struct BdfFontData {
00043     const char *familyName;
00044     const char *slant;
00045 
00046     int maxAdvance;
00047     int height;
00048     int size;
00049     BdfBoundingBox defaultBox;
00050     int ascent;
00051 
00052     int firstCharacter;
00053     int defaultCharacter;
00054     int numCharacters;
00055 
00056     const byte *const *bitmaps;
00057     const byte *advances;
00058     const BdfBoundingBox *boxes;
00059 };
00060 
00061 class BdfFont : public Font {
00062 public:
00063     BdfFont(const BdfFontData &data, DisposeAfterUse::Flag dispose);
00064     ~BdfFont();
00065 
00066     virtual int getFontHeight() const;
00067     virtual int getMaxCharWidth() const;
00068 
00069     virtual int getCharWidth(uint32 chr) const;
00070     virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
00071 
00072     const char *getFamilyName() const;
00073     const char *getFontSlant() const;
00074     int getFontSize() const;
00075 
00076     static BdfFont *loadFont(Common::SeekableReadStream &stream);
00077     static bool cacheFontData(const BdfFont &font, const Common::String &filename);
00078     static BdfFont *loadFromCache(Common::SeekableReadStream &stream);
00079     static BdfFont *scaleFont(BdfFont *src, int newSize);
00080 private:
00081     int mapToIndex(uint32 ch) const;
00082 
00083     const BdfFontData _data;
00084     const DisposeAfterUse::Flag _dispose;
00085 };
00086 
00087 #define DEFINE_FONT(n) \
00088     const BdfFont *n = 0; \
00089     void create_##n() { \
00090         n = new BdfFont(desc, DisposeAfterUse::NO); \
00091     }
00092 
00093 #define FORWARD_DECLARE_FONT(n) \
00094     extern const BdfFont *n; \
00095     extern void create_##n()
00096 
00097 #define INIT_FONT(n) \
00098     create_##n()
00099 
00100 } // End of namespace Graphics
00101 
00102 #endif


Generated on Sat Aug 17 2019 05:00:43 for ResidualVM by doxygen 1.7.1
curved edge   curved edge