Merge "Make GlyphBufferData as another class" into devel/master
[platform/core/uifw/dali-adaptor.git] / third-party / glyphy / vector-font-cache.h
1 #ifndef DALI_INTERNAL_TEXT_ABSTRACTION_VECTOR_FONT_CACHE_H
2 #define DALI_INTERNAL_TEXT_ABSTRACTION_VECTOR_FONT_CACHE_H
3
4 /*
5  * Copyright (c) 2019 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 <string>
23 #include <ft2build.h>
24 #include FT_FREETYPE_H
25 #include FT_GLYPH_H
26 #include <dali/integration-api/debug.h>
27
28 // INTERNAL INCLUDES
29 #include <dali/devel-api/text-abstraction/glyph-info.h>
30 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
31
32 namespace Dali
33 {
34
35 namespace TextAbstraction
36 {
37
38 namespace Internal
39 {
40
41 /**
42  * A cache of vector-based font data.
43  */
44 class VectorFontCache
45 {
46 public:
47
48   /**
49    * Constructor
50    */
51   VectorFontCache( FT_Library freeTypeLibrary );
52
53   /**
54    * Destructor
55    */
56   ~VectorFontCache();
57
58   /**
59    * @brief Get the font ID for a vector-based font.
60    *
61    * @param[in] url The path to the font file.
62    * @return A valid font ID, or zero if the font does not exist.
63    */
64   FontId GetFontId( const std::string& url );
65
66   /**
67    * @brief Get the unscaled metrics for a glyph.
68    *
69    * @param[in] vectorFontId The font ID for a vector-based font.
70    * @param[in,out] array A glyph-info structure with initialized FontId & GlyphIndex value.
71    * On return the size, bearing and advance values will be set.
72    */
73   void GetGlyphMetrics( FontId vectorFontId, GlyphInfo& glyph_info );
74
75   /**
76    * @brief Get the vector representation of a glyph.
77    *
78    * @param[in] vectorFontId The font ID for a vector-based font.
79    * @param[in] fontId The equivalent font ID.
80    * @param[in] glyphIndex The index of a glyph within the specified font.
81    * @param[out] blob A blob of data; this is owned by VectorFontCache and should be copied by the caller of GetVectorBlob().
82    * @param[out] blobLength The length of the blob data, or zero if the blob creation failed.
83    * @param[out] nominalWidth The width of the blob.
84    * @param[out] nominalHeight The height of the blob.
85    */
86   void GetVectorBlob( FontId vectorFontId, FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight );
87
88 private:
89
90   /**
91    * @brief Get the font ID for a vector-based font.
92    *
93    * @param[in] url The path to the font file.
94    * @param[out] fontId A valid font ID, or zero if the font does not exist.
95    * @return True if the font was found.
96    */
97   bool FindFont( const std::string& url, FontId& fontId ) const;
98
99   /**
100    * @brief Add a new vector-based font to the cache.
101    *
102    * @param[in] url The path to the font file.
103    * @return A valid font ID, or zero if the font does not exist.
104    */
105   FontId CreateFont( const std::string& url );
106
107   // Undefined copy constructor.
108   VectorFontCache( const VectorFontCache& );
109
110   // Undefined assignment constructor.
111   VectorFontCache& operator=( const VectorFontCache& );
112
113 private:
114
115   struct Impl;
116   Impl* mImpl;
117 };
118
119 } // namespace Internal
120
121 } // namespace TextAbstraction
122
123 } // namespace Dali
124
125 #endif // DALI_INTERNAL_TEXT_ABSTRACTION_VECTOR_FONT_CACHE_H