Merge "Combine Internal::ProxyObject & Internal::Object" into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / text / font-layout.h
1 #ifndef __DALI_INTERNAL_FONT_LAYOUT_H__
2 #define __DALI_INTERNAL_FONT_LAYOUT_H__
3
4 /*
5  * Copyright (c) 2014 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
22 // INTERNAL INCLUDES
23 #include <dali/integration-api/glyph-set.h>
24 #include <dali/public-api/math/vector2.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 /**
33  * Structure contains the information required to layout text.
34  * Contains the fonts global metrics, DPI, pad adjust and units per EM.
35  * All members are POD.
36  *
37  * Font-Metrics class will create and and own this struct.
38  * Text-Metric objects will hold a read only pointer to this struct.
39  *
40  */
41 struct FontLayout
42 {
43   /**
44    * Constructor
45    */
46   FontLayout();
47
48   /**
49    * Constructor
50    * @param unitsPerEM units per EM
51    * @param dpi dots per inch
52    */
53   FontLayout( float unitsPerEM, Vector2 dpi );
54
55   /**
56    * Set the global metrics
57    * @param metrics dali integration global metric object
58    */
59   void SetMetrics( const Dali::Integration::GlobalMetrics &metrics );
60
61   /**
62    * Returns the global metrics
63    * @return global metrics
64    */
65   const Dali::Integration::GlobalMetrics& GetGlobalMetrics() const;
66
67   /**
68    * Get a multiplier value to scale measurements to pixels based on the given pointSize
69    * @param[in] pointSize The pointSize
70    * @return A multiplier value to scale measurements to pixels
71    */
72   float GetUnitsToPixels( const float pointSize ) const;
73
74   /**
75    * The line height is the vertical distance between the top of the highest character
76    * to the bottom of the lowest character
77    * @return the line height of the font in pixels
78    */
79   float GetLineHeight() const;
80
81   /**
82    * The ascender is the vertical distance from the
83    * baseline to the highest character coordinate in a font face.
84    * @return the ascender in pixels
85    */
86   float GetAscender() const;
87
88   /**
89    * Returns the underline position for this font.
90    * @return The underline position.
91    */
92   float GetUnderlinePosition() const;
93
94   /**
95    * Returns the thickness of the underline for this font.
96    * @return The thickness of the underline.
97    */
98   float GetUnderlineThickness() const;
99
100   /**
101    * Return the units per em for this font.
102    * @return units per em
103    */
104   float GetUnitsPerEM() const;
105
106   /**
107    * Returns the width of the widest glyph in this font in font units
108    * @return Width of widest glyph
109    */
110   float GetMaxWidth() const;
111
112   /**
113    * Returns the height of the tallest glyph in this font in font units
114    * @return Hight of tallest glyph
115    */
116   float GetMaxHeight() const;
117
118   /**
119    * Returns the horizontal pad adjust for this font in font units
120    * @return Horizontal pad adjust
121    */
122   float GetPadAdjustX() const;
123
124   /**
125    * Returns the vertical pad adjust for this font in font units
126    * @return Vertical pad adjust
127    */
128   float GetPadAdjustY() const;
129
130   /**
131    * Returns the dots per inch for this font
132    * @return dpi
133    */
134   Vector2 GetDpi() const;
135
136
137 private:
138
139   Dali::Integration::GlobalMetrics     mMetrics;      ///< integration Metrics
140   float                                mUnitsPerEM;   ///< Font units/EM. Used to convert from units to pixels. Equal to (1.0f / GlobalMetrics.unitsPerEm)
141   Vector2                              mDpi;          ///< Dots per inch. Used to convert from units to pixels.
142 };
143
144 } // namespace Internal
145
146 } // namespace Dali
147
148 #endif // __DALI_INTERNAL_FONT_LAYOUT_H__