]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/ft2_font.hpp
* all : skeleton of a future bitmap font support
[vlc] / modules / gui / skins2 / src / ft2_font.hpp
1 /*****************************************************************************
2  * ft2_font.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifndef FT2_FONT_HPP
26 #define FT2_FONT_HPP
27
28 #include <ft2build.h>
29 #include FT_FREETYPE_H
30 #include FT_GLYPH_H
31 #include <string>
32
33 #include "generic_font.hpp"
34
35 class UString;
36
37
38 /// Freetype2 font
39 class FT2Font: public GenericFont
40 {
41     public:
42         FT2Font( intf_thread_t *pIntf, const string &rName, int size );
43         virtual ~FT2Font();
44
45         /// Initalize the object. Returns false if it failed
46         virtual bool init();
47
48         /// Render a string on a bitmap.
49         /// If maxWidth != -1, the text is truncated with '...'
50         virtual GenericBitmap *drawString( const UString &rString,
51             uint32_t color, int maxWidth = -1 ) const;
52
53         /// Get the text height
54         virtual int getSize() const { return m_height; }
55
56     private:
57         /// File name
58         const string m_name;
59         /// Buffer to store the font
60         void *m_buffer;
61         /// Pixel size of the font
62         int m_size;
63         /// Handle to FT library
64         FT_Library m_lib;
65         /// Font face
66         FT_Face m_face;
67         /// Font metrics
68         int m_height, m_ascender, m_descender;
69         /// Index, glyph, width and advance of the dot symbol
70         int m_dotIndex;
71         FT_Glyph m_dotGlyph;
72         int m_dotWidth;
73         int m_dotAdvance;
74 };
75
76
77 #endif