1 #ifndef DALI_TEXT_ABSTRACTION_INTERNAL_FONT_FACE_CACHE_ITEM_H
2 #define DALI_TEXT_ABSTRACTION_INTERNAL_FONT_FACE_CACHE_ITEM_H
5 * Copyright (c) 2022 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.
21 #include <dali/internal/text/text-abstraction/plugin/font-cache-item-interface.h>
22 #include <dali/internal/text/text-abstraction/plugin/font-face-glyph-cache-manager.h>
23 #include <dali/internal/text/text-abstraction/plugin/harfbuzz-proxy-font.h>
26 #include <fontconfig/fontconfig.h>
27 #include <memory> // for std::unique_ptr
31 #include FT_FREETYPE_H
35 #include FT_SYNTHESIS_H
37 namespace Dali::TextAbstraction::Internal
40 * @brief Caches the FreeType face and font metrics of the triplet 'path to the font file name, font point size and face index'.
42 struct FontFaceCacheItem : public FontCacheItemInterface
44 FontFaceCacheItem(const FT_Library& freeTypeLibrary,
46 GlyphCacheManager* glyphCacheManager,
48 PointSize26Dot6 requestedPointSize,
50 const FontMetrics& metrics);
52 FontFaceCacheItem(const FT_Library& freeTypeLibrary,
54 GlyphCacheManager* glyphCacheManager,
56 PointSize26Dot6 requestedPointSize,
58 const FontMetrics& metrics,
64 FontFaceCacheItem(const FontFaceCacheItem& rhs) = delete; // Do not use copy construct
65 FontFaceCacheItem(FontFaceCacheItem&& rhs);
70 * @copydoc FontCacheItemInterface::GetFontMetrics()
72 void GetFontMetrics(FontMetrics& metrics, unsigned int dpiVertical) const override;
75 * @copydoc FontCacheItemInterface::GetGlyphMetrics()
77 bool GetGlyphMetrics(GlyphInfo& glyphInfo, unsigned int dpiVertical, bool horizontal) const override;
80 * @copydoc FontCacheItemInterface::CreateBitmap()
82 void CreateBitmap(GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth, bool isItalicRequired, bool isBoldRequired) const override;
85 * @copydoc FontCacheItemInterface::IsColorGlyph()
87 bool IsColorGlyph(GlyphIndex glyphIndex) const override;
90 * @copydoc FontCacheItemInterface::IsCharacterSupported()
92 bool IsCharacterSupported(Character character) override;
95 * @copydoc FontCacheItemInterface::GetPointSize()
97 PointSize26Dot6 GetPointSize() const override
99 return mRequestedPointSize;
103 * @copydoc FontCacheItemInterface::GetGlyphIndex()
105 GlyphIndex GetGlyphIndex(Character character) const override;
108 * @copydoc FontCacheItemInterface::GetGlyphIndex()
110 GlyphIndex GetGlyphIndex(Character character, Character variantSelector) const override;
113 * @copydoc FontCacheItemInterface::GetTypeface()
115 FT_Face GetTypeface() const override
117 return mFreeTypeFace;
121 * @copydoc FontCacheItemInterface::GetHarfBuzzFont()
123 HarfBuzzFontHandle GetHarfBuzzFont(const uint32_t& horizontalDpi, const uint32_t& verticalDpi) override;
126 * @copydoc FontCacheItemInterface::HasItalicStyle()
128 bool HasItalicStyle() const override
130 return (0u != (mFreeTypeFace->style_flags & FT_STYLE_FLAG_ITALIC));
134 const FT_Library& mFreeTypeLibrary; ///< A handle to a FreeType library instance.
135 FT_Face mFreeTypeFace; ///< The FreeType face.
137 GlyphCacheManager* mGlyphCacheManager; ///< The reference of Glyph cache manager. Owned from font-client-plugin-cache-handler.
138 std::unique_ptr<HarfBuzzProxyFont> mHarfBuzzProxyFont; ///< The harfbuzz font. It will store harfbuzz relate data.
140 FontPath mPath; ///< The path to the font file name.
141 PointSize26Dot6 mRequestedPointSize; ///< The font point size.
142 FaceIndex mFaceIndex; ///< The face index.
143 FontMetrics mMetrics; ///< The font metrics.
144 _FcCharSet* mCharacterSet; ///< Pointer with the range of characters.
145 int mFixedSizeIndex; ///< Index to the fixed size table for the requested size.
146 float mFixedWidthPixels; ///< The height in pixels (fixed size bitmaps only)
147 float mFixedHeightPixels; ///< The height in pixels (fixed size bitmaps only)
148 unsigned int mVectorFontId; ///< The ID of the equivalent vector-based font
149 FontId mFontId; ///< Index to the vector with the cache of font's ids.
150 bool mIsFixedSizeBitmap : 1; ///< Whether the font has fixed size bitmaps.
151 bool mHasColorTables : 1; ///< Whether the font has color tables.
154 } // namespace Dali::TextAbstraction::Internal
156 #endif //DALI_TEXT_ABSTRACTION_INTERNAL_FONT_FACE_CACHE_ITEM_H