1 #ifndef DALI_TEST_ABSTRACTION_INTERNAL_FONT_CLIENT_UTILS_H
2 #define DALI_TEST_ABSTRACTION_INTERNAL_FONT_CLIENT_UTILS_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/devel-api/text-abstraction/font-client.h>
24 #include <fontconfig/fontconfig.h>
27 #include FT_FREETYPE_H
31 #include FT_SYNTHESIS_H
33 namespace Dali::TextAbstraction::Internal
35 void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data,
36 unsigned int srcWidth,
37 unsigned int srcHeight,
38 const unsigned char* const srcBuffer,
39 const Pixel::Format srcFormat);
41 void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data,
44 bool moveBuffer = false);
47 * @brief Creates a font family pattern used to match fonts.
49 * @note Need to call FcPatternDestroy to free the resources.
51 * @param[in] fontDescription The font to cache.
53 * @return The pattern.
55 FcPattern* CreateFontFamilyPattern(const FontDescription& fontDescription);
58 * @brief Creates a character set from a given font's @p description.
60 * @note Need to call FcCharSetDestroy to free the resources.
62 * @param[in] description The font's description.
64 * @return A character set.
66 FcCharSet* CreateCharacterSetFromDescription(const FontDescription& description);
68 constexpr int ValueToIndex(int value, const int* const table, unsigned int maxIndex)
72 // Return an invalid index if there is no table.
81 if(value >= table[maxIndex])
86 for(unsigned int index = 0u; index < maxIndex; ++index)
88 const int v1 = table[index];
89 const unsigned int indexPlus = index + 1u;
90 const int v2 = table[indexPlus];
91 if((v1 < value) && (value <= v2))
93 const int result = ((v1 > 0) && ((value - v1) < (v2 - value))) ? index : indexPlus;
101 * @brief Returns the FontWidth's enum index for the given width value.
103 * @param[in] width The width value.
105 * @return The FontWidth's enum index.
107 const FontWidth::Type IntToWidthType(int width);
110 * @brief Returns the FontWeight's enum index for the given weight value.
112 * @param[in] weight The weight value.
114 * @return The FontWeight's enum index.
116 const FontWeight::Type IntToWeightType(int weight);
119 * @brief Returns the FontSlant's enum index for the given slant value.
121 * @param[in] slant The slant value.
123 * @return The FontSlant's enum index.
125 const FontSlant::Type IntToSlantType(int slant);
127 const FontWidth::Type DefaultFontWidth();
128 const FontWeight::Type DefaultFontWeight();
129 const FontSlant::Type DefaultFontSlant();
131 } // namespace Dali::TextAbstraction::Internal
133 #endif // DALI_TEST_ABSTRACTION_INTERNAL_FONT_CLIENT_UTILS_H