Returning GlypInfo information in floats rather than fractional26.6
[platform/core/uifw/dali-adaptor.git] / text / dali / internal / text-abstraction / font-client-impl.h
1 #ifndef __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H__
2 #define __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/text-abstraction/font-client.h>
26
27 namespace Dali
28 {
29
30 namespace TextAbstraction
31 {
32
33 namespace Internal
34 {
35
36 /**
37  * Conversion from Fractional26.6 to float
38  */
39 namespace
40 {
41    const float FROM_266 = 1.0f / 64.0f;
42 }
43
44 /**
45  * Implementation of the FontClient
46  */
47 class FontClient : public Dali::BaseObject
48 {
49 public:
50
51   /**
52    * Constructor
53    */
54   FontClient();
55
56   /**
57    * Destructor
58    */
59   ~FontClient();
60
61   /**
62    * @copydoc Dali::FontClient::Get()
63    */
64   static Dali::TextAbstraction::FontClient Get();
65
66   /**
67    * @copydoc Dali::FontClient::SetDpi()
68    */
69   void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
70
71   /**
72    * @copydoc Dali::FontClient::GetSystemFonts()
73    */
74   void GetSystemFonts( FontList& systemFonts );
75
76   /**
77    * @copydoc Dali::FontClient::FindSystemFont()
78    */
79   bool FindSystemFont( Character charcode, FontDescription& systemFont );
80
81   /**
82    * @copydoc Dali::FontClient::GetFontId()
83    */
84   FontId GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex );
85
86   /**
87    * @copydoc Dali::FontClient::FindDefaultFont()
88    */
89   FontId FindDefaultFont( Character charcode );
90
91   /**
92    * @copydoc Dali::FontClient::GetFontMetrics()
93    */
94   void GetFontMetrics( FontId fontId, FontMetrics& metrics );
95
96   /**
97    * @copydoc Dali::FontClient::GetGlyphIndex()
98    */
99   GlyphIndex GetGlyphIndex( FontId fontId, Character charcode );
100
101   /**
102    * @copydoc Dali::FontClient::CreateMetrics()
103    */
104   bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
105
106   /**
107    * @copydoc Dali::FontClient::CreateBitmap()
108    */
109   BitmapImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
110
111 private:
112
113   /**
114    * Helper for lazy initialization.
115    */
116   void CreatePlugin();
117
118   // Undefined copy constructor.
119   FontClient( const FontClient& );
120
121   // Undefined assignment constructor.
122   FontClient& operator=( FontClient& );
123
124 private:
125
126   struct Plugin;
127   Plugin* mPlugin;
128
129   // Allows DPI to be set without loading plugin
130   unsigned int mDpiHorizontal;
131   unsigned int mDpiVertical;
132
133 }; // class FontClient
134
135 } // namespace Internal
136
137 inline static Internal::FontClient& GetImplementation(FontClient& fontClient)
138 {
139   DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
140   BaseObject& handle = fontClient.GetBaseObject();
141   return static_cast<Internal::FontClient&>(handle);
142 }
143
144 inline static const Internal::FontClient& GetImplementation(const FontClient& fontClient)
145 {
146   DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
147   const BaseObject& handle = fontClient.GetBaseObject();
148   return static_cast<const Internal::FontClient&>(handle);
149 }
150
151 } // namespace TextAbstraction
152
153 } // namespace Dali
154
155 #endif // __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H__