]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/bitmap_font.hpp
* all: beginning of "text" bitmap font support. The text bitmap must have
[vlc] / modules / gui / skins2 / src / bitmap_font.hpp
1 /*****************************************************************************
2  * bitmap_font.hpp
3  *****************************************************************************
4  * Copyright (C) 2004 VideoLAN
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #ifndef BITMAP_FONT_HPP
25 #define BITMAP_FONT_HPP
26
27 #include "generic_font.hpp"
28 #include <string>
29
30 class GenericBitmap;
31
32
33 /// Class to handle bitmap fonts
34 class BitmapFont: public GenericFont
35 {
36     public:
37         BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
38                     const string &rType );
39         virtual ~BitmapFont() {}
40
41         virtual bool init() { return true; }
42
43         /// Render a string on a bitmap.
44         /// If maxWidth != -1, the text is truncated with '...'
45         virtual GenericBitmap *drawString( const UString &rString,
46             uint32_t color, int maxWidth = -1 ) const;
47
48         /// Get the font size
49         virtual int getSize() const { return 12; }
50
51     private:
52         /// Description of a glyph
53         struct Glyph_t
54         {
55             Glyph_t(): m_xPos( -1 ), m_yPos( 0 ) {}
56             int m_xPos, m_yPos;
57         };
58
59         /// Bitmap
60         const GenericBitmap &m_rBitmap;
61         /// Glyph size
62         int m_width, m_height;
63         /// Horizontal advance between two characters
64         int m_advance;
65         /// Horizontal advance for non-displayable characters
66         int m_skip;
67         /// Character table
68         Glyph_t m_table[256];
69 };
70
71 #endif