2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
20 * @brief This is the header file for _IFont class.
24 #ifndef _FGRP_INTERNAL_IFONT_H_
25 #define _FGRP_INTERNAL_IFONT_H_
31 #ifdef USE_HASHMAP_FOR_FONT
32 #include <FBaseColHashMapT.h>
35 #include <FBaseColIListT.h>
38 #include "util/FGrp_UtilType.h"
40 namespace Tizen { namespace Graphics
43 class _FontRsrcManager;
48 typedef std::tr1::shared_ptr<_IFont> SharedFontResource;
49 #ifdef USE_HASHMAP_FOR_FONT
50 typedef Tizen::Base::Collection::HashMapT <_Util::WString, SharedFontResource> FontMapT;
52 typedef std::list<std::pair<_Util::WString, SharedFontResource> > FontMapT;
55 //! Enumerated definition of the font style.
58 STYLE_NONE = 0, //!< Basic style.
59 STYLE_ITALIC = 1, //!< Italic style.
60 STYLE_BOLD = 2, //!< Bold style.
61 STYLE_UNDERLINE = 4, //!< Underline style.
62 STYLE_BACKSLANT = 8 //!< Reverse italic style.
65 //! Enumerated definition of the font quality.
68 QUALITY_MONO = 0, //!< Glyph of 1-bit form.
69 QUALITY_LOW = 1, //!< Low quality of 8-bit form.
70 QUALITY_MEDIUM = 2, //!< Medium quality of 8-bit form.
71 QUALITY_HIGH = 3 //!< High quality of 8-bit form.
74 //! Enumerated definition of the font capabilities.
77 CAPS_SCALABLE = 0x0001, //!< Support of the scalable font.
78 CAPS_ANGLE = 0x0002, //!< Support of the angle.
79 CAPS_X_EXPANSION = 0x0004, //!< Support of the expansion of the font.
80 CAPS_BOLDWEIGHT = 0x0008, //!< Support of the bold weight of the font.
81 CAPS_QUALITY_MONO = 0x0010, //!< Support of the white & black font.
82 CAPS_QUALITY_LOW = 0x0020, //!< Support of the low quality in the gray map font.
83 CAPS_QUALITY_MEDIUM = 0x0040, //!< Support of the medium quality in the gray map font.
84 CAPS_QUALITY_HIGH = 0x0080 //!< Support of the high quality in the gray map font.
90 _Util::FixedPoint26_6 size; //!< Size of the font. (26.6 fixed point unit)
91 unsigned int style; //!< Style of the font. (_IFont::Style)
92 int quality; //!< Quality of the font. (_IFont::Quality)
93 float angle; //!< Angle of the font.
94 long xExpansion; //!< Expansion of the font.
95 _Util::FixedPoint26_6 boldWeight; //!< Bold weight of the font
98 //! GlyphBitmap structure
101 long width; //!< Horizontal size of an image buffer.
102 long height; //!< Vertical size of an image buffer.
103 long bytesPerLine; //!< The number of bytes to represent one horizontal line in buffer.
104 unsigned long depth; //!< The number of bits to compose one pixel.
105 unsigned char* pBitmap; //!< Start address of an image buffer.
111 unsigned long id; //!< Internal identifier of the font.
112 _Util::FixedPoint22_10 xOffset; //!< Starting point of displaying the font.
113 _Util::FixedPoint22_10 yOffset; //!< Starting point of displaying the font.
114 _Util::FixedPoint22_10 xAdvance; //!< Distance to move for displaying the next font.
115 _Util::FixedPoint22_10 yAdvance; //!< Distance to move for displaying the next font.
117 GlyphBitmap image; //!< Image information of a glyph.
118 void* ptrAux; //!< Internal data for each target.
121 //! Size Property structure
124 _Util::FixedPoint26_6 minSize; //!< Minimal size of the supportable font.
125 _Util::FixedPoint26_6 maxSize; //!< Maximal size of the supportable font.
127 _Util::FixedPoint26_6 maxWidth; //!< Maximal width of this font data.
128 _Util::FixedPoint26_6 maxHeight; //!< Maximal height of this font data.
129 _Util::FixedPoint26_6 baseLine; //!< BaseLine of this font data.
130 _Util::FixedPoint26_6 ascender; //!< Ascender of this font data.
131 _Util::FixedPoint26_6 descender; //!< Descender of this font data.
132 _Util::FixedPoint26_6 leading; //!< Leading of this font data.
135 //! Font Property structure
138 int fontCaps; //!< Flag for the font capability. (_IFont::Capability)
139 int styleCaps; //!< Flag for the font style capability. (_IFont::Style)
141 const char* pEngineName; //!< Name of the font engine.
142 const char* pFamilyName; //!< Name of the font family.
143 const char* pStyleName; //!< Name of the font style.
144 long styleFlag; //!< flag value of the font style. (Regular = 0, Bold = 2)
145 long weightClass; //!< Value of the font WeightClass.
148 virtual ~_IFont(void) {}
150 //! Changes the attribute using fontAttrib.
151 virtual bool SetAttrib(const Attrib& fontAttrib) = 0;
152 //! Gets current attribute and store it in fontAttrib.
153 virtual bool GetAttrib(Attrib& fontAttrib) const = 0;
155 //! Gets the value of the interval correctness between two characters.
156 virtual bool GetKerning(unsigned long ch1, unsigned long ch2, long& xVector, long& yVector) const = 0;
158 //! Loads the font glyph data for displaying font.
159 virtual bool LoadGlyph(unsigned long character, Glyph** pFontGlyphData) = 0;
160 //! Releases the resource of the font glyph data that is not needed any more.
161 virtual bool UnloadGlyph(Glyph** pFontGlyphData) = 0;
162 //! Check if specified glyph is included.
163 virtual unsigned long CheckGlyph(unsigned long character) = 0;
165 virtual float GetFontSizeFromMaxHeight(_Util::FixedPoint26_6 expectedMaxHeight) const = 0;
167 //! Gets the support range and the property for this font engine.
168 virtual bool GetFontSizeProperty(SizeProperty& sizeProperty) const = 0;
169 virtual bool GetFontProperty(Property& property) const = 0;
172 virtual bool GetGlyphList(const _Util::String& text, Tizen::Base::Collection::IListT<Glyph *>& out, int script) = 0;
174 //! Gets the font fallback map.
175 virtual FontMapT* GetFallbackMap(void) = 0;
177 virtual bool IsEmoji(void) const = 0;
180 //! Initializes a font instance with the font data on the memory buffer.
181 virtual bool Create(const void* pBuffer, long bufSize, long face = 0) = 0;
182 //! Initializes a font instance with the font file.
183 virtual bool Create(const char* pFilePath, long face = 0) = 0;
184 //! Initializes a font instance with the font data on the static memory buffer.
185 virtual bool CreateStatic(const void* pBuffer, long bufSize, long face = 0) = 0;
186 //! Reloads a font instance with the font data on the memory buffer.
187 virtual bool Reload(const void* pBuffer, long bufSize, long face = 0) = 0;
188 //! Reloads a font instance with the font file
189 virtual bool Reload(const char* filePath, long face = 0) = 0;
190 //! Destroys the instance.
191 virtual void Destroy(void) = 0;
192 //! Finds glyph in the cache
193 virtual bool FindCache(unsigned long glyphIndex, _Util::FixedPoint26_6 size, int style, Glyph** pOut) = 0;
194 //! Adds glyph in the cache
195 virtual bool AddCache(unsigned long glyphIndex, _Util::FixedPoint26_6 size, int style, Glyph* pGlyph) = 0;
197 virtual bool CleanCache(void) = 0;
200 friend class _FontRsrcManager;
203 }} // Tizen::Graphics
205 #endif // _FGRP_INTERNAL_IFONT_H_