1 #ifndef DALI_TEST_ABSTRACTION_INTERNAL_FONT_FACE_CACHE_ITEM_H
2 #define DALI_TEST_ABSTRACTION_INTERNAL_FONT_FACE_CACHE_ITEM_H
5 * Copyright (c) 2021 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/internal/text/text-abstraction/plugin/font-cache-item-interface.h>
25 #include <fontconfig/fontconfig.h>
29 #include FT_FREETYPE_H
33 #include FT_SYNTHESIS_H
35 namespace Dali::TextAbstraction::Internal
38 * @brief Caches the FreeType face and font metrics of the triplet 'path to the font file name, font point size and face index'.
40 struct FontFaceCacheItem : public FontCacheItemInterface
42 FontFaceCacheItem(FT_Library& freeTypeLibrary,
45 PointSize26Dot6 requestedPointSize,
47 const FontMetrics& metrics);
49 FontFaceCacheItem(FT_Library& freeTypeLibrary,
52 PointSize26Dot6 requestedPointSize,
54 const FontMetrics& metrics,
61 * @copydoc FontCacheItemInterface::GetFontMetrics()
63 void GetFontMetrics(FontMetrics& metrics, unsigned int dpiVertical) const override;
66 * @copydoc FontCacheItemInterface::GetGlyphMetrics()
68 bool GetGlyphMetrics(GlyphInfo& glyph, unsigned int dpiVertical, bool horizontal) const override;
71 * @copydoc FontCacheItemInterface::CreateBitmap()
73 void CreateBitmap(GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth, bool isItalicRequired, bool isBoldRequired) const override;
76 * @copydoc FontCacheItemInterface::IsColorGlyph()
78 bool IsColorGlyph(GlyphIndex glyphIndex) const override;
81 * @copydoc FontCacheItemInterface::IsCharacterSupported()
83 bool IsCharacterSupported(Character character) override;
86 * @copydoc FontCacheItemInterface::GetPointSize()
88 PointSize26Dot6 GetPointSize() const override
90 return mRequestedPointSize;
94 * @copydoc FontCacheItemInterface::GetGlyphIndex()
96 GlyphIndex GetGlyphIndex(Character character) const override;
99 * @copydoc FontCacheItemInterface::GetTypeface()
101 FT_Face GetTypeface() const override
103 return mFreeTypeFace;
107 * @copydoc FontCacheItemInterface::HasItalicStyle()
109 bool HasItalicStyle() const override
111 return (0u != (mFreeTypeFace->style_flags & FT_STYLE_FLAG_ITALIC));
114 FT_Library& mFreeTypeLibrary; ///< A handle to a FreeType library instance.
115 FT_Face mFreeTypeFace; ///< The FreeType face.
116 FontPath mPath; ///< The path to the font file name.
117 PointSize26Dot6 mRequestedPointSize; ///< The font point size.
118 FaceIndex mFaceIndex; ///< The face index.
119 FontMetrics mMetrics; ///< The font metrics.
120 _FcCharSet* mCharacterSet; ///< Pointer with the range of characters.
121 int mFixedSizeIndex; ///< Index to the fixed size table for the requested size.
122 float mFixedWidthPixels; ///< The height in pixels (fixed size bitmaps only)
123 float mFixedHeightPixels; ///< The height in pixels (fixed size bitmaps only)
124 unsigned int mVectorFontId; ///< The ID of the equivalent vector-based font
125 FontId mFontId; ///< Index to the vector with the cache of font's ids.
126 bool mIsFixedSizeBitmap : 1; ///< Whether the font has fixed size bitmaps.
127 bool mHasColorTables : 1; ///< Whether the font has color tables.
130 } // namespace Dali::TextAbstraction::Internal
132 #endif //DALI_TEST_ABSTRACTION_INTERNAL_FONT_FACE_CACHE_ITEM_H