Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / graphics / FGrp_IFont.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /*
19  * @file        FGrp_IFont.h
20  * @brief       This is the header file for _IFont class.
21  *
22  */
23
24 #ifndef _FGRP_INTERNAL_IFONT_H_
25 #define _FGRP_INTERNAL_IFONT_H_
26
27 #include <memory>
28 #include <tr1/memory>
29
30 #include <FBaseColHashMapT.h>
31
32 #include "util/FGrp_UtilType.h"
33
34
35 namespace Tizen { namespace Graphics
36 {
37
38 class _FontRsrcManager;
39
40 class _IFont
41 {
42 public:
43         //! Enumerated definition of the font style.
44         enum Style
45         {
46                 STYLE_NONE = 0,      //!< Basic style.
47                 STYLE_ITALIC = 1,    //!< Italic style.
48                 STYLE_BOLD = 2,      //!< Bold style.
49                 STYLE_UNDERLINE = 4, //!< Underline style.
50                 STYLE_BACKSLANT = 8  //!< Reverse italic style.
51         };
52
53         //! Enumerated definition of the font quality.
54         enum Quality
55         {
56                 QUALITY_MONO = 0,    //!< Glyph of 1-bit form.
57                 QUALITY_LOW = 1,     //!< Low quality of 8-bit form.
58                 QUALITY_MEDIUM = 2,  //!< Medium quality of 8-bit form.
59                 QUALITY_HIGH = 3     //!< High quality of 8-bit form.
60         };
61
62         //! Enumerated definition of the font capabilities.
63         enum Capability
64         {
65                 CAPS_SCALABLE = 0x0001,       //!< Support of the scalable font.
66                 CAPS_ANGLE = 0x0002,          //!< Support of the angle.
67                 CAPS_X_EXPANSION = 0x0004,    //!< Support of the expansion of the font.
68                 CAPS_BOLDWEIGHT = 0x0008,     //!< Support of the bold weight of the font.
69                 CAPS_QUALITY_MONO = 0x0010,   //!< Support of the white & black font.
70                 CAPS_QUALITY_LOW = 0x0020,    //!< Support of the low quality in the gray map font.
71                 CAPS_QUALITY_MEDIUM = 0x0040, //!< Support of the medium quality in the gray map font.
72                 CAPS_QUALITY_HIGH = 0x0080    //!< Support of the high quality in the gray map font.
73         };
74
75         //! Attrib structure
76         struct Attrib
77         {
78                 long size;               //!< Size of the font. (26.6 fixed point unit)
79                 unsigned int style;      //!< Style of the font. (_IFont::Style)
80                 int quality;             //!< Quality of the font. (_IFont::Quality)
81                 float angle;             //!< Angle of the font.
82                 long xExpansion;         //!< Expansion of the font.
83                 long boldWeight;         //!< Bold weight of the font
84         };
85
86         //! GlyphBitmap structure
87         struct GlyphBitmap
88         {
89                 long width;                   //!< Horizontal size of an image buffer.
90                 long height;                  //!< Vertical size of an image buffer.
91                 long bytesPerLine;            //!< The number of bytes to represent one horizontal line in buffer.
92                 unsigned long depth;          //!< The number of bits to compose one pixel.
93                 unsigned char* pBitmap;        //!< Start address of an image buffer.
94         };
95
96         //! Glyph structure
97         struct Glyph
98         {
99                 unsigned long id;            //!< Internal identifier of the font.
100                 long xOffset;                //!< Starting point of displaying the font.
101                 long yOffset;                //!< Starting point of displaying the font.
102                 long xAdvance;               //!< Distance to move for displaying the next font.
103                 long yAdvance;               //!< Distance to move for displaying the next font.
104                 long hasOwnerShip;
105                 GlyphBitmap image;           //!< Image information of a glyph.
106                 void* ptrAux;                //!< Internal data for each target.
107         };
108
109         //! Property structure
110         struct Property
111         {
112                 int fontCaps;            //!< Flag for the font capability. (_IFont::Capability)
113                 int styleCaps;           //!< Flag for the font style capability. (_IFont::Style)
114                 unsigned long minSize;   //!< Minimal size of the supportable font.
115                 unsigned long maxSize;   //!< Maximal size of the supportable font.
116
117                 const char* pEngineName;  //!< Name of the font engine.
118                 const char* pFamilyName;  //!< Name of the font family.
119                 const char* pStyleName;   //!< Name of the font style.
120                 long maxWidth;           //!< Maximal width of this font data.
121                 long maxHeight;          //!< Maximal height of this font data.
122                 long baseLine;           //!< BaseLine of this font data.
123                 long ascender;           //!< Ascender of this font data.
124                 long descender;          //!< Descender of this font data.
125                 long leading;            //!< Leading of this font data.
126         };
127
128         virtual ~_IFont(void) {}
129
130         typedef std::tr1::shared_ptr<_IFont> SharedFontResource;
131
132         //! Changes the attribute using fontAttrib.
133         virtual bool SetAttrib(const Attrib& fontAttrib) = 0;
134         //! Gets current attribute and store it in fontAttrib.
135         virtual bool GetAttrib(Attrib& fontAttrib) const = 0;
136
137         //! Gets the value of the interval correctness between two characters.
138         virtual bool GetKerning(unsigned long ch1, unsigned long ch2, long& xVector, long& yVector) const = 0;
139
140         //! Loads the font glyph data for displaying font.
141         virtual bool LoadGlyph(unsigned long character, Glyph** pFontGlyphData) = 0;
142         //! Releases the resource of the font glyph data that is not needed any more.
143         virtual bool UnloadGlyph(Glyph** pFontGlyphData) = 0;
144         //! Check if specified glyph is included.
145         virtual unsigned long CheckGlyph(unsigned long character) = 0;
146
147         //! Gets the support range and the property for this font engine.
148         virtual bool GetFontProperty(Property& property) const = 0;
149
150         //! Harfbuzz test
151         virtual bool GetGlyphList(const _Util::String& text, Tizen::Base::Collection::IListT<Glyph *>& out, bool isRtl, int script) const = 0;
152
153         //! Gets the font fallback map.
154         virtual Tizen::Base::Collection::HashMapT<Tizen::Base::String, SharedFontResource>* GetFallbackMap(void) = 0;
155
156 protected:
157         //! Initializes a font instance with the font data on the memory buffer.
158         virtual bool Create(const void* pBuffer, long bufSize, long face = 0) = 0;
159         //! Initializes a font instance with the font file.
160         virtual bool Create(const char* pFilePath, long face = 0) = 0;
161         //! Initializes a font instance with the font data on the static memory buffer.
162         virtual bool CreateStatic(const void* pBuffer, long bufSize, long face = 0) = 0;
163         //! Reloads a font instance with the font data on the memory buffer.
164         virtual bool Reload(const void* pBuffer, long bufSize, long face = 0) = 0;
165         //! Reloads a font instance with the font file
166         virtual bool Reload(const char* filePath, long face = 0) = 0;
167         //! Destroys the instance.
168         virtual void Destroy(void) = 0;
169         //! Finds glyph in the cache
170         virtual bool FindCache(unsigned long character, int size, int style, Glyph** pOut) = 0;
171         //! Adds glyph in the cache
172         virtual bool AddCache(unsigned long character, int size, int style, Glyph* pGlyph) = 0;
173         //! Clean cache
174         virtual bool CleanCache(void) = 0;
175
176 private:
177         friend class _FontRsrcManager;
178 }; // _IFont
179
180 struct _FontResource
181 {
182         std::auto_ptr<_IFont> first;
183         //std::auto_ptr<_FontCache> second;
184 };
185
186 }} // Tizen::Graphics
187
188 #endif // _FGRP_INTERNAL_IFONT_H_