Refactored font-client-plugin-impl
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / text-abstraction / plugin / bitmap-font-cache-item.h
1 #ifndef DALI_INTERNAL_TEXT_ABSTRACTION_BITMAP_FONT_CACHE_ITEM_H
2 #define DALI_INTERNAL_TEXT_ABSTRACTION_BITMAP_FONT_CACHE_ITEM_H
3
4 /*
5  * Copyright (c) 2021 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 // INTERNAL INCLUDES
21 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
22 #include <dali/devel-api/text-abstraction/bitmap-font.h>
23 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
24
25 #include <dali/internal/text/text-abstraction/plugin/font-cache-item-interface.h>
26 #include <ft2build.h>
27 #include FT_FREETYPE_H
28
29 namespace Dali::TextAbstraction::Internal
30 {
31 /**
32  * @brief Stores a bitmap font and its pixel buffers per glyph.
33  */
34 struct BitmapFontCacheItem : public FontCacheItemInterface
35 {
36   /**
37    * Constructor
38    *
39    * @param[in] bitmapFont The font to cache
40    * @param[in] fontId The id of the font
41    */
42   BitmapFontCacheItem(const BitmapFont& bitmapFont, FontId fontId);
43
44   /**
45    * @copydoc FontCacheItemInterface::GetFontMetrics()
46    */
47   void GetFontMetrics(FontMetrics& metrics, unsigned int dpiVertical) const override;
48
49   /**
50    * @copydoc FontCacheItemInterface::GetGlyphMetrics()
51    */
52   bool GetGlyphMetrics(GlyphInfo& glyph, unsigned int dpiVertical, bool horizontal) const override;
53
54   /**
55    * @copydoc FontCacheItemInterface::CreateBitmap()
56    */
57   void CreateBitmap(GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth, bool isItalicRequired, bool isBoldRequired) const override;
58
59   /**
60    * @copydoc FontCacheItemInterface::IsColorGlyph()
61    */
62   bool IsColorGlyph(GlyphIndex glyphIndex) const override
63   {
64     return true;
65   }
66
67   /**
68    * @copydoc FontCacheItemInterface::IsCharacterSupported()
69    */
70   bool IsCharacterSupported(Character character) override;
71
72   /**
73    * @copydoc FontCacheItemInterface::GetPointSize()
74    */
75   PointSize26Dot6 GetPointSize() const override
76   {
77     return TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
78   }
79
80   /**
81    * @copydoc FontCacheItemInterface::GetGlyphIndex()
82    */
83   GlyphIndex GetGlyphIndex(Character character) const override
84   {
85     return 0u;
86   }
87
88   /**
89    * @copydoc FontCacheItemInterface::GetTypeface()
90    */
91   FT_Face GetTypeface() const override
92   {
93     return nullptr;
94   }
95
96   /**
97    * @copydoc FontCacheItemInterface::HasItalicStyle()
98    */
99   bool HasItalicStyle() const override
100   {
101     return false;
102   }
103
104   BitmapFont                      font;         ///< The bitmap font.
105   std::vector<Devel::PixelBuffer> pixelBuffers; ///< The pixel buffers of the glyphs.
106   FontId                          id;           ///< Index to the vector with the cache of font's ids.
107 };
108
109 } // namespace Dali::TextAbstraction::Internal
110
111 #endif //DALI_INTERNAL_TEXT_ABSTRACTION_BITMAP_FONT_CACHE_ITEM_H