1 #ifndef __DALI_TOOLKIT_TEXT_METRICS_H__
2 #define __DALI_TOOLKIT_TEXT_METRICS_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/devel-api/text-abstraction/font-client.h>
35 typedef IntrusivePtr<Metrics> MetricsPtr;
38 * @brief A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics.
40 class Metrics : public RefObject
45 * Create a new Metrics object
47 static Metrics* New( TextAbstraction::FontClient& fontClient )
49 return new Metrics( fontClient );
53 * @brief Set the maximum Emoji size.
55 * @param[in] emojiSize Emoticons will be scaled to fit this size in pixels.
57 void SetMaxEmojiSize( int emojiSize )
59 mEmojiSize = emojiSize;
63 * @brief Get the maximum Emoji size.
65 * @return The maximum Emoji size.
67 int GetMaxEmojiSize() const
73 * @brief Query the metrics for a font.
75 * @param[in] fontId The ID of the font for the required glyph.
76 * @param[out] metrics The font metrics.
78 void GetFontMetrics( FontId fontId, FontMetrics& metrics )
80 mFontClient.GetFontMetrics( fontId, metrics, mEmojiSize ); // inline for performance
84 * @brief Retrieve the metrics for a series of glyphs.
86 * @param[in,out] array An array of glyph-info structures with initialized FontId & GlyphIndex values.
87 * It may contain the advance and an offset set into the bearing from the shaping tool.
88 * On return, the glyph's size value will be initialized. The bearing value will be updated by adding the font's glyph bearing to the one set by the shaping tool.
89 * @param[in] size The size of the array.
90 * @return True if all of the requested metrics were found.
92 bool GetGlyphMetrics( GlyphInfo* array, uint32_t size )
94 return mFontClient.GetGlyphMetrics( array, size, true, mEmojiSize ); // inline for performance
100 * A reference counted object may only be deleted by calling Unreference()
102 virtual ~Metrics() {}
109 Metrics( TextAbstraction::FontClient& fontClient )
110 : mFontClient( fontClient ),
116 Metrics(const Metrics&);
119 Metrics& operator=(const Metrics& rhs);
123 TextAbstraction::FontClient mFontClient;
130 } // namespace Toolkit
134 #endif // __DALI_TOOLKIT_TEXT_METRICS_H__