2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/devel-api/text/bitmap-font.h>
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/devel-api/text-abstraction/bitmap-font.h>
26 #include <dali-toolkit/internal/text/character-set-conversion.h>
27 #include <dali-toolkit/internal/text/text-definitions.h>
49 BitmapFontDescription::BitmapFontDescription()
52 underlinePosition{ 0.f },
53 underlineThickness{ 1.f }
56 BitmapFontDescription::~BitmapFontDescription()
59 void CreateBitmapFont( const BitmapFontDescription& description, TextAbstraction::BitmapFont& bitmapFont )
61 bitmapFont.glyphs.reserve( description.glyphs.size() );
62 bitmapFont.name = description.name;
63 bitmapFont.underlinePosition = description.underlinePosition;
64 bitmapFont.underlineThickness = description.underlineThickness;
66 for( const auto& glyph : description.glyphs )
68 // 1) Convert to utf32
69 Vector<Character> utf32;
70 utf32.Resize( glyph.utf8.size() );
72 const uint32_t numberOfCharacters = ( glyph.utf8.size() == 0 ) ? 0 :
73 Text::Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( glyph.utf8.c_str() ),
76 utf32.Resize( numberOfCharacters );
78 TextAbstraction::BitmapGlyph bitmapGlyph( glyph.url, utf32[0u], glyph.ascender, glyph.descender );
80 bitmapFont.glyphs.push_back( std::move( bitmapGlyph ) );
84 } // namespace DevelText
86 } // namespace Toolkit