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,
47 PointSize26Dot6 requestedPointSize,
49 const FontMetrics& metrics);
51 FontFaceCacheItem(const FT_Library& freeTypeLibrary,
54 PointSize26Dot6 requestedPointSize,
56 const FontMetrics& metrics,
62 FontFaceCacheItem(const FontFaceCacheItem& rhs) = delete; // Do not use copy construct
63 FontFaceCacheItem(FontFaceCacheItem&& rhs);
68 * @copydoc FontCacheItemInterface::GetFontMetrics()
70 void GetFontMetrics(FontMetrics& metrics, unsigned int dpiVertical) const override;
73 * @copydoc FontCacheItemInterface::GetGlyphMetrics()
75 bool GetGlyphMetrics(GlyphInfo& glyphInfo, unsigned int dpiVertical, bool horizontal) const override;
78 * @copydoc FontCacheItemInterface::CreateBitmap()
80 void CreateBitmap(GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth, bool isItalicRequired, bool isBoldRequired) const override;
83 * @copydoc FontCacheItemInterface::IsColorGlyph()
85 bool IsColorGlyph(GlyphIndex glyphIndex) const override;
88 * @copydoc FontCacheItemInterface::IsCharacterSupported()
90 bool IsCharacterSupported(Character character) override;
93 * @copydoc FontCacheItemInterface::GetPointSize()
95 PointSize26Dot6 GetPointSize() const override
97 return mRequestedPointSize;
101 * @copydoc FontCacheItemInterface::GetGlyphIndex()
103 GlyphIndex GetGlyphIndex(Character character) const override;
106 * @copydoc FontCacheItemInterface::GetGlyphIndex()
108 GlyphIndex GetGlyphIndex(Character character, Character variantSelector) const override;
111 * @copydoc FontCacheItemInterface::GetTypeface()
113 FT_Face GetTypeface() const override
115 return mFreeTypeFace;
119 * @copydoc FontCacheItemInterface::GetHarfBuzzFont()
121 HarfBuzzFontHandle GetHarfBuzzFont(const uint32_t& horizontalDpi, const uint32_t& verticalDpi) override;
124 * @copydoc FontCacheItemInterface::HasItalicStyle()
126 bool HasItalicStyle() const override
128 return (0u != (mFreeTypeFace->style_flags & FT_STYLE_FLAG_ITALIC));
132 const FT_Library& mFreeTypeLibrary; ///< A handle to a FreeType library instance.
133 FT_Face mFreeTypeFace; ///< The FreeType face.
135 std::unique_ptr<GlyphCacheManager> mGlyphCacheManager; ///< The glyph cache manager. It will cache this face's glyphs.
136 std::unique_ptr<HarfBuzzProxyFont> mHarfBuzzProxyFont; ///< The harfbuzz font. It will store harfbuzz relate data.
138 FontPath mPath; ///< The path to the font file name.
139 PointSize26Dot6 mRequestedPointSize; ///< The font point size.
140 FaceIndex mFaceIndex; ///< The face index.
141 FontMetrics mMetrics; ///< The font metrics.
142 _FcCharSet* mCharacterSet; ///< Pointer with the range of characters.
143 int mFixedSizeIndex; ///< Index to the fixed size table for the requested size.
144 float mFixedWidthPixels; ///< The height in pixels (fixed size bitmaps only)
145 float mFixedHeightPixels; ///< The height in pixels (fixed size bitmaps only)
146 unsigned int mVectorFontId; ///< The ID of the equivalent vector-based font
147 FontId mFontId; ///< Index to the vector with the cache of font's ids.
148 bool mIsFixedSizeBitmap : 1; ///< Whether the font has fixed size bitmaps.
149 bool mHasColorTables : 1; ///< Whether the font has color tables.
152 } // namespace Dali::TextAbstraction::Internal
154 #endif //DALI_TEXT_ABSTRACTION_INTERNAL_FONT_FACE_CACHE_ITEM_H