[dali_1.0.31] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / internal / event / text / font-metrics-interface.h
1 #ifndef __DALI_FONT_METRICS_INTERFACE_H__
2 #define __DALI_FONT_METRICS_INTERFACE_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 // INTERNAL INCLUDES
22 #include <dali/internal/event/text/resource/font-id.h>
23 #include <dali/internal/event/text/glyph-metric.h>
24 #include <dali/integration-api/text-array.h>
25
26 // EXTERNAL INCLUDES
27 #include <string>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 /**
36  *
37  * Abstract interface for requesting information about a font and its metrics.
38  *
39  */
40 class FontMetricsInterface
41 {
42
43 public:
44
45   /**
46    * Ensures the metrics for each character in the text are loaded and cached.
47    * @param[in] text The text string to load the metrics for.
48    */
49   virtual void LoadMetricsSynchronously( const Integration::TextArray& text ) = 0;
50
51   /**
52    * Gets the metrics for a single character.
53    * The glyph information holds the character dimensions and layout information.
54    * @note LoadMetricsSynchronously() should be called on the string you wish
55    * to get the metrics for, before calling GetGlyph() on each character
56    * @param[in] charIndex character code
57    * @return pointer to a glyph metric object
58    */
59   virtual const GlyphMetric* GetGlyph( uint32_t charIndex ) const = 0;
60
61   /**
62    * Get the unique id for the font.
63    * @return font id
64    */
65   virtual FontId  GetFontId() const = 0;
66
67   /**
68    * Get the font family
69    * @return the font family name
70    */
71   virtual const std::string& GetFontFamilyName() const = 0;
72
73   /**
74    * Get the font style
75    * @return the font style name
76    */
77   virtual const std::string&  GetFontStyleName() const = 0;
78
79   /**
80    * Get the maximum glyph size.
81    * @param[out] width maximum width of a character in the font
82    * @param[out] height maximum height of a character in the font
83    */
84   virtual void GetMaximumGylphSize(float& width, float& height) const = 0;
85
86   /**
87    * Get a multiplier value to scale measurements to pixels based on the given pointSize
88    * @param[in] pointSize The pointSize
89    * @return A multiplier value to scale measurements to pixels
90    */
91   virtual float GetUnitsToPixels(const float pointSize) const = 0;
92
93   /**
94    * The line height is the vertical distance between the top of the highest character
95    * to the bottom of the lowest character
96    * @return the line height of the font in pixels
97    */
98   virtual float GetLineHeight() const = 0;
99
100   /**
101    * The ascender is the vertical distance from the
102    * baseline to the highest character coordinate in a font face.
103    * @return the ascender in pixels
104    */
105   virtual float GetAscender() const = 0;
106
107   /**
108    * Returns the underline position for this font.
109    * @return The underline position.
110    */
111   virtual float GetUnderlinePosition() const = 0;
112
113   /**
114    * Returns the thickness of the underline for this font.
115    * @return The thickness of the underline.
116    */
117   virtual float GetUnderlineThickness() const = 0;
118
119   /**
120    * Returns the width of the widest glyph in this font in pixels
121    * @return Width of widest glyph
122    */
123   virtual float GetMaxWidth() const = 0;
124
125   /**
126    * Returns the height of the tallest glyph in this font in pixels
127    * @return Height of tallest glyph
128    */
129   virtual float GetMaxHeight() const = 0;
130
131   /**
132    * Returns the horizontal pad adjust for this font in pixels
133    * @return Horizontal pad adjust
134    */
135   virtual float GetPadAdjustX() const = 0;
136
137   /**
138    * Returns the vertical pad adjust for this font in pixels
139    * @return Vertical pad adjust
140    */
141   virtual float GetPadAdjustY() const = 0;
142
143
144 protected:
145
146   /**
147    * Constructor
148    */
149   FontMetricsInterface()
150   {
151   }
152
153   /**
154    * Destructor.
155    */
156   virtual ~FontMetricsInterface()
157   {
158   }
159
160   // Undefined copy constructor.
161   FontMetricsInterface( const FontMetricsInterface& );
162
163   // Undefined assignment operator.
164   FontMetricsInterface& operator=( const FontMetricsInterface& );
165
166 };
167
168
169 } // namespace Internal
170
171 } // namespace Dali
172
173 #endif // __DALI_FONT_METRICS_INTERFACE_H__