summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tilefont.h
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-15 04:07:07 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-15 04:07:07 +0000
commitaf3cd3ff34ef5da884b2c673afe1321f0cf372e7 (patch)
treea574c2155f571f216f29c44b29e333ea320322a6 /crawl-ref/source/tilefont.h
parent71ed1a7fd6819916d79d194126c061ac1f087b11 (diff)
downloadcrawl-ref-af3cd3ff34ef5da884b2c673afe1321f0cf372e7.tar.gz
crawl-ref-af3cd3ff34ef5da884b2c673afe1321f0cf372e7.zip
Large tiles-related changes. Platform-specific rendering removed and replaced with SDL/OpenGL.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6550 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tilefont.h')
-rw-r--r--crawl-ref/source/tilefont.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/crawl-ref/source/tilefont.h b/crawl-ref/source/tilefont.h
new file mode 100644
index 0000000000..5d8939a9a9
--- /dev/null
+++ b/crawl-ref/source/tilefont.h
@@ -0,0 +1,71 @@
+/*
+ * File: tilefont.h
+ * Created by: ennewalker on Sat Jan 5 01:33:53 2008 UTC
+ *
+ * Modified for Crawl Reference by $Author: ennewalker $ on $Date: 2008-03-07 $
+ */
+
+#ifndef TILEFONT_H
+#define TILEFONT_H
+
+#include "AppHdr.h"
+#include "externs.h"
+#include "tiletex.h"
+
+// This class handles loading FreeType2 fonts and rendering them via OpenGL.
+
+// TODO enne - Fonts could be made better by:
+//
+// * handling kerning
+//
+// * the possibility of streaming this class in and out so that Crawl doesn't
+// have to link against FreeType2 or be forced do as much processing at
+// load time.
+
+class FTFont
+{
+public:
+ FTFont();
+ virtual ~FTFont();
+
+ bool load_font(const char *font_name, unsigned int font_size);
+
+ // render just text
+ void render_textblock(unsigned int x, unsigned int y,
+ unsigned char *chars, unsigned char *colours,
+ unsigned int width, unsigned int height,
+ bool drop_shadow = false);
+
+ // render text + background box
+ void render_string(unsigned int x, unsigned int y, const char *text,
+ const coord_def &min_pos, const coord_def &max_pos,
+ unsigned char font_colour, bool drop_shadow = false,
+ unsigned char box_alpha = 0,
+ unsigned char box_colour = 0, unsigned int outline = 0);
+
+ unsigned int char_width() const { return m_max_advance.x; }
+ unsigned int char_height() const { return m_max_advance.y; }
+
+protected:
+ struct GlyphInfo
+ {
+ // offset before drawing glyph; can be negative
+ int offset;
+
+ // per-glyph horizontal advance
+ int advance;
+
+ bool renderable;
+ };
+ GlyphInfo *m_glyphs;
+
+ // cached value of the maximum advance from m_advance
+ coord_def m_max_advance;
+
+ // minimum offset (likely negative)
+ int m_min_offset;
+
+ GenericTexture m_tex;
+};
+
+#endif